Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
08123 Graphics Critical (emulator) Always Nov 2, 2021, 09:42 Nov 16, 2022, 02:33
Tester hap View Status Public Platform MAME (Official Binary)
Assigned To Resolution Open OS Windows 10/11 (64-bit)
Status [?] Confirmed Driver
Version 0.237 Fixed in Version Build 64-bit
Fixed in Git Commit Github Pull Request #
Summary 08123: bgfx vulkan sometimes crashes when resizing window
Description Windows 10 here, nvidia GPU.

mame 1942 -video bgfx -bgfx_backend vulkan -window -waitvsync -skip_gameinfo
Grab top edge of the window and resize fast, MAME crashes:

-----------------------------------------------------
Exception at EIP=00007ffe6b03f304 (__cxa_throw_bad_array_new_length+0x1ebeab54): ACCESS VIOLATION
While attempting to read memory at 00000000000000a0
-----------------------------------------------------
RAX=0000000000000000 RBX=000000000b087c18 RCX=000000000b087c18 RDX=0000000007f1f630
RSI=0000000007f1f700 RDI=0000000007f1f630 RBP=0000000007f1fb01 RSP=0000000007f1f5a0
 R8=0000000000000016 R9=000000000872b901 R10=0000000000000000 R11=0000000000000007
R12=0000000000000001 R13=0000000000000000 R14=00000000087c1310 R15=0000000011c6c8f0
-----------------------------------------------------
Stack crawl:
  0000000007f1f5e0: 00007ffe6b03f304 (vkGetInstanceProcAddr+0x39294)
  0000000007f1f690: 00007ffe6b02d973 (vkGetInstanceProcAddr+0x27903)
  0000000007f1f760: 000000014ad99dba (bgfx::vk::BufferVK::update(VkCommandBuffer_T*, unsigned int, unsigned int, void*, bool)+0x008a)
  0000000007f1fe50: 000000014ada68ff (bgfx::vk::RendererContextVK::submit(bgfx::Frame*, bgfx::ClearQuad&, bgfx::TextVideoMemBlitter&)+0x1f5f)
  0000000007f1feb0: 000000014a8e0505 (bgfx::Context::renderFrame(int)+0x00c5)
  0000000007f1fef0: 000000014a8ea4f2 (bgfx::Context::renderThread(bx::Thread*, void*)+0x0022)
  0000000007f1ff20: 000000014ad3b08c (bx::ThreadInternal::threadFunc(void*)+0x002c)
  0000000007f1ff50: 00007ffed8d57034 (BaseThreadInitThunk+0x0014)
  0000000007f1ffd0: 00007ffeda7a2651 (RtlUserThreadStart+0x0021)
Steps To Reproduce
Additional Information
Github Commit
Flags
Regression Version
Affected Sets / Systems
Attached Files
png file icon pongf Screenshot_2021-11-05_00-48-17.png (87,548 bytes) Nov 4, 2021, 13:54 Uploaded by ozfalcon
Mirrored screenshot
ozfalcon
Relationships
There are no relationship linked to this issue.
Notes
12
User avatar
No.19410
hap
Developer
Nov 2, 2021, 09:45
I assume it's a Windows-only issue, someone can try on another OS?
And does it happen on AMD GPUs?
User avatar
No.19412
Robbbert
Senior Tester
Nov 2, 2021, 12:59
edited on: Nov 2, 2021, 13:00
I'm using NVIDIA GeForce GT 710.
Windows 10 latest forced updates. Version 10.0.19042.1288

MAME - latest git.

No crashes.
User avatar
No.19413
hap
Developer
Nov 2, 2021, 13:09
From discord:

crash:
duke (I don't know which GPU)
dirthead (nvidia)
naoki (nvidia)

no crash
naoki (intel)
User avatar
No.19416
sairuk
Tester
Nov 3, 2021, 20:43
Could not replicate this on AMD

No crash
- Win10 Radeon RX580 (fresh win10 install (updated), 237 release binary, latest AMD drivers)
- Ubuntu 20.04 Radeon RX580 (compiled 237 dirty)

Run with:
mame -waitvsync -skip_gameinfo -window -video bgfx -bgfx_backend vulkan -bgfx_debug -bgfx_screen_chains %CHAIN% -rompath %ROMPATH% %ROM%

where CHAIN was both auto and crt-geom-deluxe and ROM was 1942 and pacman

no crash reports should probably be rerun with -bgfx_debug to confirm vulkan backend is in use and mame has not fallen back to d3d which I noted happened on a non vulkan gpu and no crash.
User avatar
No.19417
gspat
Tester
Nov 3, 2021, 22:30
Can confirm crash :
AMD 2400g/Nvidia gtx960/16gb/win10

-bgfx_debug shows using vulkan and gtx960

C:\mame\msys64\src\mame>mame 1942 -video bgfx -bgfx_backend vulkan -bgfx_debug -window -waitvsync -skip_gameinfo

-----------------------------------------------------
Exception at EIP=000000007263e381 (not found): ACCESS VIOLATION
While attempting to read memory at 0000000000000070
-----------------------------------------------------
RAX=0000000000000000 RBX=000001d6b13a1e90 RCX=000001d6a251e418 RDX=0000006cb39ff1c8
RSI=0000006cb39ff1c8 RDI=000001d6a251e418 RBP=0000006cb39ff230 RSP=0000006cb39ff0d0
 R8=0000000000000016 R9=0000000000000001 R10=0000000000000000 R11=0000000000000007
R12=0000000000000001 R13=0000006cb39ff601 R14=000001d69cef4040 R15=0000006cb39ff6d8
-----------------------------------------------------
Stack crawl:
  0000006cb39ff120: 000000007263e381 (vkGetInstanceProcAddr+0xac21)
  0000006cb39ff660: 000000007263f52d (vkGetInstanceProcAddr+0xbdcd)
  0000006cb39ff730: 00007ff6b32cdcba (not found)
  0000006cb39ffe20: 00007ff6b32da81f (not found)
  0000006cb39ffe80: 00007ff6b32949a5 (not found)
  0000006cb39ffec0: 00007ff6b5d6a7e2 (not found)
  0000006cb39ffef0: 00007ffa33cc7034 (BaseThreadInitThunk+0x0014)
  0000006cb39fff70: 00007ffa340c2651 (RtlUserThreadStart+0x0021)
User avatar
No.19418
cuavas
Administrator
Nov 3, 2021, 23:44
I can get it to happen on Win10 with NVIDIA GeForce, but not reliably – sometimes I have to resize the window lots of times before it happens. The -waitvsync is a red herring, it can happen with -nowaitvsync as well. It's just somewhat random whether it will happen on any given resize.
User avatar
No.19419
ozfalcon
Tester
Nov 4, 2021, 13:53
edited on: Nov 4, 2021, 14:13
Happens here on Debian 11 Linux. Though I am using local compiled subtarget arcade.
#>./sdlmamearcade64.V0237.Mainline pongf -video bgfx -bgfx_backend vulkan -bgfx_debug -window -skip_gameinfo

I can't resize very much before it chokes or seg faults.
V0228 Seems to choke as well but doesn't seg fault.

Interestingly I left -skip_gameinfo on and noticed it was mirrored. (Uploaded).
And I also got ALOT of warnings with -verbose enabled
(Mame 0228 does not display these warnings nor was it mirrored)
Starting Pong (Rev E) [TTL]
Warning: Attempting to retrieve a nonexistent target 'temp' for screen 0
Warning: Attempting to retrieve a nonexistent target 'temp' for screen 0
.....

Note:Never used bgfx or vulcan before so not sure all is as should be on this machine.
User avatar
No.19420
hap
Developer
Nov 4, 2021, 14:12
Those unrelated verbose warnings are fixed in 0.238
User avatar
No.20801
Firewave
Senior Tester
Nov 11, 2022, 14:17
Using 0.249 on Linux I am able to reproduce it with pacman but not 1942:

==8047==ERROR: AddressSanitizer: SEGV on unknown address 0x7f91f7c73a00 (pc 0x7f91fac80833 bp 0x7f921b16f930 sp 0x7f921b16f5c0 T4)
==8047==The signal is caused by a READ memory access.
    #0 0x7f91fac80833  (<unknown module>)
    #1 0x7f92262028f8  (/usr/lib/x86_64-linux-gnu/libvulkan_lvp.so+0x2628f8) (BuildId: 99445f14bee7b60ff39e9452caf6b3f3f586179b)
    #2 0x7f921b16fa1f  (<unknown module>)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (<unknown module>)
Thread T4 created by T1 here:
    #0 0x7f926d32904c in pthread_create (/mnt/s/GitHub/mame/mame+0x24dcc04c) (BuildId: 94a5374e261be8f8)
    #1 0x7f922608199f  (/usr/lib/x86_64-linux-gnu/libvulkan_lvp.so+0xe199f) (BuildId: 99445f14bee7b60ff39e9452caf6b3f3f586179b)

Thread T1 created by T0 here:
    #0 0x7f926d32904c in pthread_create (/mnt/s/GitHub/mame/mame+0x24dcc04c) (BuildId: 94a5374e261be8f8)
    #1 0x7f9296b2ad0b in bx::Thread::init(int (*)(bx::Thread*, void*), void*, unsigned int, char const*) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../3rdparty/bx/src/thread.cpp:181:12
    #2 0x7f92968cf7c8 in bgfx::Context::init(bgfx::Init const&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../3rdparty/bgfx/src/bgfx.cpp:1919:13
    #3 0x7f92968db826 in bgfx::init(bgfx::Init const&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../3rdparty/bgfx/src/bgfx.cpp:3538:14
    #4 0x7f9293adb5ed in renderer_bgfx::init_bgfx_library() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/modules/render/drawbgfx.cpp:196:2
    #5 0x7f9293adc38c in renderer_bgfx::create() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/modules/render/drawbgfx.cpp:311:3
    #6 0x7f9293bdf79b in sdl_window_info::complete_create() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/sdl/window.cpp:853:17
    #7 0x7f9293be272a in sdl_window_info::window_init() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/sdl/window.cpp:446:15
    #8 0x7f9293a090a0 in sdl_osd_interface::video_init() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/sdl/video.cpp:79:12
    #9 0x7f929393acff in osd_common_t::init_subsystems() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/modules/lib/osdobj_common.cpp:665:7
    #10 0x7f929392e50e in sdl_osd_interface::init(running_machine&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/sdl/sdlmain.cpp:483:16
    #11 0x7f92936324ec in running_machine::start() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:151:18
    #12 0x7f9293635e3c in running_machine::run(bool) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:281:3
    #13 0x7f928b745e4f in mame_machine_manager::execute() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:290:19
    #14 0x7f928cafd1c6 in cli_frontend::start_execution(mame_machine_manager*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/clifront.cpp:275:22
    #15 0x7f928cb00d0f in cli_frontend::execute(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/clifront.cpp:291:3
    #16 0x7f928b74ac2f in emulator_info::start_frontend(emu_options&, osd_interface&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:454:18
    #17 0x7f929392c29b in main /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/sdl/sdlmain.cpp:191:9
    #18 0x7f9246669209 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

I wonder if disabling BGFX_CONFIG_MULTITHREADED might give a better trace.
User avatar
No.20818
Augusto
Tester
Nov 15, 2022, 02:10
"BGFX_CONFIG_MULTITHREADED"
is configured in mame.ini or when compiling ?
User avatar
No.20829
Firewave
Senior Tester
Nov 15, 2022, 13:00
It is a compilation define which needs to be the bgfx build files.

I am having issues reproducing this now. I have made no changes to the code.

Using build with BGFX_CONFIG_MULTITHREADED=0 I sometimes see the following when exiting MAME:
X Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
  Major opcode of failed request:  72 (X_PutImage)
  Resource id in failed request:  0x380002
  Serial number of failed request:  4642
  Current serial number in output stream:  4654
User avatar
No.20833
Augusto
Tester
Nov 16, 2022, 02:33
Thanks sharing the compile setting.

Tested in Linux Ubuntu 20.04 using an "old" Radeon HD 3000 (760G .... before 2010) using kernel drivers and Mesa current version.
Not any crashes in moment when trying resize window.

Perhaps the bug is related with windows and Nvidia drivers ?