sanette / bogue

GUI library for ocaml based on SDL2
http://sanette.github.io/bogue/Principles.html
Other
189 stars 15 forks source link

Tracking Issue: Remaining Windows problems from `boguex` #32

Open jonahbeckford opened 8 months ago

jonahbeckford commented 8 months ago

This is a FYI. I won't be getting to these soon but I wanted to track them somewhere.

Setup:

sanette commented 8 months ago

I'd be glad to have more info about the segfaults. In my experience, memory leaks could happen when you close SDL Video driver and reopen it again in the same session.( this happens when you run several examples in one boguex run. ) I'm not sure which one of SDL, tsdl, or Bogue should be incrminated. But I don't think I ever got such a problem with a single SDL init

jonahbeckford commented 8 months ago

Playing sound

Windows gets stuck in this stack trace for thread 0x4594 0x0 boguex+0x18ea48 (00000000 008aea48):

[0x0]   ntdll!NtWaitForSingleObject+0x14   0x9b397ff658   0x7fff5e22497e   
[0x1]   KERNELBASE!WaitForSingleObjectEx+0x8e   0x9b397ff660   0x7fff25632961   
[0x2]   SDL2d!SDL_SYS_WaitThread+0x21 [Y:\source\dksdk-coder\vcpkg\buildtrees\sdl2\src\ase-2.30.0-3ceee4a14f.clean\src\thread\windows\SDL_systhread.c @ 194]   0x9b397ff700   0x7fff254fe4f1   
[0x3]   SDL2d!SDL_WaitThread_REAL+0x21 [Y:\source\dksdk-coder\vcpkg\buildtrees\sdl2\src\ase-2.30.0-3ceee4a14f.clean\src\thread\SDL_thread.c @ 443]   0x9b397ff730   0x7fff253efe38   
[0x4]   SDL2d!close_audio_device+0x88 [Y:\source\dksdk-coder\vcpkg\buildtrees\sdl2\src\ase-2.30.0-3ceee4a14f.clean\src\audio\SDL_audio.c @ 1208]   0x9b397ff760   0x7fff253ede4a   
[0x5]   SDL2d!SDL_CloseAudioDevice_REAL+0x1a [Y:\source\dksdk-coder\vcpkg\buildtrees\sdl2\src\ase-2.30.0-3ceee4a14f.clean\src\audio\SDL_audio.c @ 1678]   0x9b397ff7a0   0x7fff2540f933   
[0x6]   SDL2d!SDL_CloseAudioDevice+0x13 [Y:\source\dksdk-coder\vcpkg\buildtrees\sdl2\src\ase-2.30.0-3ceee4a14f.clean\src\dynapi\SDL_dynapi_procs.h @ 131]   0x9b397ff7d0   0x7fff4e31c8e1   
[0x7]   ffi_8!ffi_call_win64+0x41   0x9b397ff800   0x7fff4e31c3f4   
[0x8]   ffi_8!ffi_call_int+0x304 [Y:\source\dksdk-coder\vcpkg\buildtrees\libffi\src\libffi-3-b5bf0e8df1.clean\src\x86\ffiw64.c @ 197]   0x9b397ff830   0x7fff4e31bf9b   
[0x9]   ffi_8!ffi_call+0x3b [Y:\source\dksdk-coder\vcpkg\buildtrees\libffi\src\libffi-3-b5bf0e8df1.clean\src\x86\ffiw64.c @ 206]   0x9b397ff8c0   0x86b4ef   
[0xa]   boguex + 0x14b4ef!boguex+0x14b4ef   0x9b397ff900   0x881488   
[0xb]   boguex + 0x161488!boguex+0x161488   0x9b397ffa90   0x9688a0   
[0xc]   boguex + 0x2488a0!boguex+0x2488a0   0x9b397ffa98   0x1b163782c50   
...
[0x55]   boguex + 0x1a7968!boguex+0x1a7968   0x9b397ffce0   0x8c7c78   
[0x56]   boguex + 0x1a7c78!boguex+0x1a7c78   0x9b397ffce8   0x7231c2   
[0x57]   boguex + 0x31c2!boguex+0x31c2   0x9b397ffcf0   0x2   
[0x58]   0x2!+   0x9b397ffcf8   0x881527   
[0x59]   boguex + 0x161527!boguex+0x161527   0x9b397ffd00   0x0   

The source code for SDL2 corresponds to https://github.com/libsdl-org/SDL/tree/release-2.30.0 and the line numbers are quite close (but not exact).

For example, the SDL2d!close_audio_device+0x88 [Y:\source\dksdk-coder\vcpkg\buildtrees\sdl2\src\ase-2.30.0-3ceee4a14f.clean\src\audio\SDL_audio.c @ 1208] is https://github.com/libsdl-org/SDL/blob/859844eae358447be8d66e6da59b6fb3df0ed778/src/audio/SDL_audio.c#L1206

The other relevant threads are 0x915c 0x5 SDL2d!RunThreadViaCreateThread (00007fff 25632a00) SDLAudioP2:

[0x0]   ntdll!NtWaitForAlertByThreadId+0x14   0x9b437ff4c8   0x7fff60b43c03   
[0x1]   ntdll!RtlpWaitOnCriticalSection+0x1e3   0x9b437ff4d0   0x7fff60b318e4   
[0x2]   ntdll!RtlpEnterCriticalSectionContended+0x204   0x9b437ff5e0   0x7fff60b316d2   
[0x3]   ntdll!RtlEnterCriticalSection+0x42   0x9b437ff660   0x86d41d   
[0x4]   boguex + 0x14d41d!boguex+0x14d41d   0x9b437ff690   0x7fff60b8bada   
[0x5]   ntdll!ImageTlsCallbackCaller+0x1a   0x9b437ff6c0   0x7fff60b3869f   
[0x6]   ntdll!LdrpCallInitRoutine+0x6b   0x9b437ff6f0   0x7fff60b39329   
[0x7]   ntdll!LdrpCallTlsInitializers+0xc5   0x9b437ff760   0x7fff60b38f68   
[0x8]   ntdll!LdrShutdownThread+0x1f8   0x9b437ff7d0   0x7fff60b6aace   
[0x9]   ntdll!RtlExitUserThread+0x3e   0x9b437ff8d0   0x7fff5f162586   
[0xa]   KERNEL32!BaseThreadInitThunk+0x26   0x9b437ff910   0x7fff60b6aa58   
[0xb]   ntdll!RtlUserThreadStart+0x28   0x9b437ff940   0x0   

and 0xede4 0x6 boguex+0x14c400 (000000000086c400)`:

[0x0]   ntdll!NtDelayExecution+0x14   0x9b457ffa98   0x7fff60b651b3   
[0x1]   ntdll!RtlDelayExecution+0x43   0x9b457ffaa0   0x7fff5e2354fd   
[0x2]   KERNELBASE!SleepEx+0x7d   0x9b457ffad0   0x86c41b   
[0x3]   boguex + 0x14c41b!boguex+0x14c41b   0x9b457ffb50   0x7fff5f16257d   
[0x4]   KERNEL32!BaseThreadInitThunk+0x1d   0x9b457ffb80   0x7fff60b6aa58   
[0x5]   ntdll!RtlUserThreadStart+0x28   0x9b457ffbb0   0x0   

Any ideas?

sanette commented 8 months ago

did you try the latest version where I removed the audio lock? https://github.com/sanette/bogue/commit/b307b736609e19ba6fee688cfed761ce9425a2e1

jonahbeckford commented 8 months ago

did you try the latest version where I removed the audio lock?

Yes. The exact branch I am using is https://github.com/jonahbeckford/bogue/commits/dkcoder/