FMOD 4.26.0 crashes in FMOD::MemPool::alloc when FMOD_System_Create is called from within an Objective-C class’s +load member (which is a special method of an Objective-C class or category that is executed on startup.)
0 Furcadia 0x0017cbe7 FMOD::MemPool::alloc(int, char const*, int, unsigned int, bool) + 31
1 Furcadia 0x0017d2c3 FMOD::MemPool::calloc(int, char const*, int, unsigned int) + 53
2 Furcadia 0x00117a3b FMOD_System_Create + 87
4 Furcadia 0x000e083a +[GTAudioManager load] + 11 (GTAudioManager.m:75)
This behaviour did not exist in 4.24.08 or earlier.
- Jonathan Grynspan asked 9 years ago
Are you sure this error is a new introduction? I can’t see any code that has changed with that code path. To me it looks like this Objective-C function is executing before the C++ globals have been created, and if that is true I don’t think anything can be done about it.
Why do you need to init FMOD inside this load member? Is it not possible to initialize in a regular function as part of your app startup procedure?
The error did not occur in 4.24.08, which was the last version we were using.
We’re using FMOD in +load because we’re trying to determine if another application is playing audio as soon as possible after launch. We can defer the call until a later time if necessary, but sooner is better if possible.
GCC is documented to allow C++ and C calls in the +load method; it is only supposed to be Objective-C code that is off limits there.
- Jonathan Grynspan answered 9 years ago
I just made a quick test case and ran it through the debugger, when using the +load function execution occurs before our globals have initialized, hence the memory allocator falls over. It is possible that the initialization order is undefined, that’s why it worked in the past.
I recommend you initialize FMOD at a later date when the state is known.
Please login first to submit.