0

DESCRIPTION

I made a C server mod for cube 2: Sauerbraten https://github.com/deathstar/QServCollect

all the code can be found at the link above

The IRC Bot eventually stops sending the ping/pong data on the opened socket. The process is threaded and since the main thread is joined through PTHREAD_CREATE_JOINABLE, it dies when the IRC bot dies. This causes the entire server to crash, and I am just trying to debug it. Any help would be appreciated.

KEY

Ircbot code: ircbot/ircbot.cpp, ircbot/ircbot.h

Main thread: engine/server.cpp

LLDB DEBUG REPORT

Process 7933 stopped
* thread #1: tid = 0xa4b8d, 0x00007fff83e4010a libsystem_kernel.dylib`__semwait_signal + 10, queue = 'com.apple.main-thread', stop reason = signal SIGPIPE
    frame #0: 0x00007fff83e4010a libsystem_kernel.dylib`__semwait_signal + 10
libsystem_kernel.dylib`__semwait_signal:
->  0x7fff83e4010a <+10>: jae    0x7fff83e40114            ; <+20>
    0x7fff83e4010c <+12>: movq   %rax, %rdi
    0x7fff83e4010f <+15>: jmp    0x7fff83e3a7f2            ; cerror
    0x7fff83e40114 <+20>: retq  

SERVER LOG

PING :NuclearFallout.WA.US.GameSurge.net

SENT: PONG :NuclearFallout.WA.US.GameSurge.net

PING :NuclearFallout.WA.US.GameSurge.net

SENT: PONG :NuclearFallout.WA.US.GameSurge.net

[ OK ] looking up sauerbraten.org...
master server registration failed: failed pinging server
[ OK ] looking up sauerbraten.org...
  • 1
    You need to post the relevant parts of the code here, not at an external link. – Barmar Aug 11 '16 at 00:22
  • 1
    You don't get a seg fault from a sigpipe. You might get a seg fault from your sigpipe handler mishandling the first signal. What is your code doing and how is it handling signals in particular. – Jonathan Leffler Aug 11 '16 at 00:45
  • Read my comment [here](http://pastebin.com/hdeTB1yc), The conflicting code [here](http://pastebin.com/TbyAQqag), main function with threading [here](http://pastebin.com/E7huThZR). – George Scott Aug 11 '16 at 04:39

1 Answers1

1

The problem was that a function (specifically sscanf) was overloaded with data. I needed to do a strlen(buff) to check the buffer size of the data going into the function. Essentially it was getting much more data than it could handle and it would cause a crash eventually because of it.

If you are implementing threading, make sure to use thread safe implementations.

george
  • 11
  • 1