like the others reporting in this forum, I’ve suffered the error (crash) when calling FMOD::System::release().
It always failed at the same location. With your latest dev build, I’ve been able to trace with more details the location of the problem (thanks to your debug libs):
in this function, there are a number of calls to (in order):
then a series of tests on variables rooloffscale, distancescale, dopplerscale
then erase the struct dsListenerParams
then a call to a function (virtual function?) that leads to an error message if failed:
"IDirectSoundListener::SetAllParameters returned errcode %08X"
then call FMOD::ChannelPool::getNumChannels
then call FMOD::ChannelPool::getChannel (in a loop)
right after the loop that call getChannel above, there is a call to a function (in the debugger, this+0x244 seems to be a pointer to a class, which seems to have a vTbl and the function calls this vTbl+0x44). The vTbl seems to be pointing to 0! maybe an error (a class without a virtual destructor somewhere)??
So the code fails at this exact location everytime!
with fmodexD.dll, this is happening at 006C8F97 (DLL base listed at 006C0000 in the debugger).
Hope this helps!
- CptLucky asked 12 years ago
My problem may be different from CptLucky’s of course, but I’m still getting the same problem with v35 i.e. crashes if I don’t do the sleep before calling release. It seems to be only when I’ve triggered music for my jukebox that does it though, and they come from Stream From Disk wave banks (can have a maximum of 2 loaded at any time, but only 1 playing).
When I used the debug output the last time to see if that helped, the last entries just say
FMOD: SystemI::close : Free software output.
FMOD: SystemI::close : Free emulated output.
FMOD: SystemI::close : Free channel pool.
FMOD: SystemI::close : Remove miscllaneous DSP stuff.
FMOD: SystemI::close : done.
FMOD: EventSystemI::release : released.
So no real help there (for me anyway).
I’ve futher made a test: I’ve disabled any call to FMOD::update. The application now crashes in another code point when calling ->release(). The call stack is the same as the other message I’ve posted above (well, on page 1 of the thread). It now crashes a little earlier but always in the same function of your code. Here is the disassembly, the EIP is stopped at 0x00708EF1 mov ecx, dword ptr [eax] with eax = 0x02C97640 (which ressemble a memory allocated in the heap).
0708D2D mov eax,dword ptr [esp+4]
00708D31 test eax,eax
00708D33 jne FMOD::OutputDSound::getHandle+0Dh (708D3Ah)
00708D35 push 24h
00708D37 pop eax
00708D38 jmp FMOD::OutputDSound::getHandle+17h (708D44h)
00708D3A mov ecx,dword ptr [ecx+240h]
00708D40 mov dword ptr [eax],ecx
00708D42 xor eax,eax
00708D44 ret 4
00708D47 push ebp
00708D48 mov ebp,esp
00708D4A sub esp,8Ch
00708D52 push ebx
00708D53 push esi
00708D54 fstp dword ptr [ebp-44h]
00708D59 mov esi,ecx
00708D5B xor ebx,ebx
00708D5D fstp dword ptr [ebp-40h]
00708D62 cmp dword ptr [esi+244h],ebx
00708D68 push edi
00708D69 fstp dword ptr [ebp-3Ch]
00708D6E fstp dword ptr [vel]
00708D73 fstp dword ptr [ebp-34h]
00708D78 fstp dword ptr [ebp-30h]
00708D7D fstp dword ptr [front]
00708D82 fstp dword ptr [ebp-1Ch]
00708D87 fstp dword ptr [ebp-18h]
00708D8C fstp dword ptr [top]
00708D91 fstp dword ptr [ebp-28h]
00708D96 fstp dword ptr [ebp-24h]
00708D99 je FMOD::OutputDSound::update+276h (708FBDh)
00708D9F mov ecx,dword ptr [esi+34h]
00708DA2 lea eax,[numlisteners]
00708DA5 push eax
00708DA6 call FMOD::SystemI::get3DNumListeners (766C89h)
00708DAB cmp eax,ebx
00708DAD jne FMOD::OutputDSound::update+278h (708FBFh)
00708DB3 cmp dword ptr [numlisteners],1
00708DB7 jne FMOD::OutputDSound::update+93h (708DDAh)
00708DB9 lea eax,[top]
00708DBC mov ecx,dword ptr [esi+34h]
00708DBF push eax
00708DC0 lea eax,[front]
00708DC3 push eax
00708DC4 lea eax,[vel]
00708DC7 push eax
00708DC8 lea eax,[pos]
00708DCB push eax
00708DCC push ebx
00708DCD call FMOD::SystemI::get3DListenerAttributes (766F05h)
00708DD2 cmp eax,ebx
00708DD4 jne FMOD::OutputDSound::update+278h (708FBFh)
00708DDA lea eax,[rolloffscale]
00708DDD mov ecx,dword ptr [esi+34h]
00708DE0 push eax
00708DE1 lea eax,[distancescale]
00708DE4 push eax
00708DE5 lea eax,[dopplerscale]
00708DE8 push eax
00708DE9 call FMOD::SystemI::get3DSettings (766C36h)
00708DEE cmp eax,ebx
00708DF0 jne FMOD::OutputDSound::update+278h (708FBFh)
00708DF6 fld dword ptr [dopplerscale]
00708DF9 fcomp dword ptr [esi+27Ch]
00708DFF fnstsw ax
00708E01 test ah,44h
00708E04 jp FMOD::OutputDSound::update+0F6h (708E3Dh)
00708E06 fld dword ptr [distancescale]
00708E09 fcomp dword ptr [esi+280h]
00708E0F fnstsw ax
00708E11 test ah,44h
00708E14 jp FMOD::OutputDSound::update+0F6h (708E3Dh)
00708E16 fld dword ptr [rolloffscale]
00708E19 fcomp dword ptr [esi+284h]
00708E1F fnstsw ax
00708E21 test ah,44h
00708E24 jp FMOD::OutputDSound::update+0F6h (708E3Dh)
00708E26 mov eax,dword ptr [esi+34h]
00708E29 cmp byte ptr [eax+9E8h],bl
00708E2F jne FMOD::OutputDSound::update+0F6h (708E3Dh)
00708E31 cmp byte ptr [eax+9E9h],bl
00708E37 je FMOD::OutputDSound::update+23Ch (708F83h)
00708E3D push 40h
00708E3F lea eax,[dsListenerParams]
00708E45 pop edi
00708E46 push edi
00708E47 push ebx
00708E48 push eax
00708E49 call memset (782A5Ch)
00708E4E mov eax,dword ptr [dopplerscale]
00708E51 add esp,0Ch
00708E56 mov dword ptr [ebp-50h],eax
00708E59 mov eax,dword ptr [rolloffscale]
00708E5C fdiv dword ptr [distancescale]
00708E5F mov dword ptr [ebp-54h],eax
00708E62 mov eax,dword ptr [front]
00708E65 mov dword ptr [ebp-70h],eax
00708E68 mov eax,dword ptr [ebp-1Ch]
00708E6B mov dword ptr [ebp-6Ch],eax
00708E6E mov eax,dword ptr [ebp-18h]
00708E71 mov dword ptr [ebp-68h],eax
00708E74 mov eax,dword ptr [top]
00708E77 mov dword ptr [ebp-64h],eax
00708E7A mov eax,dword ptr [ebp-28h]
00708E7D mov dword ptr [ebp-60h],eax
00708E80 mov eax,dword ptr [ebp-24h]
00708E83 mov dword ptr [ebp-5Ch],eax
00708E86 mov eax,dword ptr [pos]
00708E89 mov dword ptr [ebp-88h],eax
00708E8F mov eax,dword ptr [ebp-40h]
00708E92 mov dword ptr [ebp-84h],eax
00708E98 mov eax,dword ptr [ebp-3Ch]
00708E9B mov dword ptr [ebp-80h],eax
00708E9E mov eax,dword ptr [vel]
00708EA1 mov dword ptr [ebp-7Ch],eax
00708EA4 mov eax,dword ptr [ebp-34h]
00708EA7 mov dword ptr [ebp-78h],eax
00708EAA mov eax,dword ptr [ebp-30h]
00708EAD mov dword ptr [ebp-74h],eax
00708EB0 mov eax,dword ptr [esi+34h]
00708EB3 mov dword ptr [dsListenerParams],edi
00708EB9 fstp dword ptr [ebp-58h]
00708EBC test byte ptr [eax+1Ch],2
00708EC0 je FMOD::OutputDSound::update+19Bh (708EE2h)
00708EC2 fld dword ptr [ebp-18h]
00708EC7 fstp dword ptr [ebp-68h]
00708ECA fld dword ptr [ebp-24h]
00708ECF fstp dword ptr [ebp-5Ch]
00708ED2 fld dword ptr [ebp-3Ch]
00708ED7 fstp dword ptr [ebp-80h]
00708EDA fld dword ptr [ebp-30h]
00708EDF fstp dword ptr [ebp-74h]
00708EE2 mov eax,dword ptr [esi+244h]
00708EE8 lea edx,[dsListenerParams]
00708EEE push 1
00708EF0 push edx
00708EF1 mov ecx,dword ptr [eax] ***** <—- CRASHES HERE *****
00708EF3 push eax
00708EF4 call dword ptr [ecx+28h]
00708EF7 cmp eax,ebx
00708EF9 mov dword ptr [hr],eax
00708EFC je FMOD::OutputDSound::update+1CCh (708F13h)
00708EFE push eax
00708EFF push offset string "IDirectSoundListener::SetAllPara"... (790F2Ch)
00708F04 push offset string "OutputDSound::update" (790F14h)
00708F09 push 592h
00708F0E jmp FMOD::OutputDSound::update+25Eh (708FA5h)
[quote:yoyquus8]it is unfortunate we don’t have new report from Billp who’s experiencing the same issue[/quote:yoyquus8]
Apologies… I tried to update to a newer version, it didn’t "just work" so there was a delay, which was just enough time for a "high priority interrupt" to drag me to another project 😡
Side note for one second… The "didn’t just work" was that Eventsystem::getGroup returns an "Invalid Parameter" with the newer versions, and it used to just work. Now that I’m back into this, I found that EventSystem::load has changed and has a 3rd argument, the EventProject pointer.
If I use Event[b:yoyquus8]Project[/b:yoyquus8]::getGroup, my code is back to operational.
OK, let me first admit that I haven’t looked through the forum for an answer, but let me just ask: Does EventProject now [i:yoyquus8]supercede [/i:yoyquus8] EventSystem::getGroup()? Or should BOTH still work?
I am now using 4.04.51
Back to the DLL issue…
[quote:yoyquus8]It turns out after experimenting for a month with this that the root of the issue is this: when FMOD is used (init/loop/release) from a DLL code, which DLL is used by an application .exe, then, it exhibit this crashing issue. [/quote:yoyquus8]
I am just now back to getting my code working under 4.04.51, but I noted that the very first run of this code as a DLL failed in the same place… Sound::release().
I am using VC++ Express, FWIW. The non-DLL version of the code runs fine (basically my previous report, all over again), and the DLL version runs FINE, but just is not happy with release().
I will experiment some more and report any findings.
does anyone have a simple project that reproduces this issue? When we do this with our tests there are no crashes, so there is something you guys are doing different to us, though i’m trying everything.
edit: i may have reproduced it i’ll keep you posted.
now if I call again FMOD::update(), it still crash of course, but back at the same location as initialy posted, right before the call to direct sound CommitDeferredSettings
I’ve forgotten to add: the windows message I get is:
Unhandled exception at 0x00708f8a (fmodex.dll) in myapplication.exe: 0xC0000005: Access violation reading location 0x02b37640.
I’ve no doubt all is fine for everyone, but it seems I’ve found a code path for at least any FMOD DLL for the past 2 months to lead to a crash ALWAYS at the SAME LOCATION, right before the call to CommitDeferredSettings.
I hope all this information will help you track it down. It seems I use pretty much standard init code?!?
Hope this helps!
On your side note, with the addition of EventProject, EventSystem::getGroup paths now need to include their EventProject name as well e.g.
Same goes for EventSystem::getEventGroup.
our error reportting system shows a crash like this, too. I haven’t been able to locate where fmod crashes in these situations and we are not able to reproduce it on our developing and testing machines as well. It’s just some sheldom effect that occours on systems of our users. The only thing I know is that we got no such reports from Linux and Mac users only on Windows.
- slajar answered 12 years ago
Yeah, Brett that appears to have fixed the problem I was having. I had a way I could reproduce the crash, and it didn’t happen once in the 10 times I tried it with v37.
Sorry I couldn’t have been more help with an example project, but it would have been very difficult to extract something meaningful for you for this one.
Thanks again Brett, much appreciated, and great work!
it is still crashing with .37 and it looks like it is the same error. It will be hard to provide a "sample/test" project though as our soundmanager class is tied up with many other things in our project.
Is there any "trace enabled" "debug" version I could try for you? from the "trace" I’ve done in the debugger, it should be quite "locatable" in your code: either your code is calling a virtual function for class, which pointer to its vtable in the other class is 0, or, you are calling a pointer that has been set to 0 before. For the later, a simple test of the pointer before calling the function should help trap the issue, in the former I suspect a destructor called too soon somewhere like this:
m_ptr_to_my_class = 0; <—- missing line leaving something not expected.
Hope this helps!
no, not from a different thread, the same thread. I was mentioning "thread" as the update loop of the application is in a thread. BUT, when I don’t call FMOD:Update() at all, so just starting it, and when the application quits closing it with the C++ code above, it crashes as well, in the same function, just at a different location (right in the code block before the other one).
This is all taking place in a code of yours that call "direct sound update" when it closes.
Let me explain the software architecture as it is implemented right now in order to make sure all is correct thread wise for you:
1) application.exe binds to an application.dll
2) application.dll contains the code to create 1 instance of our main class
3) the main class uses 1 instance of our soundclass
4) our sound class init the FMOD (code above) in a function "init" called by our main class when the main class is called to init from the DLL which is called to init from the .exe
5) the sound class play sounds, and closes FMOD in its destructor
6) the application tells the DLL to create a thread, and this thread will call an "update" in our main class, that will also call the sound class update which call the FMOD::update(). NB: EVEN WITHOUT calling FMOD update() at all, it crashes on system->release() BUT at a different location
7) instead of asking the DLL to create an update thread, the application can call an update() function in the DLL that directly calls update of the main class that will call update of the sound class that will call update of FMOD. Usually done from a windows timer in the .exe. In this case, FMOD ALSO CRASHES (no additional thread involved)
8 ) the exe can tell the DLL to close, and then the DLL closes the main class which call the sound class to close which call system->release()
I think it is safe to say there is no thread pbm in this architecture, but you certainly have more experience in the matter.
Obviously, again, cannot you add a simple "if (my_variable !=0) before calling the function of your class? because it looks like it is the issue. I don’t have YOUR source code, but does it makes sense when I read the information I have that I assume there is a realchannel class in your code, with virtual functions? it looks like the vfptr table is pointing to "non valid" memory for the code somewhere.
I’m quite stuck. However, maybe I don’t need to call ->release() at all? question: when the .exe call the .DLL to tell it to close, it delete the instance of our main class, and the DLL unloads and the .exe exits. At this stage, I would assume FMOD DLL also unloads from memory and your destructors properly delete all allocated memory? so if I don’t call ->release() at all, there shouldn’t be any memory anyhow nor locked ressources isn’t it?
Just let me know how the best I could help.
The best way you could help is to find out what it is you are doing that makes that crash happen. It sounds like you can reproduce it easily, so there is something inbetween the init and release causing it.
Putting some if statement around a realchannel pointer is -not- a solution when 99% of the time it works. You make it sound like it always does this by simply calling init and release after each other, but this is not the case. So what in between causes it? You should be able to comment out your whole application inbetween the init and release until you find the cause.
[quote:3unmbt2x]like the others reporting in this forum, I’ve suffered the error (crash) when calling FMOD::System::release()[/quote:3unmbt2x]
I’m not sure if this will help or confuse the issue, but here goes.
I’ve been working on & off with a demo I’m doing which loads & plays a couple sounds and does some mic recording. Well-behaved, no crashes.
I was compiling it as a stand-alone WIN console app.
I wanted to call the demo from a larger app, so I added __declspec(dllexport) to my classes and made a DLL out of it.
When exercised from the parent app, it works fine – just like it did with the static compile. Except…
It crashes on Sound->release().
And if I comment that out, it crases on EventSystem->release().
I ran to the forum to see what’s up and came across this thread… this seems related.
If I leave ALL my code intact and just compile it stand-alone, it’s fine. But as a DLL it crashes at the release() points.
I’m using 4.03.30.
I’ve been getting problems when calling release recently too (technically through EventSystem::release, but that calls system::release anyway IIRC). I can get it to crash fairly often with a specific sequence of actions in my code (not really possible to extract an example to send though I’m afraid), although if I do a Sleep(someSmallTime) or such like before the release, it doesn’t crash.
Of course the sleep could be hiding any number of sins, but is it necessary to have a delay between stopping and unloading sounds/events and calling release?
the error is still at the same location, but I have a couple more info to trace! Here is a dump of the debugger. The error is at 00708F8A with the mov eax, dword ptr [esi] with esi in this session beeing 0x02C97640.
00708F39 call FMOD::ChannelPool::getNumChannels (757CEBh)
00708F3E cmp eax,ebx
00708F40 je FMOD::OutputDSound::update+200h (708F47h)
00708F42 jmp FMOD::OutputDSound::update+278h (708FBFh)
00708F44 mov dword ptr [numchannels],ebx
00708F47 xor edi,edi
00708F49 cmp dword ptr [numchannels],ebx
00708F4C jle FMOD::OutputDSound::update+23Ch (708F83h)
00708F4E mov ecx,dword ptr [esi+3Ch]
00708F51 lea eax,[channelreal]
00708F54 push eax
00708F55 push edi
00708F56 call FMOD::ChannelPool::getChannel (757D5Ch)
00708F5B cmp eax,ebx
00708F5D jne FMOD::OutputDSound::update+278h (708FBFh)
00708F5F mov ecx,dword ptr [channelreal]
00708F62 cmp ecx,ebx
00708F64 je FMOD::OutputDSound::update+272h (708FB9h)
00708F66 cmp dword ptr [numlisteners],1
00708F6A jg FMOD::OutputDSound::update+22Dh (708F74h)
00708F6C test word ptr [ecx+46h],420h
00708F72 je FMOD::OutputDSound::update+236h (708F7Dh)
00708F74 mov eax,dword ptr [ecx]
00708F76 call dword ptr [eax+60h]
00708F79 cmp eax,ebx
00708F7B jne FMOD::OutputDSound::update+278h (708FBFh)
00708F7D inc edi
00708F7E cmp edi,dword ptr [numchannels]
00708F81 jl FMOD::OutputDSound::update+207h (708F4Eh)
00708F83 mov esi,dword ptr [esi+244h]
00708F89 push esi
00708F8A mov eax,dword ptr [esi]
00708F8C call dword ptr [eax+44h]
00708F8F test eax,eax
00708F91 je FMOD::OutputDSound::update+276h (708FBDh)
00708F93 push dword ptr [hr]
00708F96 push offset string "IDirectSoundListener::CommitDefe"... (790ED0h)
00708F9B push offset string "OutputDSound::update" (790F14h)
00708FA0 push 5CDh
00708FA5 push offset string "c:\pc\src\sound\fmod4\win32\src\"... (790B88h)
00708FAA push 1
00708FAC call FMOD::Debug (70ED5Eh)
In short, it is in your outputDSound::Update, there is a call to get the number of channels, and then a loop to check each channel and if the channel is "real", then it must do something prior calling IDirectsoundListener::CommitDeferedSettings().
Also interesting, the debuger locals show a "this" points of type FMOD::OutputDSound * const with a value of 0x3F800000 which in fact does not look to be a pointer (it is 1.0f float in IEEE hexa).
Another debugger hint makes me think the issue is with the class "channelreal" wich is has virtual functions, and with a __frptr which cannot be evaluated (so my hinch in my previous post could proove to be the reason of what is happening).
NB: I’m not using 3D sound, just normal sound.
Hope this helps! this is so very well located in the code that I see no reason we can’t solve it once for all!
And the call stack to go to this error is:
FMOD::SystemI::release() Line 3470
FMOD::SystemI::close() Line 5086
FMOD::SystemI::closeEx(unsigned char calledfrominit = 0x00) line 5142
FMOD::SystemI::update() Line 5480
FMOD::OutputDSound::updateCallback(FMOD_OUTPUT_STATE* output=0x003586b0) Line 2441
FMOD::OutputDSound::update() Line 1483 + 0x7 bytes
Hope this helps!
Please login first to submit.