[Bug] EE crashes when attempting to start a server while the server is already running
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 869
- Forks
- 222
- Avg merge
- 18h 33m
- Merged PRs (30d)
- 1
Description
Issue
On Linux, EmptyEpsilon crashes if you try to start a server on a system that's already running a server.
This is consistently reproducible on builds off master and off the EE-2024.12.08 tag. I haven't tested this on Windows or macOS.
Steps to reproduce
- Launch EE as a server, i.e.
EmptyEpsilon headless=scenario_00_basic.luaor via the GUI. - Launch another instance of EE, either also as a server or by clicking "Start server" in the main menu, then "Start server" on the server configuration screen.
Expected behavior
EE returns an error indicating that the port isn't open, and doesn't crash.
Observed behavior
The failure to listen is logged, but EE then crashes with a segfault.
[INFO ]: Launching headless scenario scenario_00_basic.lua on port 35666
[ERROR ]: Failed to listen on TCP port: 35666
[ERROR ]: Failed to listen on UDP port: 35666
Segmentation fault (core dumped)
Core dump backtrace:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f68f58c2307 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data (
this=<optimized out>)
at /usr/src/debug/gcc-15.2.1-1.fc42.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.h:239
239 { return _M_dataplus._M_p; }
[Current thread is 1 (Thread 0x7f68f5e1cc80 (LWP 919399))]
(gdb) bt
#0 0x00007f68f58c2307 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data (
this=<optimized out>)
at /usr/src/debug/gcc-15.2.1-1.fc42.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.h:239
#1 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_is_local (this=<optimized out>)
at /usr/src/debug/gcc-15.2.1-1.fc42.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.h:280
#2 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::capacity (this=<optimized out>)
at /usr/src/debug/gcc-15.2.1-1.fc42.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.h:1279
#3 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign (this=0x50, __str="server")
at /usr/src/debug/gcc-15.2.1-1.fc42.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.tcc:314
#4 0x00000000005d642f in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign ()
at /usr/include/c++/15/bits/basic_string.h:1771
#5 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator= ()
at /usr/include/c++/15/bits/basic_string.h:906
#6 string::operator= () at /home/oznogon/git/emptyepsilon-compile/SeriousProton/src/stringImproved.h:22
#7 GameServer::setServerName () at /home/oznogon/git/emptyepsilon-compile/SeriousProton/src/multiplayer_server.h:112
#8 operator() () at /home/oznogon/git/emptyepsilon-compile/EmptyEpsilon/src/menus/serverCreationScreen.cpp:111
#9 0x00000000008a16fd in std::function<void()>::operator() () at /usr/include/c++/15/bits/std_function.h:593
#10 GuiButton::onMouseUp () at /home/oznogon/git/emptyepsilon-compile/EmptyEpsilon/src/gui/gui2_button.cpp:63
#11 0x0000000000894041 in GuiCanvas::onPointerUp ()
at /home/oznogon/git/emptyepsilon-compile/EmptyEpsilon/src/gui/gui2_canvas.cpp:63
#12 0x00000000004cb18d in RenderLayer::onPointerUp ()
at /home/oznogon/git/emptyepsilon-compile/SeriousProton/src/Renderable.cpp:66
#13 0x0000000000500bd1 in Window::handleEvent ()
at /home/oznogon/git/emptyepsilon-compile/SeriousProton/src/windowManager.cpp:255
#14 0x00000000004711c3 in Engine::handleEvent ()
at /home/oznogon/git/emptyepsilon-compile/SeriousProton/src/engine.cpp:356
#15 0x000000000047149f in Engine::runMainLoop ()
at /home/oznogon/git/emptyepsilon-compile/SeriousProton/src/engine.cpp:212
#16 0x00000000004499f6 in main () at /home/oznogon/git/emptyepsilon-compile/EmptyEpsilon/src/main.cpp:241
Possible fix
Check if (!game_server) after new EpsilonServer(port), return if the server didn't launch instead of crashing, and if triggered from on ServerCreationScreen, output an error like "Failed to create game server on port ..." in the UI.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with EmptyEpsilon headless=scenario_00_basic.lua or through the server UI, then inspect SeriousProton/src/multiplayer_server.h around GameServer::setServerName() and EmptyEpsilon/src/menus/serverCreationScreen.cpp around the server-start callback. Done means a second server attempt reports the port failure in logs or the UI without crashing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, lua
- Domain
- game-dev, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100