0
clang -g -fsanitize=memory -Wconversion -Wsign-conversion -Wextra -Wall -Werror -pedantic -I/usr/include/SDL2 -lSDL2_image -lSDL2_gfx -lSDL2 -lSDL2_ttf -lc -lm ./deps/**/*.c ./src/*.c ./src/**/*.c -o ./bin/output

./bin/output

Uninitialized bytes in __interceptor_strlen at offset 5 inside [0x717000000310, 6)
==172913==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f39adb0bd0b  (/usr/lib/libSDL2-2.0.so.0+0x7fd0b)
    #1 0x7f39adb7a338  (/usr/lib/libSDL2-2.0.so.0+0xee338)
    #2 0x7f39adb7e840  (/usr/lib/libSDL2-2.0.so.0+0xf2840)
    #3 0x7f39adb4e33e  (/usr/lib/libSDL2-2.0.so.0+0xc233e)
    #4 0x7f39adaad307  (/usr/lib/libSDL2-2.0.so.0+0x21307)
    #5 0x560a0db3c817 in main /home/ishidex2/progs/get_out/./src/main.c:33:5
    #6 0x7f39ad8ddb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #7 0x560a0daa83fd in _start (/home/ishidex2/progs/get_out/bin/output+0x213fd)

Logs show the last code I could have possibly written myself was at main:33:5, which is the first line of main() that just contains SDL_Init(SDL_INIT_EVERYTHING);

Does SDL do that intentionally, if so, is there a way to supress that?

  • Post the code from main.c line 1 -> 33 then. Otherwise it's difficult to help you. – Morten Jensen Jun 28 '21 at 16:15
  • sorry forgot to mention, the main:33 is the first line of main() –  Jun 28 '21 at 16:18
  • The traceback shows the error is in SDL2. But, there are no debug symbols, so we can't see what it is doing. Don't know about other distros (e.g. ubuntu), but in fedora, `gdb` would tell you what commands are necessary to install the debuginfo packages [to get the symbols/debug info]. (e.g.) `dnf debuginfo-install package ...` With that, we could get a traceback that will point to files and line numbers, etc. You can then install the source packages, so you see the code. – Craig Estey Jun 28 '21 at 16:40
  • I've never seen using wildcards on `.dep/*.c` before. And, `./src/**/*.c` is unusual because of the double star. Did you mean: `./src/*/*.c` or `./src/*/*/*.c`? It might help to post the final/flattened list vs. the wildcards. – Craig Estey Jun 28 '21 at 16:46
  • Since SDL2 is widely used [and presumably debugged ;-)], you may be getting a false positive. Also, my guess is that SDL2 is prebuilt with `gcc` [and you're using `clang`]. It might be interesting to rebuild SDL2 (et. al.) from source with debug switches, either with `gcc` or `clang` – Craig Estey Jun 28 '21 at 16:49
  • Hmm yeah, SDL2 compiled with gcc might be the problem, gcc has sanitizers but it doesn't have msan –  Jun 28 '21 at 16:54
  • @CraigEstey I'm not sure if arch linux has debug builds of sdl2, so I'll try building it myself –  Jun 28 '21 at 16:55
  • When building from source, be careful about the install. It might want to install under `/usr/local/...` which would keep it from colliding with the prebuilt version [probably a good thing]. But, it might try to overwrite the prebuilt install. I had trouble with prebuilt SDL2 under ubuntu, so I uninstalled it and rebuilt from source and used that version thereafter--YMMV – Craig Estey Jun 28 '21 at 17:05

0 Answers0