BeamMP / BeamMP-Server

Server for the multiplayer mod BeamMP for BeamNG.drive
https://beammp.com
GNU Affero General Public License v3.0
131 stars 53 forks source link

Segmentation Fault on connecting #8

Closed lionkor closed 3 years ago

lionkor commented 3 years ago

When I try to join with BeamMP Client I get:

> Segmentation fault

image

Originally posted by @mnebeker in https://github.com/BeamMP/BeamMP-Server/issues/7#issuecomment-758876771

EDIT: Here's a temporary workaround: Either:

  1. Download a binary for Debian 10: https://github.com/BeamMP/BeamMP-Server/releases/tag/v1.20-linux or:
  2. Build like this:
    git reset --hard
    git checkout tags/v1.20
    cmake -S . -B bin -DCMAKE_BUILD_TYPE=Release
    make -j 4 -C bin

It might complain about cmake version, in which case you have to remove the first like of CMakeLists.txt. It might complain about lua, in which case you have to change "lua" to "lua5.3" in the non-Win32 target_link_libraries command in CMakeLists.txt.

This seems quite difficult to fix, and we're working on it. The issue will be closed as soon as that fix is out. You can Subscribe to this issue on the right to be notified of any changes or updates. Sorry for the inconvenience.

lionkor commented 3 years ago

This is an issue related to the changes to Network/Http.cpp. The crash happens in Network/Http.cpp:70 on the current master branch (b62676d), inside curl_easy_perform.

If you have the same issue, I would recommend rolling back to v1.20, which does not have this issue. You can checkout the code for v1.20 with git checkout tags/v1.20, or, for debian, download the latest linux release.

selfjell commented 3 years ago

I am having the same issue in v1.20 too. Running debian 10 Screenshot (18)

lionkor commented 3 years ago

@selfjell Are you sure? Make sure to checkout the tag, and do a full clean rebuild, and use that binary. I'm making sure since otherwise your crash would mean the issue is not where we think it was...

selfjell commented 3 years ago

I'm pretty sure. I removed everything, cloned the repository again and did git checkout tags/v1.20-linux Then I ran cmake . and make

lionkor commented 3 years ago

Damn. Could you get me backtrace of the crash?

You can do this with gdb:

gdb ./BeamMP-Server gdb will run, and prompt you with (gdb) , where you enter

r

and then it will run. Then, you take the steps to reproduce the crash, so (afaik) joining the server in this case. You will see a lot of threading related messages, but that's normal.

Once it crashes, you enter bt in the gdb console, and send a screenshot or paste the output.

selfjell commented 3 years ago

Here's the trace:

Screenshot (19)

Screenshot (20)

Let me know if you need more.

lionkor commented 3 years ago

Thank you, that looks like the same issue. Could you do a Debug build and try it again? You can set a debug build with

cmake . -DCMAKE_BUILD_TYPE=Debug

and then rebuild with make.

selfjell commented 3 years ago

Sorry for the tardy reply. I did a debug build now and used gdb to get the trace. Think it is much of the same info though.

Skjermbilde 2021-01-14 kl  19 12 26
lionkor commented 3 years ago

Thank you very much. This is still master branch code, as on 1.20 curl_easy_perform is not on line 70 in Http.cpp.

Either way, I tracked down approximately what causes the issue, and I'm working on a rewrite of the http system in the server. You can follow the progress on the segfault-fix-1 branch. Thanks everyone for the help. If you experience this issue as well, please run

git reset --hard to reset all changes you might have made and git checkout tags/v1.20 and then build once again.

If you're experiencing the exact same issue, please react with a :confused:, instead of replying.

azm613 commented 3 years ago

Currently battling this, not quite sure what to do.

lionkor commented 3 years ago

Currently battling this, not quite sure what to do.

@azm613 run these commands in order:

git reset --hard
git checkout tags/v1.20
cmake -S . -B bin -DCMAKE_BUILD_TYPE=Release
make -j 4 -C bin

If you encounter any further issues, please go the the BeamMP discord and mention me in the #support @Lion#5934

ger-pakon commented 3 years ago

On Ubuntu 20.04.01 with https://github.com/Tencent/rapidjson/ or the rapidjson-dev (1.1.0+dfsg2-5ubuntu) I ran into following Error while compiling:

ubuntu@beammp:~/BeamMP-Server$ make -j5
[  4%] Building CXX object CMakeFiles/BeamMP-Server.dir/src/Network/GParser.cpp.o
In file included from /home/ubuntu/BeamMP-Server/src/Network/GParser.cpp:14:
/home/ubuntu/BeamMP-Server/include/UnixCompat.h: In function ‘void ZeroMemory(void*, size_t)’:
/home/ubuntu/BeamMP-Server/include/UnixCompat.h:15:30: warning: unused parameter ‘dst’ [-Wunused-parameter]
   15 | inline void ZeroMemory(void* dst, size_t len) {
      |                        ~~~~~~^~~
/home/ubuntu/BeamMP-Server/include/UnixCompat.h:15:42: warning: unused parameter ‘len’ [-Wunused-parameter]
   15 | inline void ZeroMemory(void* dst, size_t len) {
      |                                   ~~~~~~~^~~
/home/ubuntu/BeamMP-Server/src/Network/GParser.cpp: In function ‘void Apply(Client*, int, const string&)’:
/home/ubuntu/BeamMP-Server/src/Network/GParser.cpp:36:24: error: ‘rapidjson::Document’ {aka ‘class rapidjson::GenericDocument<rapidjson::UTF8<> >’} has no member named ‘GetObjectA’; did you mean ‘GetObject’?
   36 |     for(auto& M : Pack.GetObjectA()){
      |                        ^~~~~~~~~~
      |                        GetObject
make[2]: *** [CMakeFiles/BeamMP-Server.dir/build.make:206: CMakeFiles/BeamMP-Server.dir/src/Network/GParser.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/BeamMP-Server.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

My first issue was the segfault, thats why I'm posting here.

Cheers, Pakon

selfjell commented 3 years ago

Had this issue too on debian. If you are using v1.20 checkout tags/v1.20-linux instead of tags/v1.20

ger-pakon commented 3 years ago

@selfjell Thank you for the clue, i can compile it now. :-) Hope the segfault is gone, now.

ger-pakon commented 3 years ago

Still get a segfault...


Thread 290 "BeamMP-Server" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe7fff700 (LWP 7038)]
0x00007ffff7ee76d7 in ?? () from /lib/x86_64-linux-gnu/libcurl.so.4
(gdb) bt
#0  0x00007ffff7ee76d7 in ?? () from /lib/x86_64-linux-gnu/libcurl.so.4
#1  0x00007ffff7ee51ce in ?? () from /lib/x86_64-linux-gnu/libcurl.so.4
#2  0x00007ffff7ed07af in ?? () from /lib/x86_64-linux-gnu/libcurl.so.4
#3  0x00007ffff7ef0b56 in ?? () from /lib/x86_64-linux-gnu/libcurl.so.4
#4  0x00007ffff7ef18d1 in curl_multi_perform () from /lib/x86_64-linux-gnu/libcurl.so.4
#5  0x00007ffff7ee7d4b in curl_easy_perform () from /lib/x86_64-linux-gnu/libcurl.so.4
#6  0x000055555559dacc in ?? ()
#7  0x000055555558d985 in ?? ()
#8  0x000055555558e72c in ?? ()
#9  0x0000555555590b27 in ?? ()
#10 0x000055555562a9a4 in ?? ()
#11 0x00007ffff7f8c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#12 0x00007ffff7dcc293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

But the binary file from: https://github.com/BeamMP/BeamMP-Server/releases/download/v1.20-linux/BeamMP-Server-debian seems to work.

lionkor commented 3 years ago

PR #10 fixes this. Once merged, any other segfaults that may occur likely belong to a different issue, and should be warranted with a new one being opened for them.

ger-pakon commented 3 years ago

Hey @lionkor

after checkout git checkout origin/segfault-fix-1 I had to install libboost-dev and libssl-dev.

After recompiling the error disappears as expected. I could join the Server. :-)

PS: In debug mode, I could see, that sometimes the heartbeat seems to trigger more than once in 5 seconds.

Thanks for fixing!

lionkor commented 3 years ago

@ger-pakon

PS: In debug mode, I could see, that sometimes the heartbeat seems to trigger more than once in 5 seconds.

That can happen at the moment, if a "hot-change" update and a normal update overlap... Otherwise it shouldn't. Will look into it, though. I'll change the README as well, once its merged, to reflect the libraries you'll need. CURL should no longer be needed, for example.

synth80s commented 3 years ago

Hey @lionkor

after checkout git checkout origin/segfault-fix-1 I had to install libboost-dev and libssl-dev.

After recompiling the error disappears as expected. I could join the Server. :-)

PS: In debug mode, I could see, that sometimes the heartbeat seems to trigger more than once in 5 seconds.

Thanks for fixing!

I checked out with my head pointed at the segfault fix, also installed the libboost-dev and libssl dependencies. I am getting a compile error in Http.cpp on #include <boost/beast/ssl.hpp>. I tried installing the latest version 1.75 since debian is only at 1.67 with no fix. I noticed this just includes a few more boost libraries, and when I manually include the, https://www.boost.org/doc/libs/1_74_0/boost/beast/ssl/ssl_stream.hpp is the only one that is not found. Any ideas?

synth80s commented 3 years ago

@ger-pakon

PS: In debug mode, I could see, that sometimes the heartbeat seems to trigger more than once in 5 seconds.

That can happen at the moment, if a "hot-change" update and a normal update overlap... Otherwise it shouldn't. Will look into it, though. I'll change the README as well, once its merged, to reflect the libraries you'll need. CURL should no longer be needed, for example.

I checked out with my head pointed at the segfault fix, also installed the libboost-dev and libssl dependencies. I am getting a compile error in Http.cpp on #include <boost/beast/ssl.hpp>. I tried installing the latest version 1.75 since debian is only at 1.67 with no fix. I noticed this just includes a few more boost libraries, and when I manually include the, https://www.boost.org/doc/libs/1_74_0/boost/beast/ssl/ssl_stream.hpp is the only one that is not found. Any ideas?

lionkor commented 3 years ago

@synth80s this has been closed as this issue is now resolved. Wait a bit for us to fix the documentation, we're still looking into your issue!

synth80s commented 3 years ago

@synth80s this has been closed as this issue is now resolved. Wait a bit for us to fix the documentation, we're still looking into your issue!

No problem, it seems like boost is missing the ssl headers and such. I just checked usr/include/boost/beast and ssl.hpp is indeed missing, even in version 1.75 (it was added in 1.71). Does debian's package manager not include this? Feel free to pm me, I am a software engineer and can help look into it as well.