ryzom / ryzomcore

Ryzom Core is the open-source project related to the Ryzom game. This community repository is synchronized with the Ryzom Forge repository, based on the Core branch.
https://wiki.ryzom.dev
GNU Affero General Public License v3.0
333 stars 90 forks source link

Crash in XAudio2 driver while playing #254

Closed ryzom-pipeline closed 8 years ago

ryzom-pipeline commented 8 years ago

Original report by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


It crashed on : if (_SourceVoice) _SourceVoice->SetVolume(_Gain, _OperationSet);

With stacktrace :

    ntdll.dll!00007ff942ed39ae()    
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
    ntdll.dll!00007ff942f5544a()    
>   nel_drv_xaudio2_win_d.dll!NLSOUND::CSourceXAudio2::setGain(float gain)  Line 776 + 0x37 bytes   C++
    ryzom_client_d.exe!NLSOUND::CSimpleSource::updateFinalGain()  Line 338  C++
    ryzom_client_d.exe!NLSOUND::CSourceCommon::setRelativeGain(float gain)  Line 193    C++
    ryzom_client_d.exe!NL3D::CPSSoundInstanceImpl::setSoundParams(float gain, const NLMISC::CVector & pos, const NLMISC::CVector & velocity, float pitch)  Line 77  C++
    ryzom_client_d.exe!NL3D::CPSSound::step(NL3D::TPSProcessPass pass)  Line 175    C++
    ryzom_client_d.exe!NL3D::CPSLocated::step(NL3D::TPSProcessPass pass)  Line 1986 C++
    ryzom_client_d.exe!NL3D::CParticleSystem::step(NL3D::CParticleSystem::TPass pass, float ellapsedTime, NL3D::CParticleSystemShape & shape, NL3D::CParticleSystemModel & model)  Line 716 C++
    ryzom_client_d.exe!NL3D::CParticleSystemModel::doAnimate()  Line 678    C++
    ryzom_client_d.exe!NL3D::CParticleSystemModel::traverseAnimDetail()  Line 610   C++
    ryzom_client_d.exe!NL3D::CAnimDetailTrav::traverse()  Line 88   C++
    ryzom_client_d.exe!NL3D::CScene::renderPart(NL3D::UScene::TRenderPart rp, bool doHrcPass, bool doTrav, bool keepTrav)  Line 634 C++
    ryzom_client_d.exe!NL3D::CSceneUser::renderPart(NL3D::UScene::TRenderPart rp, bool doHrcPass, bool doTrav, bool keepTrav)  Line 529 + 0x39 bytes    C++
    ryzom_client_d.exe!renderMainScenePart(NL3D::UScene::TRenderPart renderPart, bool wantTraversals, bool keepTraversals)  Line 476 + 0x2d bytes   C++
    ryzom_client_d.exe!drawRenderScene(bool wantTraversals, bool keepTraversals)  Line 754  C++
    ryzom_client_d.exe!doRenderScene(bool wantTraversals, bool keepTraversals)  Line 779    C++
    ryzom_client_d.exe!mainLoop()  Line 1732    C++
    ryzom_client_d.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, char * cmdline, HINSTANCE__ * __formal)  Line 626 + 0x5 bytes   C++
    ryzom_client_d.exe!__tmainCRTStartup()  Line 547 + 0x42 bytes   C
    ryzom_client_d.exe!WinMainCRTStartup()  Line 371    C
    kernel32.dll!00007ff940fb2d92()     
    ntdll.dll!00007ff942ec9f64()    

And current values were :

        _Gain   1.0000000   float
        _OperationSet   65562   unsigned int
+       _SourceVoice    0x000000000e11ebe0  IXAudio2SourceVoice *
        gain    1.0000000   float
-       this    0x000000000bf415e0 {_SoundDriver=0x000000000c215cd0 _StaticBuffer=0x000000001036b380 _SourceVoice=0x000000000e11ebe0 ...}   NLSOUND::CSourceXAudio2 * const
+       NLSOUND::ISource    {...}   NLSOUND::ISource
+       _SoundDriver    0x000000000c215cd0 {_XAudio2=0x000000000e0a0090 _MasteringVoice=0x000000000cb54f60 _SoundDriverOk=true ...} NLSOUND::CSoundDriverXAudio2 *
+       _StaticBuffer   0x000000001036b380 {_SoundDriver=0x000000000c215cd0 _DataAligned=0x00000000105dd520 "…" _DataPtr=0x00000000105dd520 "…" ...}    NLSOUND::CBufferXAudio2 *
-       _SourceVoice    0x000000000e11ebe0  IXAudio2SourceVoice *
-       IXAudio2Voice   {...}   IXAudio2Voice
-       __vfptr 0x00007ff932b01c10  *
        [0] CXX0030: Error: expression cannot be evaluated  
        [1] CXX0030: Error: expression cannot be evaluated  
        [2] CXX0030: Error: expression cannot be evaluated  
        [3] CXX0030: Error: expression cannot be evaluated  
        [4] CXX0030: Error: expression cannot be evaluated  
        [5] CXX0030: Error: expression cannot be evaluated  
        [6] CXX0030: Error: expression cannot be evaluated  
        [7] CXX0030: Error: expression cannot be evaluated  
        [8] CXX0030: Error: expression cannot be evaluated  
        [9] CXX0030: Error: expression cannot be evaluated  
        [10]    CXX0030: Error: expression cannot be evaluated  
        [11]    CXX0030: Error: expression cannot be evaluated  
        [12]    CXX0030: Error: expression cannot be evaluated  
        [13]    CXX0030: Error: expression cannot be evaluated  
        [14]    CXX0030: Error: expression cannot be evaluated  
        [15]    CXX0030: Error: expression cannot be evaluated  
        [16]    CXX0030: Error: expression cannot be evaluated  
        [17]    CXX0030: Error: expression cannot be evaluated  
        [18]    CXX0030: Error: expression cannot be evaluated  
+       _AdpcmUtility   0x0000000000000000 {_SourceVoice=??? _SourceData=??? _SourceSize=??? ...}   NLSOUND::CAdpcmXAudio2 *
        _OperationSet   65562   unsigned int
        _Format FormatPcm   NLSOUND::IBuffer::TBufferFormat
        _Channels   1 ''   unsigned char
        _BitsPerSample  16 ''  unsigned char
        _Frequency  16000   unsigned int
        _PlayStart  20690697    __int64
        _BufferStreaming    false   bool
        _Doppler    1.0000000   float
+       _Emitter    {pCone=0x0000000000000000 OrientFront={...} OrientTop={...} ...}    X3DAUDIO_EMITTER
+       _Cone   {InnerAngle=6.2831855 OuterAngle=6.2831855 InnerVolume=1.0000000 ...}   X3DAUDIO_CONE
        _MinDistance    2.0000000   float
        _MaxDistance    10.000000   float
+       _Pos    {x=19502.760 y=-26189.803 z=4.0942278 } NLMISC::CVector
        _Relative   false   bool
        _Alpha  1.0000000000000000  double
+       _DirectDryVoice 0x000000000cb586f0  IXAudio2Voice *
+       _DirectFilterVoice  0x000000000cb58818  IXAudio2Voice *
+       _EffectDryVoice 0x0000000000000000  IXAudio2Voice *
+       _EffectFilterVoice  0x0000000000000000  IXAudio2Voice *
        _DirectDryEnabled   true    bool
        _DirectFilterEnabled    false   bool
        _EffectDryEnabled   false   bool
        _EffectFilterEnabled    false   bool
        _DirectGain 1.0000000   float
        _EffectGain 1.0000000   float
        _DirectFilterPassGain   1.0000000   float
        _EffectFilterPassGain   1.0000000   float
        _DirectFilterLowFrequency   250.00000   float
        _DirectFilterHighFrequency  5000.0000   float
        _EffectFilterLowFrequency   250.00000   float
        _EffectFilterHighFrequency  5000.0000   float
+       _DirectFilter   {Type=LowPassFilter Frequency=1.0000000 OneOverQ=1.0000000 }    XAUDIO2_FILTER_PARAMETERS
+       _EffectFilter   {Type=LowPassFilter Frequency=1.0000000 OneOverQ=1.0000000 }    XAUDIO2_FILTER_PARAMETERS
        _IsPlaying  true    bool
        _IsPaused   false   bool
        _IsLooping  true    bool
        _Pitch  1.0000000   float
        _Gain   1.0000000   float

And _SourceVoice's __vfptr seems invalid :p

I joined my whole client.log for this session.

ryzom-pipeline commented 8 years ago

Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


Weird.

ryzom-pipeline commented 8 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


Yep, I agree :( I'm currently using OpenAL driver and I have no crash related to it at the moment.

ryzom-pipeline commented 8 years ago

Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


Does this happen often or not?

ryzom-pipeline commented 8 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


I think I can reproduce it everytime if I play really more than 30 minutes (travel on a mektoub in my case).

Btw another player got this assert :

2015/11/07 21:03:20 AST 1f38 ryzom_client_r.exe source_xaudio2.cpp 281 NLSOUND::CSourceXAudio2::submitBuffer : "ibuffer->getFormat() == _Format && ibuffer->getChannels() == _Channels && ibuffer->getBitsPerSample() == _BitsPerSample"
ryzom-pipeline commented 8 years ago

Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


Add some extra checks, ref #254

ryzom-pipeline commented 8 years ago

Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


Try with these changes

ryzom-pipeline commented 8 years ago

Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


This seems like a good idea as well, ref #254

ryzom-pipeline commented 8 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


Thanks a lot, I'll try :)

ryzom-pipeline commented 8 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


Ah, I noticed something with Windows 10, but if I use XAUDIO2_DEBUG_ENGINE flag in Debug, I got :

2015/11/15 13:49:31 DBG 18c0 ryzom_client_d.exe audio_mixer_user.cpp 368 NLSOUND::CAudioMixerUser::initDriver : AM: Init Driver 'XAudio2' ('xaudio2')...
2015/11/15 13:49:31 DBG 18c0 ryzom_client_d.exe dynloadlib.cpp 207 NLMISC::CLibrary::loadLibrary : Loading dynamic library 'nel_drv_xaudio2_win_d.dll'
2015/11/15 13:49:31 WRN 18c0 ryzom_client_d.exe sound_driver_xaudio2.cpp 152 NLSOUND::CSoundDriverXAudio2::CSoundDriverXAudio2 : XA2: Creating CSoundDriverXAudio2
2015/11/15 13:49:31 INF 18c0 ryzom_client_d.exe sound_driver_xaudio2.cpp 212 NLSOUND::CSoundDriverXAudio2::release : XA2: Releasing CSoundDriverXAudio2
2015/11/15 13:49:31 INF 18c0 ryzom_client_d.exe common.cpp 621 NLMISC::Exception::Exception : Exception will be launched: XA2: XAudio2 failed to initialize. Please install the latest version of the DirectX End-User Runtimes.
2015/11/15 13:49:31 WRN 18c0 ryzom_client_d.exe audio_mixer_user.cpp 391 NLSOUND::CAudioMixerUser::initDriver : XA2: XAudio2 failed to initialize. Please install the latest version of the DirectX End-User Runtimes.
2015/11/15 13:49:31 WRN 18c0 ryzom_client_d.exe init.cpp 1422 postlogInit : init : Error when creating 'SoundMngr' : XA2: XAudio2 failed to initialize. Please install the latest version of the DirectX End-User Runtimes.

But if I remove the flag, it works :)

ryzom-pipeline commented 8 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


I played some minutes, it didn't crash in XAudio2 driver this time, but in OpenGL one :p I kept the crashlog and I'll retry to see if your changes fixed the crash :)

ryzom-pipeline commented 8 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


I played again some times and it didn't crash, I even listened songs in music player to force the use of driver :)

I'll continue to play with it but it's possible you fixed the crashes :) Great job !

I'll compile new clients for Steam with your changes so other beta-testers will be able to check that too :)

ryzom-pipeline commented 8 years ago

Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


Can you give a new client.log with the changes? I want to confirm something.

ryzom-pipeline commented 8 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


New log :)

ryzom-pipeline commented 8 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


Here is the new client.log :)

ryzom-pipeline commented 8 years ago

Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


Please confirm that it's fixed, thanks. :)

ryzom-pipeline commented 8 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


I just recompiled the whole client and I'll play in Debug :)

Btw, last time I played in Debug, assert weren't catched by VC++ because to a wrong boolean value :(

ryzom-pipeline commented 8 years ago

Original comment by Cédric Ochs (Bitbucket: [Cédric OCHS](https://bitbucket.org/Cédric OCHS), ).


I played a lot this afternoon (with XAudio2 driver) in Debug and it didn't crash :)

ryzom-pipeline commented 8 years ago

Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


Ok.