Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
07372 Crash/Freeze Critical (emulator) Always Jul 6, 2019, 22:43 Oct 19, 2019, 18:52
Tester GeorgeMcMullen View Status Public Platform MAME (Self-compiled)
Assigned To GeorgeMcMullen Resolution Fixed OS Other
Status [?] Resolved Driver
Version 0.211 Fixed in Version 0.215 Build 32-bit
Fixed in Git Commit Github Pull Request #
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
Github Commit
Flags
Regression Version
Affected Sets / Systems
Attached Files
 
Relationships
There are no relationship linked to this issue.
Notes
3
User avatar
No.16684
GeorgeMcMullen
Tester
Jul 20, 2019, 16:51
I checked out the history of the input_x11.cpp OSD module and the lines that I mentioned are actually from the original refactoring of the file. As such, knowledge about the inner workings and potential regressions may be hard to come by. Barring anybody else's contribution, I'll do some additional tracing of the code to see if there are any possible hitches and submit a pull request.
User avatar
No.17084
GeorgeMcMullen
Tester
Oct 13, 2019, 17:15
Quick update. I've been working on a pull request and have gotten some feedback.

https://github.com/mamedev/mame/pull/5725
User avatar
No.17097
GeorgeMcMullen
Tester
Oct 18, 2019, 19:03
My pull request has been merged into master. Thank you!

https://github.com/mamedev/mame/commit/4a2d4b3911488fc73d3443ec569093860e37be38