socket-chat
socket-chat copied to clipboard
CPP Server segfaults when user sends "/q" (quit) command
I just tested your code as I am in search of exactly something like this. But the CPP version crashes with a segfault everytime a user sends "/q" (quit).
This only happens when the server was compiled with a recent g++ compiler (e.g. 8.3.0.) , it seems.
Interesting. I'm involved in other stuff presently. I'll try to look into it, but can't promise. Need to get recent version of g++ also. Thanks for reporting though 🙂 If you get curious and find the root cause, we can discuss here.
I did some debugging using DDD with one version running on a Raspberry Pi with Raspbian Linux (compiled with g++ 6.x) that works fine and compared it with a version compiled with g++ 8.3.0 on a x86_64 Ubuntu PC.
The segfault happens in "serverChat.cc" at line 34.
With the g++ 6.x build the condition of the "for (auto &p : clients)" loop (line 34) is not matched and the code returns to the while loop. Everything is fine.
However, with the g++ 8.x build the code simpy segfaults at the same line (line 34). It happens during the second iteration of the "for ..." loop after handleLostConnection has been called.
May be an optimizing problem or a change with g++ handling exceptions or so. I haven't touched C++ code in a while. Maybe that helps, thank you very much for getting back to me.
P.S.: great software, quite interesting for retro people like me building a classic console based BBS based on Linux standard tools.
Hey! I got a chance to try running this with g++ 9.1.0. Couldn't reproduce this bug there unfortunately. If I get my hands on 8.3.0, I'll try again and let you know.