XNA Creators Club Online
Page 1 of 1 (11 items)
Sort Posts: Previous Next

Cue finalizer crashes in native code on game quit

Last post 08-20-2008 1:37 PM by Zilla. 10 replies.
  • 04-01-2008 6:30 PM

    Cue finalizer crashes in native code on game quit

    Ever since I added sound to my game, it occasionally crashes with an access violation when I quit it, deep inside some native code. This is most common when quitting with Alt-F4, but sometimes happens when doing a "clean" quit as well (back out of game/menu using the controller).

    The stack trace of the crash is:

    at Microsoft.Xna.Framework.Audio.UnsafeNativeMethods.Cue.GetStatus(IntPtr pCue)
    at Microsoft.Xna.Framework.Audio.Cue.get_IsPlaying()
    at Microsoft.Xna.Framework.Audio.Cue.Finalize()


    I have finalizers in my game that makes sure that all Cues are properly quit, but the collection and execution order of finalizers is not defined, so that's not a robust mechanism for the termination case. However, I think that the whole point of a managed API should be that it couldn't crash in native code, so I believe there's a bug somewhere in the XACT implementation for XNA.

    Is this known? Should I file it on Connect? Is there some way I can debug this on my side?

    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 04-01-2008 8:02 PM In reply to

    Re: Cue finalizer crashes in native code on game quit

    We have one known issue with cue finalizers, which I would guess is the same thing you are hitting here, but if you have a small enough repro case to post on Connect, that would certainly be useful to verify that this really is the same issue.
    XNA Framework Developer - blog - homepage
  • 04-01-2008 8:28 PM In reply to

    Re: Cue finalizer crashes in native code on game quit

    Thanks, Shawn! Will there be a patch, or do we have to wait for 3.0?
    No, my repro case is rather large and complex :-(

    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 04-01-2008 8:33 PM In reply to

    Re: Cue finalizer crashes in native code on game quit

    I fear this will be a 3.0 fix.
    XNA Framework Developer - blog - homepage
  • 04-02-2008 2:18 PM In reply to

    Re: Cue finalizer crashes in native code on game quit

    I fear this will be a 3.0 fix.


    That's unfortunate. (Perhaps if I found a way to turn this AV into a remotely exploitable security hole, it would get fixed sooner ;-)
    Is there a user-level work-around?
    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 04-02-2008 4:09 PM In reply to

    Re: Cue finalizer crashes in native code on game quit

    jwatte:

    That's unfortunate. (Perhaps if I found a way to turn this AV into a remotely exploitable security hole, it would get fixed sooner ;-)


    <grin>

    jwatte:

    Is there a user-level work-around?


    I think (but am not absolutely confident) the root problem is a race condition to do with cues getting finalized while they are still playing. If you manually hold on to your cue references and only let these be collected after you are sure they have stopped, I think that will avoid the issue.

    I haven't actually implemented the fix for this yet, though, so I might be misunderstanding the details of what exactly causes it. It boils down to something that ought to be locked, but is not, but I'm not 100% solid on how to workaround that.
    XNA Framework Developer - blog - homepage
  • 08-18-2008 11:17 AM In reply to

    Re: Cue finalizer crashes in native code on game quit

    I get the same error when the game is running.

    The Windows version of my game works fine. The exception only occurs in the XBox version.

  • 08-18-2008 6:16 PM In reply to

    Re: Cue finalizer crashes in native code on game quit

    My work-around, so far, is to never unload a wavebank or sound bank. I also hold on to cues in an internal list as soon as I've played them, and check that list for IsStopped, and don't release the cue from the list until it's actually stopped. That seems to fix most of the problems, but it's annoying to have to check that list each time through Game.Update().
    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 08-18-2008 8:18 PM In reply to

    Re: Cue finalizer crashes in native code on game quit

    Thank you for your advice.

    This seems like a major problem... Are we the only ones with these exceptions?


  • 08-19-2008 8:41 AM In reply to

    Re: Cue finalizer crashes in native code on game quit


    jwatte:
    My work-around, so far, is to never unload a wavebank or sound bank. I also hold on to cues in an internal list as soon as I've played them, and check that list for IsStopped, and don't release the cue from the list until it's actually stopped. That seems to fix most of the problems, but it's annoying to have to check that list each time through Game.Update().

     

    Hi, Jon

    I was playing around with your suggestions but didn't succeed...

    Can you give me some code examples of your work-around and some more detailed information of your solution?

     

    Thank you in adv! Zilla

  • 08-20-2008 1:37 PM In reply to

    Re: Cue finalizer crashes in native code on game quit

    I did some human garbage collection in XACT because I realised that my code "lost" the sound banks when I had more than one or two open:

    I deleted all the unused wave files, banks and cues. Then I reorganised my XACT project and the code and threw everything into two sound and two wave banks (background music and sound effects).

    It seems that this solved my problem because the game doesn't crash anymore :-)


Page 1 of 1 (11 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG