On Feb 12, 2014, at 11:42 AM, Daniel H. Bahr <dhb...@gmail.com> wrote:

> Hello everyone, I really hope this is the right place to post this
> since I did not find a pcap-specific mailing list,

There aren't separate tcpdump or libpcap mailing lists.  This list is for all 
tcpdump-related and libpcap-related mail, regardless of whether they're about 
using tcpdump/libpcap (you're in the "using libpcap" group) or developing 
tcpdump/libpcap.

> Now it has been displaying an erratic behaviour in which after a
> number of packets captured it would crash with a SIGSEGV.

On what OS is this?  (I ask because not all OSes use SIGSEGV and SIGBUS for the 
same purposes, and because, with some versions of some OSes and libpcap, the 
packet data handed to your callback will, I think, be write-protected - see 
below.)

What type of processor is this running on?  (I ask because there might be 
alignment issues on some processors, although I'd expect a SIGBUS, rather than 
a SIGSEGV, for alignment issues.)

Can you get a stack trace to see where the SIGSEGV is happening?

>       capture_loop (pd, packets, (pcap_handler)parse_packet);

The cast to (pcap_handler) shouldn't be necessary...

> void parse_packet(u_char *user, struct pcap_pkthdr *packethdr,
>                  u_char *packetptr) {

...and *won't* be necessary if you change that to

        void parse_packet(u_char *user, const struct pcap_pkthdr *packethdr,
                         const u_char *packetptr) {

If your code fails to compile after you make that change, your code may be 
incorrect; libpcap does not guarantee that you will be able to modify either 
the struct pcap_pkthdr handed to you or the raw packet data handed to you, and, 
if you try to do so, Bad Things could happen (including a crash, if that data 
is in a region of your address space not writable by you).
_______________________________________________
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers

Reply via email to