Hi! On Thu, 2020-07-23 at 03:20:21 +0300, Boian Bonev wrote: > I have had the same problem last couple of days, finally could track > what is happening:
Hah, just had finished fixing this locally, when I checked for the bug number to slap to the commit message, saw this. :) > - Exit.pm installs a handler for __DIE__ Yes, this was the main problem. > I would suggest two things: > > 1) Fix the code in Vendor.pm to avoid the global handler around eval > and make the code work as initially planned (patch attached) That would be a workaround as any other eval would also need to be protected, which makes the exit handlers usage rather unsafe. I'm attaching the fix I had prepared, which I'll be including in 1.20.6. Thanks, Guillem
diff --git i/scripts/Dpkg/Exit.pm w/scripts/Dpkg/Exit.pm index 70a29b1a6..07f122fab 100644 --- i/scripts/Dpkg/Exit.pm +++ w/scripts/Dpkg/Exit.pm @@ -75,7 +75,10 @@ Run the registered exit handlers. =cut sub run_exit_handlers { - $_->() foreach (reverse @handlers); + while (my $handler = pop @handlers) { + $handler->(); + } + _reset_exit_handlers(); } sub _exit_handler { @@ -83,7 +86,7 @@ sub _exit_handler { exit(127); } -my @SIGNAMES = qw(INT HUP QUIT __DIE__); +my @SIGNAMES = qw(INT HUP QUIT); my %SIGOLD; sub _setup_exit_handlers @@ -101,6 +104,10 @@ sub _reset_exit_handlers } } +END { + run_exit_handlers(); +} + =back =head1 CHANGES diff --git i/scripts/t/Dpkg_Exit.t w/scripts/t/Dpkg_Exit.t index b4b15e405..663dfc96b 100644 --- i/scripts/t/Dpkg_Exit.t +++ w/scripts/t/Dpkg_Exit.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 7; BEGIN { use_ok('Dpkg::Exit'); @@ -51,7 +51,17 @@ sub exit_handler { exit 0; } +sub ini_handler { + pass('ini handler invoked'); +} + +sub end_handler { + pass('end handler invoked'); +} + +Dpkg::Exit::push_exit_handler(\&end_handler); Dpkg::Exit::push_exit_handler(\&exit_handler); +Dpkg::Exit::push_exit_handler(\&ini_handler); kill 'INT', $$;