tx00100xt / SeriousSamClassic-VK

Open source game engine version developed by Croteam for Serious Sam Classic with Vulkan support (Windows, Linux, FreeBSD, OpenBSD, macOS, Raspberry Pi OS). Based on https://github.com/sultim-t/Serious-Engine-Vk and linux port https://github.com/icculus/Serious-Engine
GNU General Public License v2.0
104 stars 12 forks source link

Crash on Start on Linux #21

Closed d10sfan closed 1 year ago

d10sfan commented 1 year ago

I'm seeing a strange crash immediately after starting on Linux, 1.10.2 works fine, so it seems like something was introduced after that.

This happens immediately after attempting to launch the game, I see the following if I try running with gdb, I get the following stack trace. Let me know if there's anything other information you need or if you see something I'm doing wrong here.

I'm making a build script, you can see it here for reference: https://github.com/luxtorpeda-dev/packages/blob/44560873121aebbf2240b77892933197647fdf47/engines/serious-engine/build.sh

(gdb) r
Starting program: /home/d10sfan/.local/share/Steam/steamapps/common/Serious Sam Classic The First Encounter/Bin/SeriousSam 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
0x00007ffff7d889b9 in _GLOBAL__sub_I_Normals.cpp ()
   from /home/d10sfan/.local/share/Steam/steamapps/common/Serious Sam Classic The First Encounter/Bin/libEngine.so
(gdb) bt
#0  0x00007ffff7d889b9 in _GLOBAL__sub_I_Normals.cpp ()
   from /home/d10sfan/.local/share/Steam/steamapps/common/Serious Sam Classic The First Encounter/Bin/libEngine.so
#1  0x00007ffff7fcf0fe in ?? () from /lib64/ld-linux-x86-64.so.2
#2  0x00007ffff7fcf1ec in ?? () from /lib64/ld-linux-x86-64.so.2
#3  0x00007ffff7fe4f00 in ?? () from /lib64/ld-linux-x86-64.so.2
#4  0x0000000000000001 in ?? ()
#5  0x00007fffffffddfd in ?? ()
#6  0x0000000000000000 in ?? ()
(gdb) 
#0  0x00007ffff7d889b9 in _GLOBAL__sub_I_Normals.cpp ()
   from /home/d10sfan/.local/share/Steam/steamapps/common/Serious Sam Classic The First Encounter/Bin/libEngine.so
#1  0x00007ffff7fcf0fe in ?? () from /lib64/ld-linux-x86-64.so.2
#2  0x00007ffff7fcf1ec in ?? () from /lib64/ld-linux-x86-64.so.2
#3  0x00007ffff7fe4f00 in ?? () from /lib64/ld-linux-x86-64.so.2
#4  0x0000000000000001 in ?? ()
#5  0x00007fffffffddfd in ?? ()
#6  0x0000000000000000 in ?? ()
(gdb) q
A debugging session is active.

        Inferior 1 [process 207599] will be killed.

Quit anyway? (y or n) y
tx00100xt commented 1 year ago

Hello. There were few changes between versions 1.10.2 and 1.10.3.

First change: -mtune=generic has been replaced in CMakeLists.txt with -march=native to be compatible with Raspberry PI. https://github.com/tx00100xt/SeriousSamClassic-VK/commit/dd84a2180bd0cccaa5d74e3c19503dc75752dbbe

If it is done for everyone, then it is better to return -mtune=generic. find . -name "CMakeLists.txt" -exec sed -i 's/-march=native/-mtune=generic/g' {} +

The second change concerns the timer. In version 1.10.2, the OPTEX (optimized mutex) section was restored from win32 code. https://github.com/tx00100xt/SeriousSamClassic-VK/commit/9f7e1ccc4c8bd948c35e23185d13b94ca7aa1af6 It worked correctly on GCC 10.xx and it became incorrect to work in GCC 11.xx. Between versions 1.10.2 and 1.10.3 there was a fix for 11.xx. https://github.com/tx00100xt/SeriousSamClassic-VK/commit/a22b4e0d11cc895371a2ae4135b3dea0582d43cd You can try building with USE_SINGLE_THREAD = TRUE, since I didn't find any difference between builds with USE_SINGLE_THREAD = TRUE and USE_SINGLE_THREAD = FALSE. find . -name "CMakeLists.txt" -exec sed -i '/^option(USE_SINGLE_THREAD/s/FALSE/TRUE/g' {} +

The third fix looks at the possibility of placing executable files in /usr/bin. libraries in /usr/lib and data in /usr/share https://github.com/tx00100xt/SeriousSamClassic-VK/commit/77712ea8ef6daee5fd91a7677670ff26e6676310 , as well as searching for game data in the home directory https://github.com/tx00100xt/SeriousSamClassic-VK/commit/6276882f2e03edd6cfb505bb3239e193d2e288ef https://github.com/tx00100xt/SeriousSamClassic-VK/commit/48143b121a150e55e9ee386456b92f8060a88655 . And placing all user files in the home directory https://github.com/tx00100xt/SeriousSamClassic-VK/commit/d9d3386a0060af95d4581d3d95972adb94ea3bbf. I don't think this should cause the game to crash.

Other changes between versions 1.10.2 and 1.10.3 are not fundamental

Since the Github Action is used for building and subsequent use for everyone https://github.com/luxtorpeda-dev/packages/actions/runs/4560400259/workflow https://github.com/luxtorpeda-dev/packages/actions/runs/4560400259/jobs/8045305806, I would recommend trying to change -march=native to -mtune=generic first.

find . -name "CMakeLists.txt" -exec sed -i 's/-march=native/-mtune=generic/g' {} +

tx00100xt commented 1 year ago

For the sake of interest, I inserted the lines into the Workflow file: echo "=== native ===" gcc -v -E -x c /dev/null -o /dev/null -march=native 2>&1 | grep /cc1 echo "=== generic ===" gcc -v -E -x c /dev/null -o /dev/null -mtune=generic 2>&1 | grep /cc1 https://github.com/tx00100xt/SE1-TSE-OddWorld/actions/runs/4565752992/jobs/8057310670#step:3:255

As you can see, with the "-march=native" key, the compilation will be optimized for the server running gcc. In addition,

Illegal instruction.

hints to us that the execution is on a hardware different from the one for which it was optimized. I think that changing "-march=native" to "-mtune=generic" in the "CMakeLists.txt " file should solve the problem.

d10sfan commented 1 year ago

Thanks! mtune=generic fixed it for me, and now the build works on my system. Thanks for the help!