Skip to content
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

gmusializer(20953,0x1e2b35b40) malloc: double free for ptr 0x158028000 #64

Closed
wisonye opened this issue Dec 21, 2023 · 9 comments
Closed

Comments

@wisonye
Copy link

wisonye commented Dec 21, 2023

Hi, I love all your YouTube videos and was watching your latest one This Release is Insane!, then I want to try it by myself. Here are the steps I had tried and then I saw the double free bug:

Apple M2 Macbook Air with the following clang version:

clang --version
Homebrew clang version 17.0.6
Target: arm64-apple-darwin22.4.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
  1. Install ffmpeg and raylib 5.0

  2. Compile the project

    # Compile no build without any error
    clang -o nob nob.c
    
    # Comiple the binary with warnings
    /Users/wison/c/musializer   ./nob
    
    # [INFO] --- STAGE 1 ---
    # [INFO] created directory `build`
    # [INFO] Generating ./build/config.h
    # [INFO] CMD: cc -o ./build/nob.configured nob.c -DCONFIGURED
    # [INFO] CMD: ./build/nob.configured
    # [INFO] --- STAGE 2 ---
    # [INFO] Target: macos
    # [INFO] Hotreload: DISABLED
    # [INFO] Microphone: DISABLED
    # [INFO] ---
    # [INFO] created directory `./build/raylib`
    # [INFO] created directory `./build/raylib/macos`
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/rcore.c -o ./build/raylib/macos/rcore.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/raudio.c -o ./build/raylib/macos/raudio.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -x objective-c -c ./raylib/raylib-5.0/src/rglfw.c -o ./build/raylib/macos/rglfw.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/rmodels.c -o ./build/raylib/macos/rmodels.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/rshapes.c -o ./build/raylib/macos/rshapes.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/rtext.c -o ./build/raylib/macos/rtext.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/rtextures.c -o ./build/raylib/macos/rtextures.o
    # [INFO] CMD: clang -g -DPLATFORM_DESKTOP -fPIC -I./raylib/raylib-5.0/src/external/glfw/include -Iexternal/glfw/deps/ming -DGRAPHICS_API_OPENGL_33 -c ./raylib/raylib-5.0/src/utils.c -o ./build/raylib/macos/utils.o
    # In file included from ./raylib/raylib-5.0/src/rmodels.c:111:
    # ./raylib/raylib-5.0/src/external/par_shapes.h:1133:32: warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]
    #  1133 |     float r = (float) rand() / RAND_MAX;
    #       |                              ~ ^~~~~~~~
    # /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/stdlib.h:105:18: note: expanded from macro 'RAND_MAX'
    #   105 | #define RAND_MAX        0x7fffffff
    #       |                         ^~~~~~~~~~
    # 1 warning generated.
    # [INFO] CMD: ar -crs ./build/raylib/macos/libraylib.a ./build/raylib/macos/rcore.o ./build/raylib/macos/raudio.o ./build/raylib/macos/rglfw.o ./build/raylib/macos/rmodels.o ./build/raylib/macos/rshapes.o ./build/raylib/macos/rtext.o ./build/raylib/macos/rtextures.o ./build/raylib/macos/utils.o
    # [INFO] CMD: clang -Wall -Wextra -g -I./build/ -I./raylib/raylib-5.0/src/ -o ./build/musializer ./src/plug.c ./src/ffmpeg_linux.c ./src/musializer.c ./build/raylib/macos/libraylib.a -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL -lm -ldl -lpthread
    # [INFO] created directory `./build/resources/`
    # [INFO] created directory `./build/resources//logo`
    # [INFO] copying ./resources//logo/logo-256.ico -> ./build/resources//logo/logo-256.ico
    # [INFO] copying ./resources//logo/logo-256.png -> ./build/resources//logo/logo-256.png
    # [INFO] copying ./resources//logo/logo.svg -> ./build/resources//logo/logo.svg
    # [INFO] created directory `./build/resources//icons`
    # [INFO] copying ./resources//icons/fullscreen.svg -> ./build/resources//icons/fullscreen.svg
    # [INFO] copying ./resources//icons/volume.png -> ./build/resources//icons/volume.png
    # [INFO] copying ./resources//icons/volume.svg -> ./build/resources//icons/volume.svg
    # [INFO] copying ./resources//icons/fullscreen.png -> ./build/resources//icons/fullscreen.png
    # [INFO] created directory `./build/resources//shaders`
    # [INFO] created directory `./build/resources//shaders/glsl120`
    # [INFO] copying ./resources//shaders/glsl120/circle.fs -> ./build/resources//shaders/glsl120/circle.fs
    # [INFO] created directory `./build/resources//shaders/glsl330`
    # [INFO] copying ./resources//shaders/glsl330/circle.fs -> ./build/resources//shaders/glsl330/circle.fs
    # [INFO] created directory `./build/resources//fonts`
    # [INFO] copying ./resources//fonts/OFL.txt -> ./build/resources//fonts/OFL.txt
    # [INFO] copying ./resources//fonts/Alegreya-Regular.ttf -> ./build/resources//fonts/Alegreya-Regular.ttf
    
    
    ls -lht build/
    # total 5696
    # drwxr-xr-x@ 6 wison  staff   192B 22 Dec 09:50 resources/
    # drwxr-xr-x@ 3 wison  staff    96B 22 Dec 09:50 musializer.dSYM/
    # -rwxr-xr-x@ 1 wison  staff   2.7M 22 Dec 09:50 musializer*
    # drwxr-xr-x@ 3 wison  staff    96B 22 Dec 09:50 raylib/
    # -rwxr-xr-x@ 1 wison  staff    69K 22 Dec 09:50 nob.configured*
    # -rw-r--r--@ 1 wison  staff   457B 22 Dec 09:50 config.h
  3. Run it without error

    /Users/wison/c/musializer   ./build/musializer
    
    # INFO: FILEIO: [./resources/logo/logo-256.png] File loaded successfully
    # INFO: IMAGE: Data loaded successfully (256x256 | R8G8B8A8 | 1 mipmaps)
    # INFO: Initializing raylib 5.0
    # INFO: Platform backend: DESKTOP (GLFW)
    # INFO: Supported raylib modules:
    # INFO:     > rcore:..... loaded (mandatory)
    # INFO:     > rlgl:...... loaded (mandatory)
    # INFO:     > rshapes:... loaded (optional)
    # INFO:     > rtextures:. loaded (optional)
    # INFO:     > rtext:..... loaded (optional)
    # INFO:     > rmodels:... loaded (optional)
    # INFO:     > raudio:.... loaded (optional)
    # INFO: DISPLAY: Device initialized successfully
    # INFO:     > Display size: 1280 x 832
    # INFO:     > Screen size:  1280 x 720
    # INFO:     > Render size:  1280 x 720
    # INFO:     > Viewport offsets: 0, 0
    # INFO: GLAD: OpenGL extensions loaded successfully
    # INFO: GL: Supported extensions count: 43
    # INFO: GL: OpenGL device information:
    # INFO:     > Vendor:   Apple
    # INFO:     > Renderer: Apple M2
    # INFO:     > Version:  4.1 Metal - 83.1
    # INFO:     > GLSL:     4.10
    # INFO: GL: VAO extension detected, VAO functions loaded successfully
    # INFO: GL: NPOT textures extension detected, full NPOT textures supported
    # INFO: GL: DXT compressed textures supported
    # INFO: PLATFORM: DESKTOP (GLFW): Initialized successfully
    # INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
    # INFO: TEXTURE: [ID 1] Default texture loaded successfully
    # INFO: SHADER: [ID 1] Vertex shader compiled successfully
    # INFO: SHADER: [ID 2] Fragment shader compiled successfully
    # INFO: SHADER: [ID 3] Program shader loaded successfully
    # INFO: SHADER: [ID 3] Default shader loaded successfully
    # INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
    # INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
    # INFO: RLGL: Default OpenGL state initialized successfully
    # INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
    # INFO: FONT: Default font loaded successfully (224 glyphs)
    # WARNING: GLFW: Error: 65548 Description: Cocoa: Regular windows do not have icons on macOS
    # INFO: TIMER: Target time per frame: 16.667 milliseconds
    # INFO: AUDIO: Device initialized successfully
    # INFO:     > Backend:       miniaudio / Core Audio
    # INFO:     > Format:        32-bit IEEE Floating Point -> 32-bit IEEE Floating Point
    # INFO:     > Channels:      2 -> 2
    # INFO:     > Sample rate:   48000 -> 48000
    # INFO:     > Periods size:  1440
    # INFO: FILEIO: [./resources/fonts/Alegreya-Regular.ttf] File loaded successfully
    # INFO: TEXTURE: [ID 3] Texture loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
    # INFO: FONT: Data loaded successfully (64 pixel size | 95 glyphs)
    # INFO: TEXTURE: [ID 3] Mipmaps generated automatically, total: 11
    # INFO: FILEIO: [./resources/shaders/glsl330/circle.fs] Text file loaded successfully
    # INFO: SHADER: [ID 4] Fragment shader compiled successfully
    # INFO: SHADER: [ID 5] Program shader loaded successfully
    # INFO: TEXTURE: [ID 4] Texture loaded successfully (1600x900 | R8G8B8A8 | 1 mipmaps)
    # INFO: TEXTURE: [ID 1] Depth renderbuffer loaded successfully (32 bits)
    # INFO: FBO: [ID 1] Framebuffer object created successfully
  4. Drag&drop 2 MP3 files into the UI, then it crash:

    running_screenshot
    gmusializer(20953,0x1e2b35b40) malloc: double free for ptr 0x158028000
    musializer(20953,0x1e2b35b40) malloc: *** set a breakpoint in malloc_error_break to debug
    fish: Job 1, './build/musializer' terminated by signal SIGABRT (Abort)
@wisonye wisonye changed the title musializer(20321,0x1e2b35b40) malloc: double free gmusializer(20953,0x1e2b35b40) malloc: double free for ptr 0x158028000 Dec 21, 2023
@wisonye
Copy link
Author

wisonye commented Dec 21, 2023

I've already given it another try on Intel iMac as well, same double free issue:

musializer(7021,0x114acde00) malloc: *** error for object 0x7ff350118000: pointer being freed was not allocated
musializer(7021,0x114acde00) malloc: *** set a breakpoint in malloc_error_break to debug

@wisonye
Copy link
Author

wisonye commented Dec 23, 2023

It happens in Arch Linux as well...

@petergr20
Copy link

petergr20 commented Dec 29, 2023

same thing on ubuntu

Linux tux 6.5.0-14-generic #14-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:59:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

./build/musializer
INFO: FILEIO: [./resources/logo/logo-256.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (256x256 | R8G8B8A8 | 1 mipmaps)
INFO: Initializing raylib 5.0
INFO: Platform backend: DESKTOP (GLFW)
INFO: Supported raylib modules:
INFO: > rcore:..... loaded (mandatory)
INFO: > rlgl:...... loaded (mandatory)
INFO: > rshapes:... loaded (optional)
INFO: > rtextures:. loaded (optional)
INFO: > rtext:..... loaded (optional)
INFO: > rmodels:... loaded (optional)
INFO: > raudio:.... loaded (optional)
INFO: DISPLAY: Device initialized successfully
INFO: > Display size: 1920 x 1080
INFO: > Screen size: 1280 x 720
INFO: > Render size: 1280 x 720
INFO: > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 235
INFO: GL: OpenGL device information:
INFO: > Vendor: AMD
INFO: > Renderer: AMD Radeon Graphics (raphael_mendocino, LLVM 15.0.7, DRM 3.54, 6.5.0-14-generic)
INFO: > Version: 4.6 (Core Profile) Mesa 23.2.1-1ubuntu3.1
INFO: > GLSL: 4.60
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: DXT compressed textures supported
INFO: GL: ETC2/EAC compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW): Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: TIMER: Target time per frame: 16.667 milliseconds
INFO: AUDIO: Device initialized successfully
INFO: > Backend: miniaudio / PulseAudio
INFO: > Format: 32-bit IEEE Floating Point -> 32-bit Signed Integer
INFO: > Channels: 2 -> 2
INFO: > Sample rate: 48000 -> 48000
INFO: > Periods size: 3600
INFO: FILEIO: [./resources/fonts/Alegreya-Regular.ttf] File loaded successfully
INFO: TEXTURE: [ID 3] Texture loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (64 pixel size | 95 glyphs)
INFO: TEXTURE: [ID 3] Mipmaps generated automatically, total: 11
INFO: FILEIO: [./resources/shaders/glsl330/circle.fs] Text file loaded successfully
INFO: SHADER: [ID 4] Fragment shader compiled successfully
INFO: SHADER: [ID 5] Program shader loaded successfully
INFO: TEXTURE: [ID 4] Texture loaded successfully (1600x900 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Depth renderbuffer loaded successfully (32 bits)
INFO: FBO: [ID 1] Framebuffer object created successfully

free(): double free detected in tcache 2
Aborted (core dumped)

file build/musializer
build/musializer: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=aac14e731ee5a88467b3667d1da784831d0617e3, for GNU/Linux 3.2.0, with debug_info, not stripped

log of the end of strace

strace ./build/musializer
....

read(19, "\224F\320\1r\2\0\0\32I\320\1\n\2\0\0,K\320\1r\2\0\0\262M\320\1r\2\0\0"..., 4096) = 4096
read(19, "\220x\325\1C\3\0\0\350{\325\1C\3\0\0@\177\325\1\n\2\0\0R\201\325\1\n\2\0\0"..., 61440) = 61440
read(19, "\250[#\2r\2\0\0.^#\2\333\2\0\0\22a#\2\n\2\0\0000c#\2\n\2\0\0"..., 4096) = 4096
read(19, "\242\224(\2\n\2\0\0\300\226(\2r\2\0\0F\231(\2r\2\0\0\300\233(\2r\2\0\0"..., 61440) = 48304
read(19, "", 16384) = 0
read(19, "", 65536) = 0
close(19) = 0
writev(2, [{iov_base="free(): double free detected in "..., iov_len=40}, {iov_base="\n", iov_len=1}], 2free(): double free detected in tcache 2
) = 41
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fedae473000
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
gettid() = 15061
getpid() = 15061
tgkill(15061, 15061, SIGABRT) = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=15061, si_uid=1000} ---
+++ killed by SIGABRT (core dumped) +++
Aborted (core dumped)

@rexim
Copy link
Member

rexim commented Feb 8, 2024

Is this problem still reproducible? I could not reproduce it either on my Debian or Window setup.

@petergr20
Copy link

petergr20 commented Feb 8, 2024 via email

@petergr20
Copy link

I'm trying with raylib-4.5.0 in nob.c and same result ;-(

INFO: FBO: [ID 1] Framebuffer object created successfully
free(): double free detected in tcache 2
Abandon (core dumped)

@jgabaut
Copy link
Contributor

jgabaut commented Feb 16, 2024

@wisonye

It happens in Arch Linux as well...

Can't reproduce this on Arch Linux from a fresh build with raylib 5.0.

$ uname -r
6.7.4-arch1-1

@petergr20
Copy link

works file now thx

Capture d’écran du 2024-02-25 21-18-08

@rexim
Copy link
Member

rexim commented Feb 26, 2024

Cool

@rexim rexim closed this as completed Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants