hi, I'm currently hunting down a frequent crash related to dsound.dll.

  while I was trying to play Baldur's Gate with wine, I have discovered
that wine crashed quite often due to some problem with dsound buffers.

  I have included dumps from wine-dbg from three different crashes. In
the third case, I was running wine with -debugmsg +trace,+dsound but I
have included only the last few lines, plus a dump of dsound variables
as seen in the debugger. this last crash has happened while BG was
changing the scene.

  I have looked at wine's dsound_main.c source, and from this as well as
from the previous output I have come to a conclusion: it seems to me
that the application which is using dsound.dll services (currently
Baldur's Gate) is able to release a DSoundBuffer even during
DSOUND_Thread_MixPrimary (and/or DSOUND_MixIn) primary buffer
processing. DSOUND_Thread_MixPrimary is using

  for (i = dsound->nrofbuffers - 1; i >= 0; i--) {

to loop on all registered buffers, but since the dsound->nrofbuffers is
evaluated only at the very same loop start, it fails to recognize that
some of that buffers may have been removed.


  I'm planning to test few different approach to fix this:

1) I can add an EnterCriticalSection/LeaveCriticalSection couple to the
   IDirectSoundImpl_Release/IDirectSoundBuffer_Release functions, but
   this may raise the contemptions between the application and
   dsound.dll;

2) I can force the mail loop in the DSOUND_MixPrimary to re-check the
   list of buffers every time at every step. but how do I should handle
the MixIn one ? 

  I would like to know if someone has already found something like this
and what you think about those solutions...

  I'm going to check them this evening when I will go back to home (if I
will be able to make my new computer work, 'cause I have changed the
order of my hard disks on the controllers, so now I have to tell it to
Linux and I know it will not take this so easy... )

  bye,

    MP.

-- 
Stud. Marco Pietrobono            | Murphy's Law: if something could
v. del Calice, 39 - 00178 ROMA    |     go wrong, it does.
Tel. +39.6.7186329  0339.7410893  | Legge di Murphy: se qualcosa può
http://www.pietrobo.com           |    andar male, lo farà.
------------------------------------------------------------------------
Some men see things as they are and say, why;
I dream things that never were and say, why not. ( George Bernard Shaw )


------------------------ first crash output ----------------------
fixme:ddraw:common_off_screen_CreateSurface using w=640, h=272, bpp=1
fixme:win:DEFWND_DefWinProc Display default popup menu
fixme:dsound:IDirectSoundImpl_SetCooperativeLevel
(0x409229a0,00000414,3):stub
First chance exception: page fault on read access to 0x42352f78 in
32-bit code (0x400c29b6).
Loading new modules symbols:
    mcicda.drv $
Register dump:
 CS:0023 SS:002b DS:002b ES:002b FS:05cf GS:0000
 EIP:400c29b6 ESP:4208fefc EBP:4208ff10 EFLAGS:00010206(  R- 00  I   -
-P1 )
 EAX:408f2880 EBX:400c6184 ECX:408d0000 EDX:00000003
 ESI:42352f78 EDI:43578eb8
Stack dump:
Symbol h_errno is invalid
0x4208fefc (midimap.drv..code+0xeefd20):  400c6184 00000004 400c2dc4
00000004
0x4208ff0c (midimap.drv..code+0xeefd30):  00000003 4208ff20 400c2eab
4052d74c
0x4208ff1c (midimap.drv..code+0xeefd40):  41f80000 4208ff38 403e9cf8
00000000
0x4208ff2c (midimap.drv..code+0xeefd50):  4052d74c 41f80000 40e9a25c
4208fff4
0x4208ff3c (midimap.drv..code+0xeefd60):  403e8ff8 403e8f6c ffffffff
403ef1d8
0x4208ff4c (midimap.drv..code+0xeefd70):  403ef120 4052d74c 41f80000
40e9a25c
0x4208ff5c (midimap.drv..code+0xeefd80):

00b9: sel=05cf base=41f80000 limit=00000fff 32-bit rw-
Backtrace:
=>0 0x400c29b6 (DSOUND_MixPrimary+0x3e [dsound_main.c:2059])
(ebp=4208ff10)
  1 0x400c2eab (DSOUND_thread+0xe7(arg=0x0) [dsound_main.c:2235])
(ebp=4208ff20)
  2 0x403e9cf8 (THREAD_Start+0x54 [thread.c:274]) (ebp=4208ff38)
  3 0x403e8ff8 (SYSDEPS_StartThread+0x8c(teb=0x41f80000)
[sysdeps.c:130]) (ebp=4208fff4)
  4 0x4075f39a (thread_start+0x4 [sysctl.c]) (ebp=00000000)
*** Invalid address 0x00000000 (__finitel)

0x400c29b6 (DSOUND_MixPrimary+0x3e [dsound_main.c:2059]):  movl
0x0(%esi),%eax




------------------------- second crash ---------------------------------
PS: this seems to have a corrupted stack, since the frame 0 seems rather
messed up.

fixme:dsound:IDirectSoundImpl_SetCooperativeLevel
(0x409229a0,00000414,3):stub
First chance exception: page fault on read access to 0x48460000 in
32-bit code (0x48460000).
Loading new modules symbols:
    mcicda.drv $
Register dump:
 CS:0023 SS:002b DS:002b ES:002b FS:05cf GS:0000
 EIP:48460000 ESP:4208fef4 EBP:4208ff10 EFLAGS:00010202(  R- 00  I   - -
1 )
 EAX:48460000 EBX:400c6184 ECX:00000001 EDX:00000007
 ESI:408f2748 EDI:439b9480
Stack dump:
Symbol h_errno is invalid
0x4208fef4 (midimap.drv..code+0xeefd18):  400c29c2 408f2748 400c6184
00000004
0x4208ff04 (midimap.drv..code+0xeefd28):  400c2dc4 00000004 00000007
4208ff20
0x4208ff14 (midimap.drv..code+0xeefd38):  400c2eab 4052d74c 41f80000
4208ff38
0x4208ff24 (midimap.drv..code+0xeefd48):  403e9cf8 00000000 4052d74c
41f80000
0x4208ff34 (midimap.drv..code+0xeefd58):  40e9a25c 4208fff4 403e8ff8
403e8f6c
0x4208ff44 (midimap.drv..code+0xeefd68):  ffffffff 403ef1d8 403ef120
4052d74c
0x4208ff54 (midimap.drv..code+0xeefd78):

00b9: sel=05cf base=41f80000 limit=00000fff 32-bit rw-
Backtrace:
=>0 0x48460000 (mcicda.drv..code+0x63afe34) (ebp=4208ff10)
  1 0x400c2eab (DSOUND_thread+0xe7(arg=0x0) [dsound_main.c:2235])
(ebp=4208ff20)
  2 0x403e9cf8 (THREAD_Start+0x54 [thread.c:274]) (ebp=4208ff38)
  3 0x403e8ff8 (SYSDEPS_StartThread+0x8c(teb=0x41f80000)
[sysdeps.c:130]) (ebp=4208fff4)
  4 0x4075f39a (thread_start+0x4 [sysctl.c]) (ebp=00000000)
*** Invalid address 0x00000000 (__finitel)

0x48460000 (mcicda.drv..code+0x63afe34):  *** Invalid address 0x48460000
(mcicda.drv..code+0x63afe34)





---------------------- third crash ---------------------------
PS. this time I was running wine with -debug -debugmsg +trace,+dsound
I have removed the first 180MB of messages, though... ;-)

trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x423517e8) len = 4
trace:dsound:DSOUND_MixerNorm (0x423517e8, 0x42353366, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x423517e8) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x423517e8) left = 33fb, right = 33fb
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x42354f00) len = 4
trace:dsound:DSOUND_MixerNorm (0x42354f00, 0x42356a7e, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x42354f00) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x42354f00) left = 33fb, right = 33fb
trace:dsound:IDirectSoundImpl_Release (0x409229a0), ref was 10
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x408f2748) len = 4
trace:dsound:DSOUND_MixerNorm (0x408f2748, 0x43315fb0, 0x935a228),
playpos=00004498
trace:dsound:DSOUND_MixerNorm (0x408f2748) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x408f2748) left = 33fb, right = 33fb
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x408f26ac) len = 4
trace:dsound:DSOUND_MixerNorm (0x408f26ac, 0x43311b0a, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x408f26ac) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x408f26ac) left = 33fb, right = 33fb
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x43456b90) len = 4
trace:dsound:DSOUND_MixerNorm (0x43456b90, 0x4345870e, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x43456b90) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x43456b90) left = 33fb, right = 33fb
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x42353374) len = 4
trace:dsound:DSOUND_MixerNorm (0x42353374, 0x42354ef2, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x42353374) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x42353374) left = 33fb, right = 33fb
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x423517e8) len = 4
trace:dsound:DSOUND_MixerNorm (0x423517e8, 0x42353366, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x423517e8) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x423517e8) left = 33fb, right = 33fb
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x42354f00) len = 4
trace:dsound:DSOUND_MixerNorm (0x42354f00, 0x42356a7e, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x42354f00) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x42354f00) left = 33fb, right = 33fb
trace:dsound:IDirectSoundImpl_Release (0x409229a0), ref was 10
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x408f2748) len = 4
trace:dsound:DSOUND_MixerNorm (0x408f2748, 0x43315fb0, 0x935a228),
playpos=00004498
trace:dsound:DSOUND_MixerNorm (0x408f2748) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x408f2748) left = 33fb, right = 33fb
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x408f26ac) len = 4
trace:dsound:DSOUND_MixerNorm (0x408f26ac, 0x43311b0a, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x408f26ac) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x408f26ac) left = 33fb, right = 33fb
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x43456b90) len = 4
trace:dsound:DSOUND_MixerNorm (0x43456b90, 0x4345870e, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x43456b90) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x43456b90) left = 33fb, right = 33fb
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x42353374) len = 4
trace:dsound:DSOUND_MixerNorm (0x42353374, 0x42354ef2, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x42353374) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x42353374) left = 33fb, right = 33fb
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x423517e8) len = 4
trace:dsound:DSOUND_MixerNorm (0x423517e8, 0x42353366, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x423517e8) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x423517e8) left = 33fb, right = 33fb
trace:dsound:DSOUND_MixInBuffer allocating buffer (size = 4)
trace:dsound:DSOUND_MixInBuffer MixInBuffer (0x42354f00) len = 4
trace:dsound:IDirectSoundImpl_Release (0x409229a0), ref was 10
trace:dsound:IDirectSoundImpl_Release (0x409229a0), ref was 9
trace:dsound:IDirectSoundImpl_Release (0x409229a0), ref was 8
trace:dsound:IDirectSoundImpl_Release (0x409229a0), ref was 7
trace:dsound:IDirectSoundImpl_Release (0x409229a0), ref was 6
trace:dsound:IDirectSoundImpl_Release (0x409229a0), ref was 5
trace:dsound:IDirectSoundImpl_Release (0x409229a0), ref was 4
trace:dsound:DirectSoundCreate DirectSoundCreate (0x40e9a65a)
fixme:dsound:IDirectSoundImpl_SetCooperativeLevel
(0x409229a0,00000414,3):stub
trace:dsound:IDirectSoundImpl_CreateSoundBuffer
(0x409229a0,0x41b5e830,0x40e9a65e,(nil))
trace:dsound:IDirectSoundImpl_CreateSoundBuffer (size=20)
trace:dsound:IDirectSoundImpl_CreateSoundBuffer (flags=0x00000011
DSBCAPS_PRIMARYBUFFER DSBCAPS_CTRLALL
trace:dsound:IDirectSoundImpl_CreateSoundBuffer (bufferbytes=0)
trace:dsound:IDirectSoundImpl_CreateSoundBuffer (lpwfxFormat=(nil))
trace:dsound:IDirectSoundImpl_GetCaps (0x409229a0,0x41b5e864)
trace:dsound:IDirectSoundImpl_GetCaps (flags=0x00000000)
trace:dsound:DSOUND_MixerNorm (0x42354f00, 0x42356a7e, 0x935a228),
playpos=00001ae2
trace:dsound:DSOUND_MixerNorm (0x42354f00) Adjusting frequency: 22000 ->
22050
trace:dsound:DSOUND_MixerVol (0x42354f00) left = 33fb, right = 33fb
trace:dsound:IDirectSoundImpl_Release (0x409229a0), ref was 4
First chance exception: page fault on read access to 0x42354f00 in
32-bit code (0x400c29b6).
Loading new modules symbols:
    mcicda.drv $
Register dump:
 CS:0023 SS:002b DS:002b ES:002b FS:05cf GS:0000
 EIP:400c29b6 ESP:4208fefc EBP:4208ff10 EFLAGS:00010206(  R- 00  I   -
-P1 )
 EAX:408f2880 EBX:400c6184 ECX:408d0000 EDX:00000000
 ESI:42354f00 EDI:42354f78
Stack dump:
Symbol h_errno is invalid
0x4208fefc (midimap.drv..code+0xeefd20):  400c6184 00000004 400c2dc4
00000004
0x4208ff0c (midimap.drv..code+0xeefd30):  00000000 4208ff20 400c2eab
4052d74c
0x4208ff1c (midimap.drv..code+0xeefd40):  41f80000 4208ff38 403e9cf8
00000000
0x4208ff2c (midimap.drv..code+0xeefd50):  4052d74c 41f80000 40e9a25c
4208fff4
0x4208ff3c (midimap.drv..code+0xeefd60):  403e8ff8 403e8f6c ffffffff
403ef1d8
0x4208ff4c (midimap.drv..code+0xeefd70):  403ef120 4052d74c 41f80000
40e9a25c
0x4208ff5c (midimap.drv..code+0xeefd80): 

00b9: sel=05cf base=41f80000 limit=00000fff 32-bit rw-
Backtrace:
=>0 0x400c29b6 (DSOUND_MixPrimary+0x3e [dsound_main.c:2059])
(ebp=4208ff10)
  1 0x400c2eab (DSOUND_thread+0xe7(arg=0x0) [dsound_main.c:2235])
(ebp=4208ff20)
  2 0x403e9cf8 (THREAD_Start+0x54 [thread.c:274]) (ebp=4208ff38)
  3 0x403e8ff8 (SYSDEPS_StartThread+0x8c(teb=0x41f80000)
[sysdeps.c:130]) (ebp=4208fff4)
  4 0x4075f39a (thread_start+0x4 [sysctl.c]) (ebp=00000000)
*** Invalid address 0x00000000 (__finitel)

0x400c29b6 (DSOUND_MixPrimary+0x3e [dsound_main.c:2059]):  movl
0x0(%esi),%eax

Wine-dbg>print dsb
0x42354f00
Wine-dbg>print i
0
Wine-dbg>print maxlen
4
Wine-dbg>print dsound
0x409229a0
Wine-dbg>print *dsound
{
 lpVtbl=0x400c6120,
 ref=3,
 priolevel=0,
 nrofbuffers=0,
 buffers=0x408f2880,
 primary=0x40924450,
 listener=0x0000002d,
 wfx=
  {
      wFormatTag=1,
      nChannels=2,
      nSamplesPerSec=22050,
      nAvgBytesPerSec=44100,
      nBlockAlign=2,
      wBitsPerSample=8,
      cbSize=0
  }
}

NdPietrobo: as you can see the dsound buffer has nrofbuffers set to
zero, so they have been removed while DSOUND_Thread was in the loop of
DSOUND_MixPrimary...

Wine-dbg>print *dsound->buffers
0x42354f00
Wine-dbg>print *dsound->primary
{
  lpVtbl=0x400c60c0,
  ref=2,
  wfx=
   {
    wFormatTag=1,
    nChannels=2,
    nSamplesPerSec=22050,
    nAvgBytesPerSec=88200,
    nBlockAlign=4,
    wBitsPerSample=16,
    cbSize=0
   },
  buffer="",
  ds3db=0x00000000,
  playflags=0,
  playing=0,
  playpos=33348,
  writepos=38860,
  buflen=44100,
  nAvgBytesPerSec=0,
  freq=22050,
  freqAdjust=0,
  volume=0,
  pan=0,
  lVolAdjust=32768,
  rVolAdjust=32768,
  parent=0x00000000,
  dsound=0x409229a0,
  dsbd=
   {
    dwSize=20,
    dwFlags=17,
    dwBufferBytes=0,
    dwReserved=22,
    lpwfxFormat=0x409229bc
   },
  notifies=0x00000000,
  nrofnotifies=0,
  lock=
   {
    DebugInfo=0x00000000,
    LockCount=1,
    RecursionCount=1,
    OwningThread=134597816,
    LockSemaphore=460,
    Reserved=137405336
   }
 }

Reply via email to