raylib: [raudio] Segfault when loading (relatively) large files as Wave.
- I tested it on latest raylib version from master branch.
- I checked there is no similar issue already reported.
- My code has no errors or misuse of raylib (I hope?).
Issue description
When loading multiple-minute .mp3 files as Wave’s and calling the GetWaveData(Wave) method the application segfaults with no further explanation, I understand that we’re supposed to use the Music type for longer files, but bear with me as I have a (not-so-)weird use case, and there are some things about this which lead me to believe that it should/could actually work:
- It seems to be related to virtual memory size, as when running the application with either lldb or enabling address sanitizer (both of which set the virtual memory size to obscene values) then the application works flawlessly.
- I’ve used a 3-minute (3.9MB) .mp3 file for my own testing. I’ve noticed that some of the audio metadata extracted by raylib seems to be different from what another audio tool (ocenaudio) says. Ocenaudio says the file is 16-bit, while raylib says it is 32-bit, ocenaudio reports 8008125 samples, while raylib reports 16017408 (which divided by two would be 8008704, so still a bit different). I have not actually ran the numbers to check which count is correct, but I think this might help explain the issue somehow.
If this is recognized as an actual bug, I would be willing to try and contribute a PR to fix the issue, given some basic guidance.
Environment
- macOS Catalina 10.15.5
- Intel HD Graphics 3000 512 MB
- OpenGL Version: 3.3 INTEL-10.4.14
- Using AppleClang 12.0.0.12000032
- Reproduced with both raylib from master and the pre-built 3.0.0 binaries.
Code Example
#include "raylib.h"
int main(int, char**) {
InitWindow(400, 200, "unseen");
InitAudioDevice();
Wave bgm_wave = LoadWave("resources/bgm/tmnt.mp3");
float* bgm_wave_data = GetWaveData(bgm_wave);
// Main game loop
while (!WindowShouldClose())
{
TraceLog(LOG_INFO, "Wave size: %u %f", bgm_wave.sampleCount, bgm_wave_data[10]);
BeginDrawing();
ClearBackground(GetColor(0x052c46ff));
DrawText("I hope you will never see this.", 100, 100, 10, RAYWHITE);
EndDrawing();
}
UnloadWave(bgm_wave);
CloseWindow();
CloseAudioDevice();
return 0;
}
PS: in the 3.0.0 release the Apple crash reporter could track the error down to https://github.com/raysan5/raylib/blob/3.0.0/src/raudio.c#L1024 which on master seems to be https://github.com/raysan5/raylib/blob/master/src/raudio.c#L1091
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (11 by maintainers)
Commits related to this issue
- Update audio libraries #1423 miniaudio -> v0.10.25 dr_wav -> v0.12.14 dr_mp3 -> v0.6.19 dr_flac -> v0.12.22 — committed to raysan5/raylib by raysan5 4 years ago
@pedromundo ya gotta love libasan, if you add -g you should get line numbers on the back trace, compile both raylib and your app with libasan and -g
I use the following flags for asan btw
@mackron doing it now! 😄
drmp3_open_memory_and_read_f32()
was renamed todrmp3_open_memory_and_read_pcm_frames_f32()
over a year ago. You should probably upgrade dr_mp3 and try again (might have some API changes to deal with, though).