shonumi / gbe-plus

DMG/GBC/GBA emulator and experimental NDS emulator.
GNU General Public License v2.0
530 stars 80 forks source link

Crash on OpenBSD #37

Closed bentley closed 8 years ago

bentley commented 8 years ago

Tested on an OpenBSD 6.0 snapshot.

$ egdb src/gbe_plus            
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-openbsd6.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from src/gbe_plus...done.
(gdb) run /tmp/pht-mr.gbc
Starting program: /tmp/gbe-plus/build/src/gbe_plus /tmp/pht-mr.gbc
GBE+ 1.0 [SDL]
GBE::Error - Could not open gbe.ini configuration file. Check file path or permissions. 
MMU::Initialized

Program received signal SIGBUS, Bus error.
0x00001ea0048ec320 in SDL_DestroyWindow_REAL ()
   from /usr/local/lib/libSDL2.so.0.2
(gdb) bt
#0  0x00001ea0048ec320 in SDL_DestroyWindow_REAL ()
   from /usr/local/lib/libSDL2.so.0.2
#1  0x00001e9d7425cc62 in DMG_LCD::reset (this=0x1ea06eef1498)
    at /tmp/gbe-plus/src/dmg/lcd.cpp:35
#2  0x00001e9d7425df03 in DMG_LCD::DMG_LCD (this=0x1ea06eef1498)
    at /tmp/gbe-plus/src/dmg/lcd.cpp:19
#3  0x00001e9d7426eade in Z80::io_controllers::io_controllers (
    this=<optimized out>) at /tmp/gbe-plus/src/dmg/z80.h:106
#4  Z80::Z80 (this=0x1ea06eef1458) at /tmp/gbe-plus/src/dmg/z80.cpp:14
#5  0x00001e9d74248a50 in DMG_core::DMG_core (this=0x1ea06eef1350, 
    __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /tmp/gbe-plus/src/dmg/core.cpp:22
#6  0x00001e9d74207344 in main (argc=<optimized out>, 
    args=0x1e9d746945b0 <config::cli_args>) at /tmp/gbe-plus/src/main.cpp:46
(gdb) 
shonumi commented 8 years ago

Does this commit fix it? -> 4be1c8fa2764fdebeed1433bfd164f63248c4cd1

bentley commented 8 years ago

That does fix the crash. Thanks!

The emulator still doesn’t work, failing with “LCD::Error - Could not initialize SDL”. This is because SDL2’s haptic support doesn’t work on OpenBSD; SDL_INIT_ALL tries to pull in the haptic support, and fails. Replacing SDL_INIT_ALL with SDL_INIT_TIMER|SDL_INIT_AUDIO|SDL_INIT_VIDEO|SDL_INIT_EVENTS (like this commit) allows the emulator to run on OpenBSD.

shonumi commented 8 years ago

I think it would be better to have each component initialize the subsystems they need (e.g. GamePad initializes joysticks + haptics, APU initializes audio, LCD inits video (and events by that extension). That way, failure is reported appropriately by the failing component. Having the LCD init everything was kind of a hack I never got around to correcting. So, I was being lazy, and SDL 1.2 would let me get away with it :P

Does this commit fix it? -> 7e65cbec66ea3d66493799b1843716ac3fcf

bentley commented 8 years ago

Yep, works for me.

shonumi commented 8 years ago

Great! Thanks a lot for the detailed report (that backtrace made it 100x easier to pinpoint the crash). I'll mark this as closed then.