Skip to content

Commit

Permalink
Add lsan.supp for opengl leak (fixes ddnet#5296)
Browse files Browse the repository at this point in the history
See also Jupeyy's explanation in
ddnet#4294 for why we want to ignore
this:

> sadly components have no OnDestruct on anything like that
> so aslong it doesn't actually leak it's just non destructed memory

So it's something we allocate once for the entire client lifetime from
my understanding.

=================================================================
==421461==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 411760 byte(s) in 10 object(s) allocated from:
    #0 0x55eaf0c08a29 in malloc (/media/ddnet/integration_test/DDNet+0x736a29)
    #1 0x55eaf0de9f72 in CCommandProcessorFragment_OpenGL2::Cmd_CreateBufferObject(CCommandBuffer::SCommand_CreateBufferObject const*) /media/ddnet/src/engine/client/backend/opengl/backend_opengl.cpp:1898:25
    #2 0x55eaf0dd82f5 in CCommandProcessorFragment_OpenGL::RunCommand(CCommandBuffer::SCommand const*) /media/ddnet/src/engine/client/backend/opengl/backend_opengl.cpp
    #3 0x55eaf0f73229 in CCommandProcessor_SDL_GL::RunBuffer(CCommandBuffer*) /media/ddnet/src/engine/client/backend_sdl.cpp:246:20
    #4 0x55eaf0f70568 in CGraphicsBackend_Threaded::ThreadFunc(void*) /media/ddnet/src/engine/client/backend_sdl.cpp:75:25
    #5 0x55eaf0d679d7 in thread_run(void*) /media/ddnet/src/base/system.cpp:686:2
    #6 0x7f08b788c54c  (/usr/lib/libc.so.6+0x8c54c)

SUMMARY: AddressSanitizer: 411760 byte(s) leaked in 10 allocation(s).
  • Loading branch information
def- committed Jun 5, 2022
1 parent 44a79d5 commit 9a89e58
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/clang-sanitizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
cd san
export UBSAN_OPTIONS=suppressions=../ubsan.supp:log_path=./SAN:print_stacktrace=1:halt_on_errors=0
export ASAN_OPTIONS=log_path=./SAN:print_stacktrace=1:check_initialization_order=1:detect_leaks=1:halt_on_errors=0
export LSAN_OPTIONS=suppressions=../lsan.supp
./DDNet "cl_download_skins 0;quit" || true
./DDNet-Server shutdown || true
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ make
```
and run with:
```bash
UBSAN_OPTIONS=suppressions=./ubsan.supp:log_path=./SAN:print_stacktrace=1:halt_on_errors=0 ASAN_OPTIONS=log_path=./SAN:print_stacktrace=1:check_initialization_order=1:detect_leaks=1:halt_on_errors=0 ./DDNet
UBSAN_OPTIONS=suppressions=./ubsan.supp:log_path=./SAN:print_stacktrace=1:halt_on_errors=0 ASAN_OPTIONS=log_path=./SAN:print_stacktrace=1:check_initialization_order=1:detect_leaks=1:halt_on_errors=0 LSAN_OPTIONS=suppressions=./lsan.supp ./DDNet
```

Check the SAN.\* files afterwards. This finds more problems than memcheck, runs faster, but requires a modern GCC/Clang compiler.
Expand Down
1 change: 1 addition & 0 deletions lsan.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
leak:CCommandProcessorFragment_OpenGL2::Cmd_CreateBufferObject
7 changes: 4 additions & 3 deletions scripts/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ fi
# TODO: check for open ports instead
port=17822

cp ../ubsan.supp .
cp ../memcheck.supp .
cp ../ubsan.supp ../lsan.supp ../memcheck.supp .

if [[ $OSTYPE == 'darwin'* ]]; then
DETECT_LEAKS=0
Expand All @@ -135,6 +134,7 @@ fi

export UBSAN_OPTIONS=suppressions=./ubsan.supp:log_path=./SAN:print_stacktrace=1:halt_on_errors=0
export ASAN_OPTIONS=log_path=./SAN:print_stacktrace=1:check_initialization_order=1:detect_leaks=$DETECT_LEAKS:halt_on_errors=0
export LSAN_OPTIONS=suppressions=./lsan.supp

function print_results() {
if [ "$arg_valgrind_memcheck" == "1" ]; then
Expand All @@ -153,7 +153,7 @@ function print_results() {
}

if [ "$arg_valgrind_memcheck" == "1" ]; then
tool="valgrind --tool=memcheck --gen-suppressions=all --suppressions=memcheck.supp"
tool="valgrind --tool=memcheck --gen-suppressions=all --suppressions=memcheck.supp --track-origins=yes"
client_args="cl_menu_map \"\";"
else
tool=""
Expand Down Expand Up @@ -242,6 +242,7 @@ say "/mc
;cmdlist
;saytime"
EOF
sleep 1
echo "[*] test rcon commands"
tr -d '\n' > client1.fifo << EOF
rcon say hello from admin;
Expand Down

0 comments on commit 9a89e58

Please sign in to comment.