Date: Thu, 13 Jan 2005 13:24:25 +0100 From: Jonas Nagel <fireball@zerouptime.ch> To: Anton Berezin <tobez@tobez.org> Cc: FreeBSD-gnats-submit@FreeBSD.org Subject: Re: ports/76120: [perl] coredump in perl 5.8.5 in malloc()-call from Perl_pp_split() Message-ID: <20050113132425.7dc89730.fireball@zerouptime.ch> In-Reply-To: <20050113095722.GA6034@heechee.tobez.org> References: <200501112101.j0BL1pZ8072388@www.freebsd.org> <200501112110.j0BLACOK089672@freefall.freebsd.org> <20050111222201.6b5a5351.fireball@zerouptime.ch> <20050113095722.GA6034@heechee.tobez.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 13 Jan 2005 10:57:22 +0100 Anton Berezin <tobez@tobez.org> wrote: > Jonas, could you maybe re-post a complete minimal script that > reproduces the problem? Otherwise it is a bit cryptic. Of course; actually I thought this question would come but didn't want to completely clutter up the bug report in first place. Here a complete script; I also noticed, that the problem apppears only while I am using the Pcap-Filter function. If I comment setArpFilt() from the code, then it doesn't crash anymore. It appears that the Pcap filter function prepares the packet contents in a way that leads to a crash within the PERL split() function. If there is also a problem in the Pcap code, is another question. I can't see the reason from debug output. #!/usr/local/bin/perl -w use strict; use Net::Pcap; my $err = ""; my $mynet = ""; my $mymask = ""; my $dev = ""; my $pcap_t = ""; my $snaplen = 1024; my $promisc = 1; my $to_ms = 100; my $cnt = -1; my $inst = 1; if(!$ARGV[0]) { die("Specify at least one argument!\n"); } $dev = $ARGV[0]; if(Net::Pcap::lookupnet($dev, \$mynet, \$mymask, \$err)) { die("$err\n"); } print("Network is: ". inet_ntoa($mynet) .", Mask is ". inet_ntoa($mymask) ."\n"); $pcap_t = Net::Pcap::open_live($dev, $snaplen, $promisc, $to_ms, \$err); if(!$pcap_t) { die("$err\n"); } # &setArpFilt($pcap_t, $mymask); Net::Pcap::loop($pcap_t, $cnt, \&display_pkt, $inst); Net::Pcap::close($pcap_t); exit; sub inet_ntoa { return join ".",unpack("CCCC",pack("N",shift)); } sub inet_atoh { return split(//,unpack("H*",pack("CCCC",split(/\./,shift)))); } sub pkt_btoh { my @pkt = (); my $tmp = unpack("H*",shift); my @tmp = split(//,$tmp); my $rng = (scalar(@tmp)/2); for (my $i = 0; $i < $rng; $i++) { $pkt[$i] = shift(@tmp) . shift(@tmp); } return @pkt; } sub display_pkt { my($inst, $hdr, $pkt) = @_; my @pkt = &pkt_btoh($pkt); if (isArpBC(@pkt)) { print("I$inst: $hdr->{'len'} $hdr->{'caplen'} $hdr->{'tv_usec'} - ". join("",@pkt) ."\n"); } } sub setArpFilt { my $pcap_t = shift; my $netmask = shift; my $optimize = 1; my $filter_t = ""; my $filter_str = "arp"; if(Net::Pcap::compile($pcap_t, \$filter_t, $filter_str, $optimize, $netmask)) { die("Net::Pcap::compile returned error: ". Net::Pcap::geterr($pcap_t). "\n"); } if(Net::Pcap::setfilter($pcap_t, $filter_t)) { die("Net::Pcap::setfilter returned error: ". Net::Pcap::geterr($pcap_t). "\n"); } return; } -- Jonas Nagel <fireball@zerouptime.ch>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050113132425.7dc89730.fireball>