Hi, Mark,

Sounds like progress!

> On May 25, 2020, at 13:56, Mark Ruzindana <ruziem...@gmail.com> wrote:
> 
> I have been able to capture data with the first round of frames of the 
> circular buffer i.e. if I have 160 frames, I am able to capture packets of 
> frames 0 to 159 at which point right at the memcpy() in the process_packet() 
> function of the net thread, I get a segmentation fault.

The fact that you get a the segfault right at the memcpy of the final frame of 
the ring buffer suggests that there is problem with the parameters passed to 
memcpy.  Most likely src+length-1 exceeds the end of the frame so you get a 
segfault when memcpy tries to read from beyond the allocated memory.  This 
would explain why it segfaults on the final frame and not the previous frames 
because reading beyond a previous frame still reads from "legal" (though 
incorrect) memory locations.  It's also possible that the segfault happens due 
to a bad address on the destination side of the memcpy(), but unless the 
destination buffer is also 160 frames in size that seems less likely.

The release_frame function is not likely to be a culprit here unless the 
pointer you are passing it differs from the pointer that the pktsock_recv 
function returned.

For debugging, I suggest logging dst, src, len before calling memcpy.  Normally 
you wouldn't generate a log message for every packet because that would ruin 
your throughput, but since you know it's going to crash after the first 160 
packets there's not much throughout to ruin. :)

One thing to remember is that PKT_UDP_DATA() evaluates to a pointer to the UDP 
payload of the packet, but PKT_UDP_SIZE() evaluates to the total UDP size (i.e. 
8 bytes for the UDP header plus the length of the UDP payload).  Passing 
PKT_UDP_SIZE() as "len" to memcpy without subtracting 8 for the header bytes is 
not correct and could potentially cause this problem.

HTH,
Dave

-- 
You received this message because you are subscribed to the Google Groups 
"casper@lists.berkeley.edu" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to casper+unsubscr...@lists.berkeley.edu.
To view this discussion on the web visit 
https://groups.google.com/a/lists.berkeley.edu/d/msgid/casper/297C1709-AE9C-488D-9110-FD0832BF5951%40berkeley.edu.

Reply via email to