iptube / SPUDlib

Substrate Protocol for User Datagrams (SPUD) Prototype
BSD 2-Clause "Simplified" License
5 stars 11 forks source link

spudecho Causes a Segfault #44

Closed phpHavok closed 9 years ago

phpHavok commented 9 years ago

After compiling and running spudecho, it will wait for a client to connect with an OPEN message. After the message arrives, spudecho will segfault in the process of sending an ACK. See the following information from the core dump and GDB:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f88fbfd171f in tube_send (t=0x1990590, cmd=SPUD_ACK, adec=false, pdec=false,
data=0x0, len=0x0, num=0, err=0x7fff8c0fdb80) at /home/jacob/Desktop/SPUDlib/src/tube.c:184
184         cmsg->cmsg_level = IPPROTO_IPV6;

Here is a snippet of the code surrounding line 184 in src/tube.c:

183         cmsg = CMSG_FIRSTHDR(&msg);
184         cmsg->cmsg_level = IPPROTO_IPV6;
185         cmsg->cmsg_type = IPV6_PKTINFO;
186         cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));

Apparently, CMSG_FIRSTHDR() is returning NULL.

OS: Linux 3.19.0-16-generic #16-Ubuntu SMP Thu Apr 30 16:09:58 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux Compiler: gcc version 4.9.2 (Ubuntu 4.9.2-10ubuntu13)

hildjj commented 9 years ago

As far as I can tell, this can only happen if msg_controllen is too small. I'm re-working this whole set of code anyway; I'll make sure to test this afterwards, and I'll ask you to see if you can recreate the problem after that refactor.

phpHavok commented 9 years ago

That sounds great, thanks!

phpHavok commented 9 years ago

Hello, there. I was wondering if there is any news regarding this? Do you perhaps have a workaround for ensuring that msg_controllen is not too small for the time being?

hildjj commented 9 years ago

Can you try the "timers" branch, please?

phpHavok commented 9 years ago

Excellent, it's working! Thank you so much.