raysan5/raylib

[build] AddressSanitizer:DEADLYSIGNAL with Debug VCPKG build

pkeir opened this issue · 8 comments

I need to maintain multiple Windows installations of raylib, while creating new small example raylib applications on my own Ubuntu system. I use CMake and VCPKG to manage this.

On Ubuntu, using VCPKG to provide raylib v5.0, I find that around every 5-10th run of a simple raylib program will not (after say 60 secs.) display the raylib window, and instead fills the console window with 1000s of AddressSanitizer:DEADLYSIGNAL messages:

$ ./core_basic_window 
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
...

This is only the case when the exe is linked against asan and ubsan; as required for a debug build (i.e. one which links against $VCPKG_ROOT/installed/x64-linux/debug/lib/libraylib.a, as found by CMake's find_package). I attach a CMakeLists.txt file and link to raylib's core_basic_window.c for convenience.

CMakeLists.txt

core_basic_window.c

Have you tried building with debug info, and getting a backtrace?

I had the same issue with building a project on linux (kubuntu releastag 5.0), address sanitizer would sometimes crash with multiple deadlysignal until the signalstack overflows and the kernel killed it completely

Sincerely, no idea how to even start reviewing this issue... more detailed info is required...

I personally don't have any either. I tried to debug the issue, but attaching the debugger made the issue vanish. I think it could be a problem with the sanitizer itself (unlikely I guess?). Maybe just put it in some kind of knoiwn issue list, thats why I mentioned it occured to me as well.

Here some info and a good starting point (maybe):
This is the output of building and running the program:

kyomawolf@kyomapad:~/Code/anothertwo$ ninja -C build && ./build/raylibtest.app
ninja: Entering directory `build'
[2/2] Linking target raylibtest.app
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
Segmentation fault (core dumped)

this is the journalentry: Apr 03 13:18:27 kyomapad kernel: signal: raylibtest.app[228055] overflowed sigaltstack
here the repo with the modified branch
To setup: meson setup <builddirectory> and to build: ninja -C <builddirectory> you will find the executable as raylibtest.app

I'm afraid this issue can not be addressed with provided information, actually it could be not raylib related but any underlying library.

It seems possible to me that there is a memory management issue within Raylib, which is being picked up by Address Sanitizer. This could be important, but let's put that to the side just now.

If I build Raylib myself on Linux, and then use the example program I mentioned above, there are no errors. I can use GCC or Clang, with a debug or release build:

$CXX core_basic_window.c -I raylib-5.0/install-debug/include -L raylib-5.0/install-debug/lib/ -lraylib
$CXX core_basic_window.c -I raylib-5.0/install-release/include -L raylib-5.0/install-release/lib/ -lraylib

So it is the maintainer of Raylib's VCPKG package who is adding the linkage of ASan and UBSan. While I have little against this, it is not a common choice within VCPKG. As the memory management issue is not a priority, this could then be a good moment to remove the unusual linkage of ASan and UBSan from the VCPKG package.

The question is then: are you in control of the Raylib VCPKG package?

The question is then: are you in control of the Raylib VCPKG package?

I'm afraid I'm not.