-
-
Notifications
You must be signed in to change notification settings - Fork 418
Encoder: Segfault when doing (de)allocation between init/uninit calls #975
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
Comments
With your miniaudio has no restrictions on your memory allocations. It uses allocation callbacks, which if you don't provide yourself will use I don't have an explanation for this one. Maybe there is some kind of memory overrun or something happening, but that seems exceptionally unlikely because I've just looked now and I can't see any memory allocations happening in |
with my some_allocator_allocate_some_bytes() i was referring to an allocator separate from miniaudio. specifically i had this issue with the std.testing.allocator from the zig library. thank you for looking into this, this is definitely weird! |
OK, I don't think this is an issue with miniaudio then. If you don't specify your own allocation callbacks, which sounds like is the case for you, miniaudio will always use C's Are you sure this isn't an issue with the Zig bindings? |
could be an issue with zig or maybe an issue of malloc / testing allocator causing some bad (side) effects that i don't know of (the testing allocator detects memory leaks and therefore tracks stuff). i don't think it's an issue with the bindings because they are auto translated from the header, merely call the compiled c code (compilation via clang) and they do work by themselves. it's even weirder if no allocation is happening in the miniaudio calls. i will check if the issue persists using other allocators. |
because im writing zig i will write pseudocode:
this works:
ma_encoder_init_file(...)
ma_encoder_uninit(...)
this segfaults:
ma_encoder_init_file(...)
some_allocator_allocate_some_bytes()
ma_encoder_uninit(...)
some_allocator_free_some_bytes()
errors with a segfault which i will attach here after.
Q: does this hint at a bug triggering this segfault or is it forbidden to do any allocation / dealloction between the init/uninit calls of encoder?
Segmentation fault at address 0x52bddff160
D:\Programming\Zig\lib\musicfiles\miniaudio\extras\miniaudio_split\manual patch\miniaudio.c:54630:0: 0x7ff6343e4ee9 in ma_encoder__internal_on_seek_wav (miniaudio.obj)
result = pEncoder->onSeek(pEncoder, offset, (origin == ma_dr_wav_seek_origin_start) ? ma_seek_origin_start : ma_seek_origin_current);
D:\Programming\Zig\lib\musicfiles\miniaudio\extras\miniaudio_split\manual patch\miniaudio.c:69301:0: 0x7ff634273029 in ma_dr_wav_uninit (miniaudio.obj)
if (pWav->onSeek(pWav->pUserData, 4, ma_dr_wav_seek_origin_start)) {
D:\Programming\Zig\lib\musicfiles\miniaudio\extras\miniaudio_split\manual patch\miniaudio.c:54684:0: 0x7ff6342addfb in ma_encoder__on_uninit_wav (miniaudio.obj)
ma_dr_wav_uninit(pWav);
D:\Programming\Zig\lib\musicfiles\miniaudio\extras\miniaudio_split\manual patch\miniaudio.c:54887:0: 0x7ff6342aea9e in ma_encoder_uninit (miniaudio.obj)
pEncoder->onUninit(pEncoder);
D:\Programming\Zig\lib\musicfiles\src\AudioNode\fileio.zig:437:32: 0x7ff6345da78b in deinit (test.exe.obj)
c.ma_encoder_uninit(&self.enc);
The text was updated successfully, but these errors were encountered: