From 5c4e6304ce12a3c94cc58eec01d4ef45db4dabc3 Mon Sep 17 00:00:00 2001 From: Stephen Oberholtzer Date: Tue, 28 Feb 2017 23:48:56 -0500 Subject: Don't emit the script destroyed signal before script is actually destroyed The script unloading code originally worked like this: 1. Destroy package 2. Emit 'script destroyed' signal 3. Unhook script's signal handlers If a script added a 'script destroyed' signal handler, unloading that script would cause the 'script destroyed' signal to be sent to the (already destroyed) package. This would cause a script error, which would trigger a script unload, which would start the whole process over again, until we run out of heap or stack space and segfault. This commit simply reorders the operations so that the 'script destroyed' signal is sent *after* the script is fully destroyed. --- src/perl/perl-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/perl/perl-core.c b/src/perl/perl-core.c index e4bde559..39389157 100644 --- a/src/perl/perl-core.c +++ b/src/perl/perl-core.c @@ -67,11 +67,11 @@ static void perl_script_destroy(PERL_SCRIPT_REC *script) { perl_scripts = g_slist_remove(perl_scripts, script); - signal_emit("script destroyed", 1, script); - perl_signal_remove_script(script); perl_source_remove_script(script); + signal_emit("script destroyed", 1, script); + g_free(script->name); g_free(script->package); g_free_not_null(script->path); -- cgit v1.2.3