mosra / magnum

Lightweight and modular C++11 graphics middleware for games and data visualization
https://magnum.graphics/
Other
4.75k stars 439 forks source link

LeakSanitizer: detected memory leaks in imgui example #540

Closed werto87 closed 2 years ago

werto87 commented 2 years ago

Hi @mosra,

when I run this example ImGuiExample.cpp in the console build with g++ and address sanitizer on linux and exit the application I get leak warnings in the console. console output:

Platform: can't get Xft.dpi property for virtual DPI scaling, falling back to physical DPI
Renderer: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2 by NVIDIA Corporation
OpenGL version: 4.6.0 NVIDIA 470.74
Using optional features:
    GL_ARB_ES2_compatibility
    GL_ARB_direct_state_access
    GL_ARB_get_texture_sub_image
    GL_ARB_invalidate_subdata
    GL_ARB_multi_bind
    GL_ARB_robustness
    GL_ARB_separate_shader_objects
    GL_ARB_texture_filter_anisotropic
    GL_ARB_texture_storage
    GL_ARB_texture_storage_multisample
    GL_ARB_vertex_array_object
    GL_KHR_debug
Using driver workarounds:
    no-forward-compatible-core-context
    no-layout-qualifiers-on-old-glsl
    nv-zero-context-profile-mask
    nv-implementation-color-read-format-dsa-broken
    nv-cubemap-inconsistent-compressed-image-size
    nv-cubemap-broken-full-compressed-image-query
    nv-compressed-block-size-in-bits

=================================================================
==406234==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 6304 byte(s) in 4 object(s) allocated from:
    #0 0x152663213459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x15265c89029b  (/usr/lib/libnvidia-glcore.so.470.74+0xddc29b)

Direct leak of 896 byte(s) in 1 object(s) allocated from:
    #0 0x152663213652 in __interceptor_realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:164
    #1 0x15265c88f542  (/usr/lib/libnvidia-glcore.so.470.74+0xddb542)

Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x152663213459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x555e9e34c1fa in SDL_calloc_REAL /home/walde/.conan/data/sdl/2.0.16/_/_/build/9bd1f44581a74683e58f2ccaad0b487d57218fac/source_subfolder/src/stdlib/SDL_malloc.c:5404
    #2 0x555e9e47ac45 in SDL_CreateMutex_REAL /home/walde/.conan/data/sdl/2.0.16/_/_/build/9bd1f44581a74683e58f2ccaad0b487d57218fac/source_subfolder/src/thread/pthread/SDL_sysmutex.c:49
    #3 0x555e9e466795 in X11_CreateDevice /home/walde/.conan/data/sdl/2.0.16/_/_/build/9bd1f44581a74683e58f2ccaad0b487d57218fac/source_subfolder/src/video/x11/SDL_x11video.c:187
    #4 0x555e9e35cd4f in SDL_VideoInit_REAL /home/walde/.conan/data/sdl/2.0.16/_/_/build/9bd1f44581a74683e58f2ccaad0b487d57218fac/source_subfolder/src/video/SDL_video.c:519
    #5 0x555e9e47d98d in SDL_InitSubSystem_REAL /home/walde/.conan/data/sdl/2.0.16/_/_/build/9bd1f44581a74683e58f2ccaad0b487d57218fac/source_subfolder/src/SDL.c:223
    #6 0x555e9e47dace in SDL_Init_REAL /home/walde/.conan/data/sdl/2.0.16/_/_/build/9bd1f44581a74683e58f2ccaad0b487d57218fac/source_subfolder/src/SDL.c:308
    #7 0x555e9e312915 in SDL_Init /home/walde/.conan/data/sdl/2.0.16/_/_/build/9bd1f44581a74683e58f2ccaad0b487d57218fac/source_subfolder/src/dynapi/SDL_dynapi_procs.h:85
    #8 0x555e9e240835 in Magnum::Platform::Sdl2Application::Sdl2Application(Magnum::Platform::Sdl2Application::Arguments const&, Magnum::NoCreateT) /home/walde/.conan/data/magnum/2020.06/_/_/build/465bfef26dbc249a82fb0894daca6ff82f7f2efd/source_subfolder/src/Magnum/Platform/Sdl2Application.cpp:153
    #9 0x555e9e2405d1 in Magnum::Platform::Sdl2Application::Sdl2Application(Magnum::Platform::Sdl2Application::Arguments const&, Magnum::Platform::Sdl2Application::Configuration const&) /home/walde/.conan/data/magnum/2020.06/_/_/build/465bfef26dbc249a82fb0894daca6ff82f7f2efd/source_subfolder/src/Magnum/Platform/Sdl2Application.cpp:108
    #10 0x555e9e230386 in Magnum::Examples::ImGuiExample::ImGuiExample(Magnum::Platform::Sdl2Application::Arguments const&) /home/walde/projects/test_multi_thread/asio_and_multithreading/main.cxx:325
    #11 0x555e9e231ac2 in main /home/walde/projects/test_multi_thread/asio_and_multithreading/main.cxx:463
    #12 0x1526626d4b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

Indirect leak of 136904 byte(s) in 428 object(s) allocated from:
    #0 0x152663213459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x15265c89029b  (/usr/lib/libnvidia-glcore.so.470.74+0xddc29b)

Indirect leak of 4768 byte(s) in 353 object(s) allocated from:
    #0 0x152663213279 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x15265c88fe34  (/usr/lib/libnvidia-glcore.so.470.74+0xddbe34)

Indirect leak of 752 byte(s) in 6 object(s) allocated from:
    #0 0x152663213652 in __interceptor_realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:164
    #1 0x15265c88f542  (/usr/lib/libnvidia-glcore.so.470.74+0xddb542)

SUMMARY: AddressSanitizer: 149664 byte(s) leaked in 793 allocation(s).
werto87 commented 2 years ago

I get similar errors when using sfml-imgui so I think it is not an magnum problem and so I close this issue.

mosra commented 2 years ago

Yeah, these are present in the NVidia drivers (and one of them in SDL) and there's unfortunately nothing I can do about it -- it's been there for years, so I just learned to ignore them :)