Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Net::Pcap Solaris and bizare coredumping

by zengargoyle (Deacon)
on Dec 10, 2002 at 02:03 UTC ( [id://218721]=perlquestion: print w/replies, xml ) Need Help??

zengargoyle has asked for the wisdom of the Perl Monks concerning the following question:

Check this out:

#!/usr/usc/perl/5.6.1/bin/perl use strict; use warnings; $|++; my $dev = shift @ARGV; $dev ||= 'qe0'; my $filter_string = 'udp src port 68 and dst port 67'; #my $filter_string = 'udp'; my $snaplen = 1508; my $promisc = 1; my $timeout = 100; my $count = -1; use Net::Pcap; my $err = ''; my $cap_dev; my $filter = ''; my $net = -256; $cap_dev = Net::Pcap::open_live($dev, $snaplen, $promisc, $timeout, \$ +err); die "$err\n" if $err; Net::Pcap::compile($cap_dev, \$filter, $filter_string, 0, -256) and die "compile: $err\n"; Net::Pcap::setfilter($cap_dev, $filter); Net::Pcap::loop($cap_dev, $count, \&callback, 'woot'); Net::Pcap::close($cap_dev); exit 0; sub callback { my ($user_data, $hdr, $pkt) = @_; warn "packet!\n"; my %header = %$hdr; #process_packet(\%header, $pkt); my $len = length $pkt; # warn "$header{len} $header{caplen} $len\n"; } sub process_packet { my ($hdr, $pkt) = @_; my $len = length $pkt; warn "$hdr->{len} $hdr->{caplen} $len\n"; }

This happily prints:

packet!
packet!
packet!
packet!

Unless I uncomment the warn line. Then I get:

packet!
342 342 342
Segmentation Fault (core dumped)

Which seems quite odd. Any ideas what could cause this behavior?

This is perl, v5.6.1 built for sun4-solaris
Net::Pcap 0.04
libpcap 0.7.1

Otherwise I use the perl and pcap (tcpdump...) all the time without seeing anything this bizare.

Replies are listed 'Best First'.
Re: Net::Pcap Solaris and bizare coredumping
by Fletch (Bishop) on Dec 10, 2002 at 15:11 UTC

    Possibly irrelevant, but make sure that you compiled Net::Pcap with the same compiler used to build your perl (gcc or the Sun unbundled cc). I've seen and heard of compiler mismatch being a frequent problem on Solaris.

      Yep, thought of that... everything is built with the Sun cc.

      Wah! guess I'll have to pipe off a tcpdump and read it's output.(cringe)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://218721]
Approved by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 06:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found