We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5521

Summary: enable AddressSanitizer and fix memory issues
Product: SDL Reporter: Christian Rauch <Rauch.Christian>
Component: buildAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.15   
Hardware: All   
OS: All   
Attachments: AddressSanitizer patch set (tar.xz)
patch enable AddressSanitizer if supported

Description Christian Rauch 2021-01-30 23:42:48 UTC
Created attachment 4741 [details]
AddressSanitizer patch set (tar.xz)

This set of patches enable AddressSanitizer [1] and fix memory issues that were found by it. The set of patches are provided as tar.xz again as I was not able to add multiple patches at once.

There are further leaks reported in "SDL_dbus.c", "SDL_egl.c" and "SDL_render_gl.c", but those seem to be in external dependencies. If you run debug executables with `ASAN_OPTIONS=fast_unwind_on_malloc=0`, e.g. "ASAN_OPTIONS=fast_unwind_on_malloc=0 ./testscale" you can find more details about those.

[1] https://clang.llvm.org/docs/AddressSanitizer.html
Comment 1 Sam Lantinga 2021-02-01 03:13:31 UTC
The two fixes are applied:
https://hg.libsdl.org/SDL/rev/064d83809cf8
https://hg.libsdl.org/SDL/rev/19a9918810ba

The first patch needs to check to make sure the address sanitization flags are supported by the compiler before setting them in the CFLAGS.
Comment 2 Christian Rauch 2021-02-02 00:45:25 UTC
Created attachment 4748 [details]
patch enable AddressSanitizer if supported

This patch adds the AddressSanitizer flags if supported by the compiler.
Comment 3 Sam Lantinga 2021-02-02 04:26:01 UTC
Great, thanks!
https://hg.libsdl.org/SDL/rev/d5b71cb1a9dd