Skip to content
Snippets Groups Projects
Commit 66ab5181 authored by Olivier Dion's avatar Olivier Dion Committed by Sébastien Blin
Browse files

agent/bindings/signal: Protect from GC callbacks

Change-Id: If91bed7badd8229aee216a91445b758e8901e573
parent 440a71b4
No related branches found
No related tags found
No related merge requests found
...@@ -83,6 +83,8 @@ public: ...@@ -83,6 +83,8 @@ public:
SCM ret = apply_to_guile(cb, args...); SCM ret = apply_to_guile(cb, args...);
if (scm_is_true(ret)) { if (scm_is_true(ret)) {
to_keep.emplace_back(cb); to_keep.emplace_back(cb);
} else {
scm_gc_unprotect_object(cb);
} }
} }
...@@ -138,6 +140,7 @@ on_signal_binding(SCM signal_sym, SCM handler_proc) ...@@ -138,6 +140,7 @@ on_signal_binding(SCM signal_sym, SCM handler_proc)
mutex = static_cast<std::mutex*>(scm_to_pointer(scm_cdr(handler_pair))); mutex = static_cast<std::mutex*>(scm_to_pointer(scm_cdr(handler_pair)));
std::unique_lock lck(*mutex); std::unique_lock lck(*mutex);
scm_gc_protect_object(handler_proc);
callbacks->push_back(handler_proc); callbacks->push_back(handler_proc);
return SCM_UNDEFINED; return SCM_UNDEFINED;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment