mamedev / mame

MAME
https://www.mamedev.org/
Other
7.97k stars 1.98k forks source link

Memory access violation error upon exit and when launching any game or machine. #10928

Closed Gryzor1363 closed 1 year ago

Gryzor1363 commented 1 year ago

MAME version

0.252

System information

Windows 7 SP1 Pro, 64 Bit Edition FX-8350 x86 AMD Processor 16 Gb RAM Nvidia GTX 1070 Video card, driver version 473.81

INI configuration details

#
# CORE CONFIGURATION OPTIONS
#
readconfig                1
writeconfig               0

#
# CORE SEARCH PATH OPTIONS
#
homepath                  .
rompath                   D:\Emulation\Arcade\Mame\Roms
hashpath                  hash
samplepath                samples
artpath                   artwork
ctrlrpath                 ctrlr
inipath                   ini
fontpath                  .
cheatpath                 cheat
crosshairpath             crosshair
pluginspath               plugins
languagepath              language
swpath                    software

#
# CORE OUTPUT DIRECTORY OPTIONS
#
cfg_directory             cfg
nvram_directory           nvram
input_directory           inp
state_directory           sta
snapshot_directory        snap;D:\Emulation\Arcade\Mame\snap
diff_directory            diff
comment_directory         comments
share_directory           share

#
# CORE STATE/PLAYBACK OPTIONS
#
state                     
autosave                  0
rewind                    0
rewind_capacity           100
playback                  
record                    
exit_after_playback       0
mngwrite                  
aviwrite                  
wavwrite                  
snapname                  %g/%i
snapsize                  auto
snapview                  auto
snapbilinear              1
statename                 %g
burnin                    0

#
# CORE PERFORMANCE OPTIONS
#
autoframeskip             0
frameskip                 0
seconds_to_run            0
throttle                  0
sleep                     1
speed                     1.0
refreshspeed              0
lowlatency                0

#
# CORE RENDER OPTIONS
#
keepaspect                1
unevenstretch             0
unevenstretchx            0
unevenstretchy            0
autostretchxy             0
intoverscan               0
intscalex                 0
intscaley                 0

#
# CORE ROTATION OPTIONS
#
rotate                    1
ror                       0
rol                       0
autoror                   0
autorol                   0
flipx                     0
flipy                     0

#
# CORE ARTWORK OPTIONS
#
artwork_crop              0
fallback_artwork          
override_artwork          

#
# CORE SCREEN OPTIONS
#
brightness                1.0
contrast                  1.0
gamma                     1.0
pause_brightness          0.65
effect                    none

#
# CORE VECTOR OPTIONS
#
beam_width_min            1.0
beam_width_max            1.0
beam_dot_size             1.0
beam_intensity_weight     0
flicker                   0

#
# CORE SOUND OPTIONS
#
samplerate                48000
samples                   1
volume                    0
compressor                1
speaker_report            0

#
# CORE INPUT OPTIONS
#
coin_lockout              1
ctrlr                     
mouse                     1
joystick                  1
lightgun                  0
multikeyboard             0
multimouse                0
steadykey                 0
ui_active                 0
offscreen_reload          0
joystick_map              auto
joystick_deadzone         0.3
joystick_saturation       0.85
natural                   0
joystick_contradictory    0
coin_impulse              0

#
# CORE INPUT AUTOMATIC ENABLE OPTIONS
#
paddle_device             keyboard
adstick_device            mouse
pedal_device              keyboard
dial_device               keyboard
trackball_device          mouse
lightgun_device           mouse
positional_device         keyboard
mouse_device              mouse

#
# CORE DEBUGGING OPTIONS
#
verbose                   0
log                       0
oslog                     0
debug                     0
update_in_pause           0
debugscript               
debuglog                  0

#
# CORE COMM OPTIONS
#
comm_localhost            0.0.0.0
comm_localport            15112
comm_remotehost           127.0.0.1
comm_remoteport           15112
comm_framesync            0

#
# CORE MISC OPTIONS
#
drc                       1
drc_use_c                 0
drc_log_uml               0
drc_log_native            0
bios                      
cheat                     0
skip_gameinfo             0
uifont                    default
ui                        cabinet
ramsize                   
confirm_quit              0
ui_mouse                  1
language                  english
nvram_save                1

#
# SCRIPTING OPTIONS
#
autoboot_command          
autoboot_delay            0
autoboot_script           
console                   0
plugins                   1
plugin                    
noplugin                  

#
# HTTP SERVER OPTIONS
#
http                      0
http_port                 8080
http_root                 web

#
# OSD KEYBOARD MAPPING OPTIONS
#
uimodekey                 auto

#
# OSD FONT OPTIONS
#
uifontprovider            auto

#
# OSD OUTPUT OPTIONS
#
output                    auto

#
# OSD INPUT OPTIONS
#
keyboardprovider          dinput
mouseprovider             auto
lightgunprovider          auto
joystickprovider          auto

#
# OSD DEBUGGING OPTIONS
#
debugger                  auto
debugger_port             23946
debugger_font             auto
debugger_font_size        0
watchdog                  0

#
# OSD PERFORMANCE OPTIONS
#
numprocessors             auto
bench                     0

#
# OSD VIDEO OPTIONS
#
video                     d3d
numscreens                1
window                    0
maximize                  1
waitvsync                 1
syncrefresh               0
monitorprovider           auto

#
# OSD PER-WINDOW VIDEO OPTIONS
#
screen                    auto
aspect                    auto
resolution                auto
view                      auto
screen0                   auto
aspect0                   auto
resolution0               auto
view0                     auto
screen1                   auto
aspect1                   auto
resolution1               auto
view1                     auto
screen2                   auto
aspect2                   auto
resolution2               auto
view2                     auto
screen3                   auto
aspect3                   auto
resolution3               auto
view3                     auto

#
# OSD FULL SCREEN OPTIONS
#
switchres                 0

#
# OSD ACCELERATED VIDEO OPTIONS
#
filter                    0
prescale                  8

#
# OpenGL-SPECIFIC OPTIONS
#
gl_forcepow2texture       0
gl_notexturerect          0
gl_vbo                    1
gl_pbo                    1
gl_glsl                   0
gl_glsl_filter            1
glsl_shader_mame0         none
glsl_shader_mame1         none
glsl_shader_mame2         none
glsl_shader_mame3         none
glsl_shader_mame4         none
glsl_shader_mame5         none
glsl_shader_mame6         none
glsl_shader_mame7         none
glsl_shader_mame8         none
glsl_shader_mame9         none
glsl_shader_screen0       none
glsl_shader_screen1       none
glsl_shader_screen2       none
glsl_shader_screen3       none
glsl_shader_screen4       none
glsl_shader_screen5       none
glsl_shader_screen6       none
glsl_shader_screen7       none
glsl_shader_screen8       none
glsl_shader_screen9       none

#
# OSD SOUND OPTIONS
#
sound                     auto
audio_latency             2

#
# PORTAUDIO OPTIONS
#
pa_api                    none
pa_device                 none
pa_latency                0

#
# BGFX POST-PROCESSING OPTIONS
#
bgfx_path                 bgfx
bgfx_backend              auto
bgfx_debug                0
bgfx_screen_chains        default
bgfx_shadow_mask          slot-mask.png
bgfx_lut                  lut-default.png
bgfx_avi_name             auto

#
# WINDOWS PERFORMANCE OPTIONS
#
priority                  0
profile                   0

#
# WINDOWS VIDEO OPTIONS
#
menu                      0
attach_window             

#
# DIRECT3D POST-PROCESSING OPTIONS
#
hlslpath                  hlsl
hlsl_enable               1
hlsl_oversampling         0
hlsl_write                auto
hlsl_snap_width           2048
hlsl_snap_height          1536
shadow_mask_tile_mode     0
shadow_mask_alpha         0.0
shadow_mask_texture       shadow-mask.png
shadow_mask_x_count       6
shadow_mask_y_count       4
shadow_mask_usize         0.1875
shadow_mask_vsize         0.25
shadow_mask_uoffset       0.0
shadow_mask_voffset       0.0
distortion                0.0
cubic_distortion          0.0
distort_corner            0.0
round_corner              0.0
smooth_border             0.0
reflection                0.0
vignetting                0.0
scanline_alpha            0.0
scanline_size             1.0
scanline_height           1.0
scanline_variation        1.0
scanline_bright_scale     1.0
scanline_bright_offset    0.0
scanline_jitter           0.0
hum_bar_alpha             0.0
defocus                   0.0,0.0
converge_x                0.0,0.0,0.0
converge_y                0.0,0.0,0.0
radial_converge_x         0.0,0.0,0.0
radial_converge_y         0.0,0.0,0.0
red_ratio                 1.0,0.0,0.0
grn_ratio                 0.0,1.0,0.0
blu_ratio                 0.0,0.0,1.0
saturation                1.0
offset                    0.0,0.0,0.0
scale                     1.0,1.0,1.0
power                     1.0,1.0,1.0
floor                     0.0,0.0,0.0
phosphor_life             0.0,0.0,0.0
chroma_mode               3
chroma_conversion_gain    0.299,0.587,0.114
chroma_a                  0.64,0.33
chroma_b                  0.30,0.60
chroma_c                  0.15,0.06
chroma_y_gain             0.2126,0.7152,0.0722

#
# NTSC POST-PROCESSING OPTIONS
#
yiq_enable                0
yiq_jitter                0.0
yiq_cc                    3.57954545
yiq_a                     0.5
yiq_b                     0.5
yiq_o                     0.0
yiq_p                     1.0
yiq_n                     1.0
yiq_y                     6.0
yiq_i                     1.2
yiq_q                     0.6
yiq_scan_time             52.6
yiq_phase_count           2

#
# VECTOR POST-PROCESSING OPTIONS
#
vector_beam_smooth        0.0
vector_length_scale       0.5
vector_length_ratio       0.5

#
# BLOOM POST-PROCESSING OPTIONS
#
bloom_blend_mode          0
bloom_scale               0.0
bloom_overdrive           1.0,1.0,1.0
bloom_lvl0_weight         1.0
bloom_lvl1_weight         0.64
bloom_lvl2_weight         0.32
bloom_lvl3_weight         0.16
bloom_lvl4_weight         0.08
bloom_lvl5_weight         0.06
bloom_lvl6_weight         0.04
bloom_lvl7_weight         0.02
bloom_lvl8_weight         0.01
lut_texture               lut-default.png
lut_enable                0
ui_lut_texture            lut-default.png
ui_lut_enable             0

#
# FULL SCREEN OPTIONS
#
triplebuffer              1
full_screen_brightness    1.0
full_screen_contrast      1.0
full_screen_gamma         1.0

#
# INPUT DEVICE OPTIONS
#
global_inputs             0
dual_lightgun             0

Emulated system/software

Internal UI

Incorrect behaviour

Upon executing Mame 0.252 with video set to "d3d" in mame.ini, attempting to launch any game leads to a forceclose of Mame, with the following memory access violation error in the windows console :

Exception at EIP=000007fef8e034d0 (not found): ACCESS VIOLATION While attempting to write memory at 000007fef8e034d0

RAX=00000000001597e0 RBX=0000000000000000 RCX=00000000000513f8 RDX=0000000000000 090 RSI=0000000000000001 RDI=0000000000000000 RBP=0000000000159dd0 RSP=0000000000159 778 R8=0000000000000000 R9=0000000000000000 R10=00000000000513f8 R11=0000000000000 000 R12=0000000000000000 R13=0000000000000090 R14=0000000000000000 R15=0000000000051 3f8

Stack crawl: 0000000000159770: 000007fef8e034d0 (not found) 0000000000159830: 0000000077379861 (TranslateMessageEx+0x0291) 0000000000159890: 0000000077376f8b (SetWindowTextW+0x0277) 00000000001598f0: 00000000773764d5 (IsDialogMessageW+0x0169) 0000000000159978: 00000000774cb4ef (KiUserCallbackDispatcher+0x001f) 0000000000159980: 000000007736c93a (DestroyWindow+0x000a) 00000000001599b0: 0000000147654c36 (not found) 00000000001599e0: 000000014a1433ee (not found) 0000000000159a20: 0000000147654fe1 (not found) 0000000000159a50: 000000014766078d (not found) 0000000000159a90: 000000014764eb35 (not found) 0000000000159ac0: 0000000143da0f01 (not found) 0000000000159c20: 0000000143fc862a (not found) 000000000015f140: 000000014763c6fb (not found) 000000000015f520: 000000014a08660f (not found) 000000000015f7e0: 000000014a086c1d (not found) 000000000015f840: 0000000147636e29 (not found) 000000000015fc00: 000000014b293a09 (not found) 000000000015fcd0: 000000013f5413b1 (not found) 000000000015fd00: 000000013f5414e6 (not found) 000000000015fd30: 000000007725556d (BaseThreadInitThunk+0x000d) 000000000015fd80: 00000000774b372d (RtlUserThreadStart+0x001d)

I get an identical error when trying to exit Mame without launching anything, and when doing that, Mame sometimes hangs and process becomes unresponsive with a blackscreen.

Expected behaviour

Game launching normally, and Mame exiting normally.

Steps to reproduce

1.Start Mame. 2.Attempt to load any game. 3.Try to exit Mame.

Additional details

A workaround (as per Cuavas' advice) consists in replacing the backend parameter in Mame.ini with anything other than "d3d". Indeed, both opengl and bgfx work fine, irrespective of the setting in lower-level INIs such as Horizont.ini or Vertical.ini.

In this case, even d3d in either file works fine and HLSL functions are active and working normally as well.

This is the first ever issue of this kind I am getting on this computer, of which the system configuration has not changed in months at least, and all previous versions tested all the way to 0.251 work just fine.

Robbbert commented 1 year ago

I tested the official release on both Windows 7 (esr) and Windows 10 with no issue. Both machines have the latest updates.

I have seen a number of complaints about this release, such as freezing, crashing, and loss of controller settings - but only for certain people. Perhaps there's some local incompatibility now.

mikeswanson commented 1 year ago

Just installed 0.252 on my machine as a clean install, pointed it to my ROMs, changed nothing else, and I see the same reported behavior. I can't start any machines from the UI, and I get the black screen when I exit. Also, when I run from the command-line, I see the "ACCESS VIOLATION" message. For what it's worth, 0.251 works great.

Windows 11 Pro 64-bit AMD Ryzen 9 5950X 32.0GB RAM NVIDIA GeForce RTX 4090 / 528.49 (latest)

Like the original report, using 'bgfx' works fine.

garfieldbanks commented 1 year ago

This is on Windows 10. Confirming the above reports. I cannot exit mame v0252 without using "taskkill /f /im mame.exe". I tried the following backends, each with the same result (black screen): auto / d3d / opengl / bgfx

I had to actually create a shortcut to a cmd file and put it in my start menu because I couldn't even open my task manager. No other window would open it would always flash back to the black screen. But my start menu opened so I put a shortcut in there while I tested this.

I used the default settings provided by running mame.exe -cc.

After switching back to mame v0251 and running the default settings with mame.exe -cc I was able to run and exit the game with no issues.

cuavas commented 1 year ago

This is on Windows 10. Confirming the above reports. I cannot exit mame v0252 without using "taskkill /f /im mame.exe". I tried the following backends, each with the same result (black screen): auto / d3d / opengl / bgfx

That’s not confirming the above reports, that’s completely different behaviour.

garfieldbanks commented 1 year ago

This is on Windows 10. Confirming the above reports. I cannot exit mame v0252 without using "taskkill /f /im mame.exe". I tried the following backends, each with the same result (black screen): auto / d3d / opengl / bgfx

That’s not confirming the above reports, that’s completely different behaviour.

I get the same error in the original post if I alt-tab around long enough it finally dies with that same error. The only difference I have is that none of the backends worked on my system. The game starts and runs, but when attempting to exit, it goes to a black screen that is hard to get out of. You cannot open the task manager or alt-tab or anything because it just goes right back to the black screen. The first couple times I tested I managed to get out by opening the Run window and blindly typing taskkill /f /im mame.exe. After a couple times I added the shortcut to do it myself.

cuavas commented 1 year ago

I get the same error in the original post if I alt-tab around long enough it finally dies with that same error. The only difference I have is that none of the backends worked on my system. The game starts and runs, but when attempting to exit, it goes to a black screen that is hard to get out of. You cannot open the task manager or alt-tab or anything because it just goes right back to the black screen. The first couple times I tested I managed to get out by opening the Run window and blindly typing taskkill /f /im mame.exe. After a couple times I added the shortcut to do it myself.

The other people are describing an issue affecting D3D only, and only when the system selection menu is displayed. That is not the same as the symptoms you are reporting. If the discussion on this issue continues to get derailed, it’s going to turn into a waste of everyone’s time and will need to be locked.

MASHinfo commented 1 year ago

I have the same problem with the official MAME under Windows 10 (black screen and can't exit). My joystick is the problem. I have a NACON GC-100 joystick with two game modes (PC and X-Box). MAME works only in the X-Box mode. The normal PC mode does not work since MAME 0.252. If you set in the mame.ini: joystickprovider none MAME works and exit without errors!

mikeswanson commented 1 year ago

If you set in the mame.ini: joystickprovider none MAME works and exit without errors!

This fixes the reported issues for me (though I can't use my joystick, of course). I have a RAC-J500S stick, and the black screen and memory access violations disappear if I either edit the .ini file or just unplug the joystick. For now, I'll use the aforementioned bgfx workaround, because the joystick continues to work.

oldghost83 commented 1 year ago

Ok, after fiddling with different settings, seems the culprit is auto mode after all. But not for gamepad. For video. But it's somehow connected to autodetecting dinput gamepads. All you need to do with new MAME 0.252 setup is unplug the dinput gamepad, if you use it like myself, before starting MAME and set video mode to something else, bgfx, for example, or opengl. Save settings, close it. Then plug your gamepad, start mame again and everything should work and close properly. No further settings required here. Input is left at default (auto). If we set video mode back to auto, it will resume freezing on exit. Oh, and unplugging gamepad on freeze doesn't help to unfreeze it. Seems that mame needs the same time to auto-exit. 20 seconds or so. Can people confirm this, please? Different computers may need different stuff. But with xinput gamepads it seems ok. No freezes.

mikeswanson commented 1 year ago

Can people confirm this, please?

Yep. This is the same as my experience.

cuavas commented 1 year ago

So can everyone confirm the issues only happen with DirectInput joysticks connected?

Also, can the issues happen without joysticks connected if you use -keyboardprovider dinput -mouseprovider dinput to use DirectInput for mouse/keyboard?

This does give some more clues as to what’s going on. I believe there’s a memory corruption issue in the Windows input code that predates 0.252, but because it seems to happen randomly, I haven’t been able to track it down. For me, it typically manifests as the -multimouse or -multikeyboard option getting turned on when it shouldn’t be.

Unfortunately I don’t have a memory analyser setup for Windows at the moment, and apparently the Visual Studio tools I’m using are too old to support ASAN. I’ll see what I can do.

cuavas commented 1 year ago

One other thing to test – does changing the sound module affect whether it crashes? Does -sound xaudio2 stop it from crashing?

I managed to get MAME building with ASAN on Windows, and unfortunately it hasn’t turned up any errors in the DirectInput code. Whatever’s happening is a nasty intermittent bug.

mikeswanson commented 1 year ago

Just did a bunch of tests, and yes, I only see the issue when the joystick is physically connected. When it's disconnected, everything works as-expected.

cuavas commented 1 year ago

Just did a bunch of tests, and yes, I only see the issue when the joystick is physically connected.

Thanks. I’ll keep trying to track it down. This has been bothering me for years.

cuavas commented 1 year ago

I think I fixed a major source of DirectInput crashes with 42e759ade491813588fda7cb185878d80a831a05. If you can compile yourself of grab a CI build with from top-of-tree you can see if it’s fixed, otherwise you can wait for 0.253 at worst.

mikeswanson commented 1 year ago

If you can compile yourself of grab a CI build with from top-of-tree you can see if it’s fixed, otherwise you can wait for 0.253 at worst.

Just compiled a version with your changes, and it appears to fix the issue. I no longer see the errors that are described in this issue.

Gryzor1363 commented 1 year ago

So can everyone confirm the issues only happen with DirectInput joysticks connected?

Also, can the issues happen without joysticks connected if you use -keyboardprovider dinput -mouseprovider dinput to use DirectInput for mouse/keyboard?

Yes, for my part I can also confirm that, while the backend in mame.ini is set to d3d :

LordEvyl commented 1 year ago

I'm getting this issue too. MAME just CRASHES and goes back to my desktop whenever I click on a ROM, and yes, I do have the newest ROMSET. I get NO ERROR message, it just CRASHES. Just solved it by unplugging my SNES style controller, and plugging my Logitech controller in instead....