Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
07372 Crash/Freeze Critical (emulator) Always 12 days ago 10 days ago
Tester GeorgeMcMullen View Status Public Platform MAME (Self-compiled)
Assigned To Resolution Open OS Other
Status [?] Driver
Version 0.211 Fixed in Version Build 32-bit
Summary 07372: X11 Lightgun routine does not check for valid X11 display, resulting in crash (segmentation fault)
Description Greetings,

First bug report, thanks in advance for your patience.

@MrGW reported an issue (https://mametesters.org/view.php?id=7350) with regards to MAME v0.210 crashing immediately on startup, which seemed to be caused by changes in v0.210 which enable X11 and XInput on Linux based systems by default. The workaround is to either compile with X11/XInput explicitly disabled, or start MAME with the option '-lightgunprovider none'. I believe I've found the cause of the issue.

I'm filing a new bug because I'm unable to comment on or reopen the original bug. Also, this is a lower level bug report for the code itself.

Platforms Affected:
- Raspberry Pi (3, 3+, 2, 0)
- Raspbian Stretch or RetroPie 4.4 (based on Raspbian Stretch)

The issue is caused by the Lightgun routine attempting to reference an X11 display when there is none. Thus, this issue is likely to occur on other Linux based platforms where X11 is not being used (e.g. directfb).

The actual crash happens at this line:

https://github.com/mamedev/mame/blob/173962bf18acf20ada60d1b592bf798be28a32a5/src/osd/modules/input/input_x11.cpp#L316

That routine should check that m_display is not null before proceeding to XPending(), which evidently also doesn't check that it's been passed a null value.

But this may also be averted by checking that the X11 initialization routine has actually successfully completed as in the following line:

https://github.com/mamedev/mame/blob/173962bf18acf20ada60d1b592bf798be28a32a5/src/osd/modules/input/input_x11.cpp#L454

A simple check on the return value of initialize will avert the lightgun routine from completing its own initialization, and subsequently causing the crash.
Steps To Reproduce git pull latest MAME source.
Compile MAME using the standard 'makefile' using the 'make' command
Launch MAME. The UI will just start to show and then it dies with a segmentation fault.

Launch MAME with the following command line options:

mame -verbose

You will get output such as the following:

Lightgun: Begin initialization
Unable to connect to X server
Lightgun: End initialization
Joystick: Start initialization
Joystick: End initialization
Searching font Liberation Sans in -. path/s
font Liberation Sans|Regular is not TrueType or BDF, using MAME default
Segmentation fault

Launching MAME with the following command line options is a workaround, which will allow you to use MAME.

mame -lightgunprovider none
Additional Information
Flags
Regression Version
Affected Sets / Systems
Attached Files
 
Relationships
There are no relationship linked to this issue.
Notes
0
There are no notes attached to this issue.