-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL_TLSData storage leak, probably? #12291
Comments
Does your app call |
Yes, it does; I should have mentioned it. Without |
Is it possible that trace is incomplete? What is failing and trying to set an error? Also, don't call any SDL functions after |
To confirm that it's not the Zig's allocator to blame, I just tried to switch to using the libc's one directly: --- a/src/lib.zig
+++ b/src/lib.zig
@@ -34 +34,2 @@ pub const sdl = struct {
- try sdl.expect(@call(.auto, c.SDL_SetMemoryFunctions, sdl.memFns(allocator)), "");
+ _ = .{allocator};
+ try sdl.expect(c.SDL_SetMemoryFunctions(std.c.malloc, std.c.calloc, std.c.realloc, std.c.free), ""); and ran the executable through valgrind:
I'm attaching the produced log: sdl-tlsdata-leak-valgrind.log. But long story short, valgrind does see the leak, too:
|
This is usually caused by not properly cleaning up threads, or calling SDL functions from threads that aren't created by SDL. Do you use multiple threads in that program? What's the minimal program you can write that has that leak? |
My own code doesn't use multiple threads. To make absolutely sure the Zig standard library doesn't use them either, I just tried to rebuild the app with the single-threaded flag enabled: --- a/build.zig
+++ b/build.zig
@@ -90,0 +91 @@ pub fn build(b: *std.Build) void {
+ exe_mod.single_threaded = true; But the leak is still reported. |
@icculus, that valgrind log is really interesting. We should check it out before the next release. |
I was using SDL v3.2.4 in a Ziglang project, having called
SDL_SetMemoryFunctions
in mySDL_AppInit
to switch to Zig'sGeneralPurposeAllocator
which, in debug build, automatically reports leaks at a deinitialization.Having the latest master version of Zig (
0.14.0-dev.3217+5b9b5e45c
), I ran$ zig build run -- 3.pool-end-game
, then closed the app and on exit got the following trace:The leaked allocation is the only one, as this kludge fixes it:
The text was updated successfully, but these errors were encountered: