Levo
January 27, 2025, 9:44pm
1
I have address and UB sanitizer enabled by default for my projects. I compiled a nearly blank SDL3 file and address san is reporting a ton of leaks in SDL_DBus_Init. Do I not bother with asan? With SDL2 I didn’t get a leak. I don’t really care too much, I’m not too worried about leaks
It seems like SDL does not shut down DBus because it might still be in use by other parts of the application.
opened 02:06PM - 20 Sep 23 UTC
closed 09:24AM - 08 Nov 23 UTC
Using leak sanitizer, I am getting
these leaks after SDL_quit():
```
Indirect… leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x7f80a66143e2 in __interceptor_malloc ../../../../src/libsanitizer/lsan/lsan_interceptors.cpp:75
#1 0x7f80a5150a17 in _dbus_string_init_preallocated ../../../dbus/dbus-string.c:156
#2 0x7f80a5159496 in _dbus_auth_new.constprop.0 ../../../dbus/dbus-auth.c:368
#3 0x7f80a512fbcd in _dbus_auth_client_new ../../../dbus/dbus-auth.c:2408
#4 0x7f80a514e484 in _dbus_transport_init_base ../../../dbus/dbus-transport.c:120
#5 0x7f80a514e484 in _dbus_transport_new_for_socket ../../../dbus/dbus-transport-socket.c:1326
#6 0x7f80a51560b8 in _dbus_transport_new_for_domain_socket ../../../dbus/dbus-transport-unix.c:94
#7 0x7f80a515830b in _dbus_transport_open_platform_specific ../../../dbus/dbus-transport-unix.c:259
#8 0x7f80a5148c04 in _dbus_transport_open ../../../dbus/dbus-transport.c:393
#9 0x7f80a5134ecf in connection_try_from_address_entry ../../../dbus/dbus-connection.c:1830
#10 0x7f80a5134ecf in _dbus_connection_open_internal ../../../dbus/dbus-connection.c:1899
#11 0x7f80a5136280 in internal_bus_get ../../../dbus/dbus-bus.c:475
#12 0x7f80a334d1c2 in SDL_DBus_Init_Spinlocked /usr/src/libsdl2-2.28.3+dfsg-2/src/core/linux/SDL_dbus.c:153
#13 0x7f80a326561e in SDL_DBus_Init /usr/src/libsdl2-2.28.3+dfsg-2/src/core/linux/SDL_dbus.c:175
#14 0x7f80a326561e in SDL_InitSubSystem_REAL /usr/src/libsdl2-2.28.3+dfsg-2/src/SDL.c:182
```
It is not happening always.
In fact, it seems pretty random.
I wasn't able to figure out the
particular scenario when that
appears.
Looking into the code, I can see
this in SDL_dbus.c:
```
/* Don't do this - bug 3950
dbus_shutdown() is a debug feature which closes all global resources in the
dbus library. Calling this should be done by the app, not a library, because if
there are multiple users of dbus in the process then SDL could shut it down ev
en though another part is using it.
*/
#if 0
if (dbus.shutdown) {
dbus.shutdown();
}
#endif
```
If this piece is responsible for a leak,
then I suggest to revisit that solution
and do something else. Using an SDL
hint would be a cheapest solution, but
I guess the better ones exist too.
1 Like
Levo
January 28, 2025, 9:02pm
3
Great now I have a reason I can point to