SDL_Mixer: Mix_FreeChunk() crashing on sample created in mem |
gejiaxu
|
Just realized I copied the code wrong when posting the simplified test. "result" was supposed to be "s2". Fixed the code here:
|
|||||||||||||
|
gejiaxu
|
After examining the isolated test some more, the freeing of s2 is specifically crashing in free.c during the HeapFree(_crtheap, 0, pBlock) call, so somehow the heap is corrupted in the space of those few lines? The intermediate code in Mix_FreeChunk() is actually quite simple, more or less just calling free() on the buffer. That being the case why would s1 be okay but s2 fail?
|
|||||||||||
|
gejiaxu
|
Sorry for spamming this but I can't edit posts and a solution has been found.
Turns out I was using pre-compiled SDL libs and if you do this and combine it with your own code, then the system may be using *different* versions of malloc()/free() at runtime. This naturally causes heap corruption, so the solution is to either make sure to compile SDL and your program in the same environment, or force the compiler to use the appropriate version of malloc. Changing the above code to the following works fine:
where
|
|||||||||||||||
|
SDL_Mixer: Mix_FreeChunk() crashing on sample created in mem |
Juan Manuel Borges Caño
Guest
|
I like, and planned to use the pitch idea :-), does Mixer not have API for that?
|
|||||||||||
|
gejiaxu
|
No it doesn't, but you can manipulate the sample yourself in memory to achieve that effect. It can't be done in real-time, but you can at least make a copy of the sample and scale its pitch.
|
|||||||||||
|
SDL_Mixer: Mix_FreeChunk() crashing on sample created in mem |
Daniel Gibson
Guest
|
I think this is not only about "different versions of malloc/free" -
another problem is that on windows each DLL has its own heap. Anyway, I guess the "proper" solution is to use SDL_malloc() and SDL_free() for data you wanna allocate that SDL should free or for data SDL allocated that you wanna free, so the corresponding data is handled by SDLs heap and the malloc/free implementations SDL.dll was linked against. Cheers, Daniel Am 24.04.2014 04:13, schrieb gejiaxu:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|