Subject: | pcap_loop crashes when interrupted by a signal |
Hello Sébastien,
This makes fwknop raise a segmentation fault on i386 architectures as
mentionned in:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508432
Martin Ferrari has submitted the following patch and a test script
that allows a way to easily reproduce the problem through the test.pl
script.
Is there any reason to allow the call of the pcap_loop to be
interrupted?
If the behavior has to be changed as done by the patch, I will either
patch the Debian package currently in Debian Sid or import the new
release if you intend to do so.
Regards,
---
Franck Joncourt
Subject: | test.pl |
#!/usr/bin/perl -w
use Net::Pcap;
my $err = '';
my $pcap = Net::Pcap::open_live('lo', 1024, 1, 0, \$err);
Net::Pcap::loop($pcap, 10, \&process_packet, "just for the demo");
Net::Pcap::close($pcap);
sub process_packet {
my($user_data, $header, $packet) = @_;
local $SIG{CHLD} = \&sigchld;
system("echo foo");
}
sub sigchld {
print "SIGCHLD\n";
}
Subject: | signal_handler.diff |
From: Franck Joncourt <franck.mail@dthconnex.com>
Subject: [PATCH] fixes/signal_handler
We do not allow pcap_loop function to be interrupted by a signal.
This makes fwknop raise a segmentation fault on i386 as mentionned in:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508432
Martin Ferrari has submitted the following patch and a test script that allows
a way to easily reproduce the problem.
Signed-off-by: Franck Joncourt <franck.mail@dthconnex.com>
---
Pcap.xs | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/Pcap.xs b/Pcap.xs
index a49138c..ca3ad16 100644
--- a/Pcap.xs
+++ b/Pcap.xs
@@ -410,10 +410,7 @@ pcap_loop(p, cnt, callback, user)
callback_fn = newSVsv(callback);
user = newSVsv(user);
- SAVE_signals = PL_signals; /* Allow the call to be interrupted by signals */
- PL_signals |= PERL_SIGNALS_UNSAFE_FLAG;
RETVAL = pcap_loop(p, cnt, callback_wrapper, (u_char *)user);
- PL_signals = SAVE_signals;
SvREFCNT_dec(user);
SvREFCNT_dec(callback_fn);
--
tg: (22e6285..) fixes/signal_handler (depends on: master)