BlitterStudio / amiberry

Optimized Amiga emulator for Linux/macOS
https://amiberry.com
GNU General Public License v3.0
643 stars 86 forks source link

JIT on Odroid XU4 #149

Closed bspinner closed 6 years ago

bspinner commented 6 years ago

JIT on Odroid XU4 seems to be broken. As mentioned here, it's failing at boot time for A4000 configurations. Other models aren't stable either.

Symptoms:

Logs: uae4arm_log.accessviolation.txt uae4arm_log.h10.txt

https://github.com/midwan/amiberry/issues/149#issuecomment-364553559

midwan commented 6 years ago

@bspinner Did you get a chance to test with the latest improvements? We had a chance to test it on the Tinkerboard also, and it works correctly there as well...

bspinner commented 6 years ago

Hey,

nice to come back to this repo and see a lot of changes. Thanks for your hard work! :)

See https://github.com/midwan/amiberry/pull/223 for problems I'm currently experiencing.

midwan commented 6 years ago

@bspinner Thanks for the feedback! Will look into the problem and respond there.

midwan commented 6 years ago

@bspinner Thanks for the #223 PR! :) Now that it's running again, please let me know if it works as expected or if you find anything out of the ordinary?

midwan commented 6 years ago

@bspinner Also, you might have improved results if the render thread works for you in SDL2 (not sure the SDL1 target even makes sense on the XU4, since we don't have hardware acceleration there).

Try adding -DUSE_RENDER_THREAD in the Makefile and test if it works? If you get a black screen after the GUI, then it doesn't work, but if it DOES work, you'll see a nice performance boost.

bspinner commented 6 years ago

Well, actually I am getting a crash without the flag when I press Start. (to be clear: before the PR I didn't even get to the GUI 😃 )

gdb output, segfault again:

Thread 1 "amiberry-xu4-sd" received signal SIGSEGV, Segmentation fault.
0xb6f74b4a in ?? () from /usr/lib/arm-linux-gnueabihf/libSDL2-2.0.so.0

Will rebuild with -DUSE_RENDER_THREAD flag right now. edit: Same thing with the flag. ☚ī¸ Looks like it's time for me to learn how to step through code with gdb 🙂

midwan commented 6 years ago

@bspinner Did you build SDL2 from source or did you use binaries provided by the repo? Which version of SDL2 are you running? What repo is the XU4 using? What's the output of gcc -v ?

bspinner commented 6 years ago
$  g++ -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/5/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.6' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.6)

(it's the latest ubuntu 16.04 as provided by hardkernel)

bspinner commented 6 years ago

Something else I noticed: the GUI isn't scaled to fullscreen anymore. Is that on purpose/do I have to configure something?

midwan commented 6 years ago

@bspinner Since the crash seems to occur in libSDL2, it might work better with a self-compiled version from SDL2's sources. I'm not sure what flags RetroPie used when configuring SDL2 on the XU4...

On the RPI, there's the notion of different gfx drivers (Legacy, fkms, full KMS). Depending on which one is enabled, and what configuration options you provide in SDL2 before building it, the behavior will be different.

I'm not sure how it looks on the XU4, but if you try a configure --enable-video-kmsdrm (in SDL2's source directory), it will list what video drivers are available to use.

midwan commented 6 years ago

@bspinner If running SDL2, the screen should scale to full-screen size, but it depends on the SDL2 backend used. In SDL1, there's no hardware scaling.

bspinner commented 6 years ago
 ./configure --enable-video-kmsdrm
checking build system type... armv7l-unknown-linux-gnueabihf
checking host system type... armv7l-unknown-linux-gnueabihf
[...]
-- dynamic libXxf86vm -> libXxf86vm.so.1
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for libdrm 2.4.46 library for kmsdrm support... yes
checking for libgbm 9.0.0 library for kmsdrm support... no
checking for OpenGL (GLX) support... yes
checking for EGL support... yes
checking for OpenGL ES v1 headers... yes
checking for OpenGL ES v2 headers... yes
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for Mir support... no
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for Wayland support... no
checking libudev.h usability... yes
checking libudev.h presence... yes
checking for libudev.h... yes
-- dynamic udev -> libudev.so.1
checking for pkg-config... (cached) /usr/bin/pkg-config
checking dbus/dbus.h usability... yes
checking dbus/dbus.h presence... no
configure: WARNING: dbus/dbus.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: dbus/dbus.h: proceeding with the compiler's result
checking for dbus/dbus.h... yes
checking for pkg-config... (cached) /usr/bin/pkg-config
checking ibus-1.0/ibus.h usability... yes
checking ibus-1.0/ibus.h presence... no
configure: WARNING: ibus-1.0/ibus.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: ibus-1.0/ibus.h: proceeding with the compiler's result
checking for ibus-1.0/ibus.h... yes
checking sys/inotify.h usability... yes
checking sys/inotify.h presence... yes
checking for sys/inotify.h... yes
checking for pkg-config... (cached) /usr/bin/pkg-config
checking fcitx/frontend.h usability... yes
checking fcitx/frontend.h presence... yes
checking for fcitx/frontend.h... yes
checking for Linux 2.4 unified input interface... yes
checking for Linux kd.h... yes
checking for Touchscreen library support... no
checking for pthreads... yes
checking for recursive mutexes... yes
checking for pthread semaphores... yes
checking for sem_timedwait... yes
checking for pthread_np.h... no
checking for pthread_setname_np... yes
checking for pthread_set_name_np... no
checking for clock_gettime in -lrt... yes
checking linux/version.h usability... yes
checking linux/version.h presence... yes
checking for linux/version.h... yes
checking for Vivante VDK API... no
checking for Vivante FB API... no
checking for linker option --enable-new-dtags... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sdl2-config
config.status: creating sdl2-config.cmake
config.status: creating SDL2.spec
config.status: creating sdl2.pc
config.status: creating include/SDL_config.h
config.status: executing libtool commands
config.status: executing sdl2_config commands
config.status: executing summary commands
SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic power filesystem threads timers file loadso cpuinfo assembly
Assembly Math   :
Audio drivers   : disk dummy oss alsa(dynamic)
Video drivers   : dummy x11(dynamic) opengl opengl_es1 opengl_es2 vulkan
X11 libraries   : xcursor xdbe xinerama xinput2 xinput2_multitouch xrandr xscrnsaver xshape xvidmode
Input drivers   : linuxev linuxkd
Using libsamplerate : NO
Using libudev       : YES
Using dbus          : YES
Using ime           : YES
Using ibus          : YES
Using fcitx         : YES
midwan commented 6 years ago

@bspinner OK, no KMSDRM support from what it seems... Do you have libgles2-mesa-dev and libgbm-dev installed? I believe those are a requirement for KMSDRM...

solskogen commented 6 years ago

and pkg-config!

On Thu, Feb 1, 2018 at 11:44 PM, Dimitris Panokostas < notifications@github.com> wrote:

@bspinner https://github.com/bspinner OK, no KMSDRM support from what it seems... Do you have libgles2-mesa-dev and libgbm-dev installed? I believe those are a requirement for KMSDRM...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/midwan/amiberry/issues/149#issuecomment-362427220, or mute the thread https://github.com/notifications/unsubscribe-auth/AA-P6ItWwy1Ef8xi7X6VtJOKAgjgHOhUks5tQj5GgaJpZM4QVOc9 .

bspinner commented 6 years ago

Rebuild SDL2 with kmsdrm support, still not working. Previous amiberry version, compiled in November 2017, is still starting and running fine.

midwan commented 6 years ago

@bspinner I've written a small test program, to try out SDL2 and the different backends. Could you try it and tell me what it reports?

Once you run it, it will display an image. You can quit from it with the "Q" button on the keyboard. It's located here: https://github.com/midwan/SDL2_performance_test

bspinner commented 6 years ago
name : opengles2
flags : SDL_RENDERER_ACCELERATED SDL_RENDERER_TARGETTEXTURE
nb textures max : 8
texture size max : 8192 x 8192
current driver : mali
RenderCopy 200x100 : 13826
RenderPresent : 349
RenderCopy 800x600 : 79
RenderPresent : 229
$ SDL_VIDEODRIVER=kmsdrm ./SDL2_performance_test
Failed to initialize SDL (kmsdrm not available)
bspinner commented 6 years ago

@midwan Any other ideas? Is KMS/DRM actually neccessary to use amiberry now?

midwan commented 6 years ago

@bspinner Sorry for the delay, got caught up with other things here. No, KMSDRM is not required of course. Any display driver will do, as long as SDL2 supports it. KMSDRM allows for fullscreen applications to launch from the console, which is why it's preferred (to keep the overhead low).

Are you trying to launch it from the console or under X11? How did you run the performance test I mentioned earlier?

bspinner commented 6 years ago

@midwan I've started it plain from console, no X11 running. As I did before with previous amiberry versions a lot of times.

midwan commented 6 years ago

@bspinner When you say previous versions, did you try SDL1 or SDL2 versions earlier? Just trying to understand what fails exactly, since I don't have such a board to test with here...

bspinner commented 6 years ago

@midwan I've used (and contributed to) the SDL2 version only so far :) Never touched SDL1 on the xu4.

Is there some way to get more info out of SDL/amiberry than just a crash? The gdb backtrace isn't helpful :(

(gdb) backtrace
#0  0xb6f74b4e in ?? () from /usr/lib/arm-linux-gnueabihf/libSDL2-2.0.so.0
#1  0xb6f80134 in ?? () from /usr/lib/arm-linux-gnueabihf/libSDL2-2.0.so.0

Do I have to compile SDL with debug symbols or something like that?

midwan commented 6 years ago

@bspinner Yes, try enabling the WITH_LOGGING define in the Makefile. That will generate a log file while the emulator is running, and might indicate a bit more (at least we'll know how far it got until it stopped).

The only recent change I made regarding graphics in SDL2, was the option to use Fullscreen or Windowed mode. But with the latest updates, it tries to detect if it's running under "x11" or not, and only if it is, it will enable Windowed mode (otherwise it tries to open a FULLSCREEN_DESKTOP as it did before).

From what I can see in your test, you have opengles2 support.

When you run the test application, did you also see the window open up, with the Amiberry logo showing? Was that fullscreen as expected?

bspinner commented 6 years ago

Summary:

Log:

AMIBERRY Logfile

Allocated 16 MB for 24-bit area (0x20000000) and 144 MB for Z3 and RTG at real address (0x60000000 - 0x69000020)
KS ver = 34 (0x22)
Stored port 1/0 d=0: added 100 0
Stored port 1/0 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
Port1: ID 'joy1' matched
Port0: NONE
Port2: NONE
Port3: NONE
0: 640x400, 8-bit (50,60)
1: 640x400, 16-bit (50,60)
2: 640x400, 32-bit (50,60)
3: 640x480, 8-bit (50,60)
4: 640x480, 16-bit (50,60)
5: 640x480, 32-bit (50,60)
6: 720x400, 8-bit (50,60)
7: 720x400, 16-bit (50,60)
8: 720x400, 32-bit (50,60)
9: 800x480, 8-bit (50,60)
10: 800x480, 16-bit (50,60)
11: 800x480, 32-bit (50,60)
12: 800x600, 8-bit (50,60)
13: 800x600, 16-bit (50,60)
14: 800x600, 32-bit (50,60)
15: 960x540, 8-bit (50,60)
16: 960x540, 16-bit (50,60)
17: 960x540, 32-bit (50,60)
18: 1024x768, 8-bit (50,60)
19: 1024x768, 16-bit (50,60)
20: 1024x768, 32-bit (50,60)
21: 1280x720, 8-bit (50,60)
22: 1280x720, 16-bit (50,60)
23: 1280x720, 32-bit (50,60)
24: 1280x800, 8-bit (50,60)
25: 1280x800, 16-bit (50,60)
26: 1280x800, 32-bit (50,60)
27: 1280x1024, 8-bit (50,60)
28: 1280x1024, 16-bit (50,60)
29: 1280x1024, 32-bit (50,60)
30: 1360x768, 8-bit (50,60)
31: 1360x768, 16-bit (50,60)
32: 1360x768, 32-bit (50,60)
33: 1366x768, 8-bit (50,60)
34: 1366x768, 16-bit (50,60)
35: 1366x768, 32-bit (50,60)
36: 1680x1050, 8-bit (50,60)
37: 1680x1050, 16-bit (50,60)
38: 1680x1050, 32-bit (50,60)
39: 1920x1080, 8-bit (50,60)
40: 1920x1080, 16-bit (50,60)
41: 1920x1080, 32-bit (50,60)
target_cfgfile_load(): load file /home/retropie/amiberry/conf/uaeconfig.uae
load config '/home/retropie/amiberry/conf/uaeconfig.uae':3
unknown config entry: 'amiberry.custom_controls=false'
unknown config entry: 'amiberry.custom_up=20480557'
unknown config entry: 'amiberry.custom_down=20480813'
unknown config entry: 'amiberry.custom_left=20481069'
unknown config entry: 'amiberry.custom_right=20481325'
unknown config entry: 'amiberry.custom_a=20481581'
unknown config entry: 'amiberry.custom_b=20481837'
unknown config entry: 'amiberry.custom_x=20482093'
unknown config entry: 'amiberry.custom_y=20482349'
unknown config entry: 'amiberry.custom_l=20482605'
unknown config entry: 'amiberry.custom_r=20482861'
unknown config entry: 'amiberry.custom_play=20483117'
unknown config entry: 'gfx_vsync=autoswitch'
unknown config entry: 'gfx_vsync_picasso=autoswitch'
KS ver = 34 (0x22)
Stored port 1/0 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
Port1: COMBO 'Built-in joystick' + 'JOY0' matched
Unplugged stored, port 0 'Mouse' (MOUSE0)
Stored port 0/0 d=0: added -2 0 Mouse MOUSE0
Port2: NONE
Port3: NONE
KS ver = 34 (0x22)
Stored port 1/0 d=1: added 100 0 Keyboard as Joystick [Default] JOY0
Port1: COMBO 'Keyboard as Joystick [Default]' + 'JOY0' matched
Port0: NONE
Port2: NONE
Port3: NONE
Autoconfig board list:
Card 01: '<no name>' no autoconfig 00dd2020 - 00dd301f.
END
--- New exception ---
JIT not in use.
Segmentation Fault
info.si_signo = 11
info.si_errno = 0
info.si_code = 1
info.si_addr = fd46187e
r0  = 0xfd461846
r1  = 0x00000000
r2  = 0x00000000
r3  = 0x020a5380
r4  = 0xb6544ab1
r5  = 0x0153e700
r6  = 0x00000000
r7  = 0x018f24c0
r8  = 0x01503d68
r9  = 0x00000001
r10 = 0x003ab010
FP  = 0xbef73624
IP  = 0x0042c154
SP  = 0xbef73388
LR  = 0xb6e93135
PC  = 0xb6e87b4e
CPSR = 0x48070030
Fault Address = 0xfd46187e
Trap no = 0x0000000e
Err Code = 0x00000005
Old Mask = 0x00000000
LR - 0xB6E93135: <(null)> (/usr/lib/arm-linux-gnueabihf/libSDL2-2.0.so.0)
Stack trace:
0x00146274 <(null) + 0x00146274> (./amiberry-xu4-sdl2-dev)
0xb68d9270 <(null) + 0xb68d9270> (/lib/arm-linux-gnueabihf/libc.so.6)
01: 0x003ab010 <(null) + 0x003ab010> (./amiberry-xu4-sdl2-dev)
IP out of range
Stack trace (non-dedicated):
./amiberry-xu4-sdl2-dev() [0x14634a]
/lib/arm-linux-gnueabihf/libc.so.6(+0x25270) [0xb68d9270]
End of stack trace.
--- end exception ---
HoraceAndTheSpider commented 6 years ago

That Config file is full of a lot of old info. It should be replaced with a fresh own starting from the QuickStart option as the base.

Delete the uaeconfig.uae file first of all I think!

midwan commented 6 years ago

That's worth a try for sure, also if you have an older adfdir.conf file, please remove that and allow it to be regenerated by the emulator.

I originally suspected the JIT FPU code, but with the above log it seems you haven't got JIT enabled, so it can't be that...

bspinner commented 6 years ago

Still crashes. :( Used A1200 quick start config this time.

AMIBERRY Logfile

Allocated 16 MB for 24-bit area (0x20000000) and 144 MB for Z3 and RTG at real address (0x60000000 - 0x69000020)
KS ver = 34 (0x22)
Stored port 1/0 d=0: added 100 0  
Stored port 1/0 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
Port1: ID 'joy1' matched
Port0: NONE
Port2: NONE
Port3: NONE
0: 640x400, 8-bit (50,60)
1: 640x400, 16-bit (50,60)
2: 640x400, 32-bit (50,60)
3: 640x480, 8-bit (50,60)
4: 640x480, 16-bit (50,60)
5: 640x480, 32-bit (50,60)
6: 720x400, 8-bit (50,60)
7: 720x400, 16-bit (50,60)
8: 720x400, 32-bit (50,60)
9: 800x480, 8-bit (50,60)
10: 800x480, 16-bit (50,60)
11: 800x480, 32-bit (50,60)
12: 800x600, 8-bit (50,60)
13: 800x600, 16-bit (50,60)
14: 800x600, 32-bit (50,60)
15: 960x540, 8-bit (50,60)
16: 960x540, 16-bit (50,60)
17: 960x540, 32-bit (50,60)
18: 1024x768, 8-bit (50,60)
19: 1024x768, 16-bit (50,60)
20: 1024x768, 32-bit (50,60)
21: 1280x720, 8-bit (50,60)
22: 1280x720, 16-bit (50,60)
23: 1280x720, 32-bit (50,60)
24: 1280x800, 8-bit (50,60)
25: 1280x800, 16-bit (50,60)
26: 1280x800, 32-bit (50,60)
27: 1280x1024, 8-bit (50,60)
28: 1280x1024, 16-bit (50,60)
29: 1280x1024, 32-bit (50,60)
30: 1360x768, 8-bit (50,60)
31: 1360x768, 16-bit (50,60)
32: 1360x768, 32-bit (50,60)
33: 1366x768, 8-bit (50,60)
34: 1366x768, 16-bit (50,60)
35: 1366x768, 32-bit (50,60)
36: 1680x1050, 8-bit (50,60)
37: 1680x1050, 16-bit (50,60)
38: 1680x1050, 32-bit (50,60)
39: 1920x1080, 8-bit (50,60)
40: 1920x1080, 16-bit (50,60)
41: 1920x1080, 32-bit (50,60)
target_cfgfile_load(): load file /home/retropie/amiberry/conf/uaeconfig.uae
load config '/home/retropie/amiberry/conf/uaeconfig.uae':3
cfgfile_load_2 failed
KS ver = 34 (0x22)
Stored port 1/0 d=0: added 100 0  
Stored port 1/0 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
Port1: ID 'joy1' matched
Port0: NONE
Port2: NONE
Port3: NONE
failed to load config '/home/retropie/amiberry/conf/uaeconfig.uae'
KS ver = 34 (0x22)
Stored port 1/0 d=1: added 100 0 Keyboard as Joystick [Default] JOY0
Port1: COMBO 'Keyboard as Joystick [Default]' + 'JOY0' matched
Port0: NONE
Port2: NONE
Port3: NONE
Autoconfig board list:
Card 01: '<no name>' no autoconfig 00dd2020 - 00dd301f.
END
Autoconfig board list:
Card 01: '<no name>' no autoconfig 00da0000 - 00daffff.
Card 02: '<no name>' no autoconfig 00600000 - 00a7ffff.
Card 03: 'Z2 Fast RAM'
  e7.51.00.00.07.db.00.00.00.01.00.00.00.00.00.00
  MID 2011 (07db) PID 81 (51) SER 00000001
  Z2 0x00200000 0x00200000 4096K RAM 0
END
KS ver = 39 (0x27)
Stored port 1/1 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
Port1: COMBO 'Keyboard as Joystick [Default]' + 'JOY0' matched
Port0: NONE
Port2: NONE
Port3: NONE
Stored port 1/1 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
Stored port 1/1 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
Autoconfig board list:
Card 01: '<no name>' no autoconfig 00da0000 - 00daffff.
Card 02: '<no name>' no autoconfig 00600000 - 00a7ffff.
Card 03: 'Z2 Fast RAM'
  e7.51.00.00.07.db.00.00.00.01.00.00.00.00.00.00
  MID 2011 (07db) PID 81 (51) SER 00000001
  Z2 0x00200000 0x00200000 4096K RAM 0
END
KS ver = 39 (0x27)
Stored port 1/1 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
Port1: COMBO 'Keyboard as Joystick [Default]' + 'JOY0' matched
Port0: NONE
Port2: NONE
Port3: NONE
Stored port 1/1 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
mapped_malloc(): 0x00f00000 - 0x00f10000 (0x20f00000 - 0x20f10000) -> UAE Boot ROM (rtarea)
mapped_malloc(): 0x00200000 - 0x00600000 (0x20200000 - 0x20600000) -> Fast memory (*)
mapped_malloc(): 0x00f80000 - 0x01000000 (0x20f80000 - 0x21000000) -> Kickstart ROM (kick)
mapped_malloc(): 0x00000000 - 0x00200000 (0x20000000 - 0x20200000) -> Chip memory (chip)
ROM loader.. (<none>)
Known ROM 'KS ROM v3.0 (A1200)' loaded
ROM loader end
memory init end
No disk in drive 0.
JIT: &countdown =  0x1da4fcc
JIT: &build_comp = 0x373b79
JIT: Supposedly 42716 compileable opcodes!
CPU=68020, FPU=0, JIT=0. 24-bit
Stored port 1/1 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
--- New exception ---
JIT not in use.
Segmentation Fault
info.si_signo = 11
info.si_errno = 0
info.si_code = 1
info.si_addr = 0000000c
r0  = 0x01e45c28
r1  = 0x00000000
r2  = 0x00000000
r3  = 0x00003fe8
r4  = 0x00000000
r5  = 0x00003fe8
r6  = 0x00000000
r7  = 0x018f24c0
r8  = 0x01503d68
r9  = 0x00000001
r10 = 0x01e450e0
FP  = 0x0153e700
IP  = 0x00000000
SP  = 0xbe8e1370
LR  = 0x00176025
PC  = 0x00172a00
CPSR = 0x68000030
Fault Address = 0x0000000c
Trap no = 0x0000000e
Err Code = 0x00000017
Old Mask = 0x00000000
LR - 0x00176025: <(null)> (./amiberry-xu4-sdl2-dev)
Stack trace:
0x00146274 <(null) + 0x00146274> (./amiberry-xu4-sdl2-dev)
0xb695d270 <(null) + 0xb695d270> (/lib/arm-linux-gnueabihf/libc.so.6)
01: 0x01e450e0 <(null) + 0x01e450e0> (./amiberry-xu4-sdl2-dev)
Stack trace (non-dedicated):
./amiberry-xu4-sdl2-dev() [0x14634a]
/lib/arm-linux-gnueabihf/libc.so.6(+0x25270) [0xb695d270]
End of stack trace.
--- end exception ---
bspinner commented 6 years ago

So, the crash moved from sdl's library to libc.so... 😄 gdb output:

(gdb) r
Starting program: /home/retropie/amiberry/amiberry-xu4-sdl2-dev
Cannot parse expression `.L1185 4@r4'.
warning: Probes-based dynamic linker interface failed.
Reverting to original interface.

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[New Thread 0xb4b83450 (LWP 17690)]
[New Thread 0xb436d450 (LWP 17693)]
[New Thread 0xb2989450 (LWP 17695)]
[New Thread 0xb2189450 (LWP 17696)]
[New Thread 0xb1989450 (LWP 17697)]
[New Thread 0xb1189450 (LWP 17698)]
[New Thread 0xb0989450 (LWP 17699)]
[New Thread 0xb0189450 (LWP 17700)]
[New Thread 0xaf989450 (LWP 17701)]
[New Thread 0xaf189450 (LWP 17702)]
[New Thread 0xae989450 (LWP 17703)]
[New Thread 0xae189450 (LWP 17704)]
[New Thread 0xad989450 (LWP 17705)]
[New Thread 0xad189450 (LWP 17706)]
[New Thread 0xac90a450 (LWP 17707)]
[New Thread 0xab7ae450 (LWP 17709)]

Thread 1 "amiberry-xu4-sd" received signal SIGSEGV, Segmentation fault.
0x00172a00 in ?? ()
(gdb) backtrace
#0  0x00172a00 in ?? ()
#1  0x00176024 in ?? ()
#2  0x000ea6d4 in ?? ()
#3  0x00019ec6 in ?? ()
#4  0xb69b78aa in __libc_start_main (main=0x19d41, argc=1, argv=0xbefff604, init=<optimized out>, fini=0x38f275, rtld_fini=0xb6fe2c2d <_dl_fini>, stack_end=0xbefff604) at libc-start.c:291
#5  0x000219fc in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)
midwan commented 6 years ago

@bspinner Could you try experimenting with some of the compiler flags I changed lately, just in case? Try removing -frename-registers first. If that doesn't help, try changing -Ofast to -O2.

You'll need to do a make clean in between these tests to clear out any compiled objects.

bspinner commented 6 years ago

I've changed the noted below lines and recompiled by make clean && make -j8 PLATFORM=xu4-sdl2. Unfortunately it still crashes. But hey, the xu4 can handle -j8 without overheating/throttling... ;D

184 ifndef DEBUG
185     CFLAGS += -std=gnu++14 -O2
186 else

Crash seems to be the same:

Thread 1 "amiberry-xu4-sd" received signal SIGSEGV, Segmentation fault.
0x00104000 in ?? ()
(gdb) back
#0  0x00104000 in ?? ()
#1  0x0010706a in ?? ()
#2  0x000a6caa in ?? ()
#3  0x000a71f2 in ?? ()
#4  0x00019e42 in ?? ()
#5  0xb69b78aa in __libc_start_main (main=0x19cc9, argc=1, argv=0xbefff604, init=<optimized out>,
    fini=0x3014e5, rtld_fini=0xb6fe2c2d <_dl_fini>, stack_end=0xbefff604) at libc-start.c:291
#6  0x000218a0 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
midwan commented 6 years ago

@bspinner OK, thanks. You mentioned an earlier version still works? Which version is that (datestamp?). We could check what changes were committed since then and we'll eventually find what caused this.

bspinner commented 6 years ago

I don't know the commit hash, but binary's timestamp is Nov 11 01:23 (2017). Are you fluent in bash script so we can use git bisect run for this?

midwan commented 6 years ago

@bspinner Ouch, there's a lot of stuff added since November... I haven't used git bisect yet, but this seems like the perfect opportunity to learn about it. However, it's probably you who has to try it, since I cannot test it here anyway without a board. :-/

bspinner commented 6 years ago

@midwan hmm.. I think this will be straight forward.. I'll try myself to come up with a little hacky script :)

bspinner commented 6 years ago

@midwan Weeeell, bisect result is either d2c43c114 or 709244ad9 ... Huge commits. I'll investigate further in the next couple of days. My test script may be funky, so the error may still be elsewhere.

midwan commented 6 years ago

@bspinner Thanks for the help! I'll take a look at those from my side also.

midwan commented 6 years ago

@bspinner I don't think anything in 709244ad9 could have broken it, it's mostly corrections and GUI related stuff (which works for you). Probably something in the previous one then...

bspinner commented 6 years ago

Didn't have much time on my hands for this today. But at least I can be sure that the bug we're looking for didn't start at 709244a, since 949018a does start properly. I'll refine my test script.

bspinner commented 6 years ago

Unfortunately it's not that easy to create a proper test script due to the many changes made to the Makefile, UAE config structure etc.

@midwan I've started over with latest dev commit and this was the output

Thread 1 "amiberry-xu4-de" received signal SIGSEGV, Segmentation fault.
0x00202000 in save_host_fp_regs ()
(gdb) back
#0  0x00202000 in save_host_fp_regs ()
#1  0x00208c66 in m68k_go (may_quit=1) at src/newcpu.cpp:1769
#2  0x00113f42 in do_start_program () at src/main.cpp:624
#3  0x00113f8c in start_program () at src/main.cpp:637
#4  0x0011437a in real_main2 (argc=1, argv=0xbefff604) at src/main.cpp:759
#5  0x00114458 in real_main (argc=1, argv=0xbefff604) at src/main.cpp:775
#6  0x0017eed0 in main (argc=1, argv=0xbefff604) at src/osdep/amiberry.cpp:946

Made with make -j8 PLATFORM=xu4 WITH_LOGGING=1 DEBUG=1

log

Autoconfig board list:
Card 01: '<no name>' no autoconfig 00da0000 - 00daffff.
Card 02: '<no name>' no autoconfig 00600000 - 00a7ffff.
END
KS ver = 39 (0x27)
Stored port 1/1 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
Port1: COMBO 'Keyboard as Joystick [Default]' + 'JOY0' matched
Port0: NONE
Port2: NONE
Port3: NONE
Stored port 1/1 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
Autoconfig board list:
Card 01: '<no name>' no autoconfig 00da0000 - 00daffff.
Card 02: '<no name>' no autoconfig 00600000 - 00a7ffff.
END
KS ver = 39 (0x27)
Stored port 1/1 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
Port1: COMBO 'Keyboard as Joystick [Default]' + 'JOY0' matched
Port0: NONE
Port2: NONE
Port3: NONE
Stored port 1/1 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
mapped_malloc(): 0x00f00000 - 0x00f10000 (0x20f00000 - 0x20f10000) -> UAE Boot ROM (rtarea)
mapped_malloc(): 0x00f80000 - 0x01000000 (0x20f80000 - 0x21000000) -> Kickstart ROM (kick)
mapped_malloc(): 0x00000000 - 0x00200000 (0x20000000 - 0x20200000) -> Chip memory (chip)
ROM loader.. (<none>)
Known ROM 'KS ROM v3.0 (A1200)' loaded
ROM loader end
memory init end
JIT: &countdown =  0x2083e54
JIT: &build_comp = 0x580d55
JIT: Supposedly 43503 compileable opcodes!
CPU=68020, FPU=0, JIT=0. 24-bit
Stored port 1/1 d=0: added 100 0 Keyboard as Joystick [Default] JOY0
midwan commented 6 years ago

@bspinner Thanks, I think I know the problem then... :)

If it's what I think it is, it's related to the new FPU JIT code and specifically the part trying to save the registers. We are using assembly to do that, but perhaps that doesn't work on the XU4.

I'll update that part with C++ code instead to see if it works for you.

midwan commented 6 years ago

@bspinner I've made some changes regarding this, but since I don't have a XU4 board to test here, I'm not sure if they would help. The RPI runs fine with these changes.

I'm attaching a modified version of newcpu.cpp, could you place this into your src/ directory and recompile, then test it? newcpu.zip

bspinner commented 6 years ago

It works! Awesome 👍

So back to the actual content of this issue.. I'll test JIT now.

midwan commented 6 years ago

Excellent, I'll add that in the dev branch and it will get merged into master eventually.

I'll also follow a similar pattern for the other assembly functions, that might cause problems like this on other platforms.

bspinner commented 6 years ago

@midwan

Observations:

CPU=68020, FPU=0, JIT=CPU=16384. 24-bit
ROM loader.. (/home/retropie/RetroPie/BIOS/amiga-os-310-a4000.rom)
Known ROM 'KS ROM v3.0 (A1200)' loaded
ROM loader end
memory init end
Reset at 00092D64. Chipset mask = 00000007
Autoconfig board list:
Card 01: '<no name>' no autoconfig 00da0000 - 00daffff.
Card 02: '<no name>' no autoconfig 00600000 - 00a7ffff.
END
Card 0: skipping autoconfig (not autoconfig)
hardreset, memory cleared
Your Amiga program just did something terribly stupid 00F00CCE PC=000013E6
CPU halted: reason = 3 PC=000013e6
midwan commented 6 years ago

@bspinner Generally speaking, you shouldn't be using JIT with games and it may lead to instability, incorrect speed, and unexpected behavior. JIT is meant for desktop usage mostly. ;)

I'll have to test the same configuration on the RPI to see if it also fails, is that Lotus image available somewhere so I can test in the same (it could be related to that version also)?

Edit: Also, I noticed you're using an A4000 ROM with an A1200 config?

HoraceAndTheSpider commented 6 years ago

Except 3D games ;)

bspinner commented 6 years ago

@midwan

Lotus turbo challenge 2 aga version by Krypt.

A4000 Rom with a 1200 shouldn't be the case. I checked everything twice. Hm. I'll look into it when I'm at home.

ghost commented 6 years ago

Just a note, there is no AGA version of any Lotus games. That just means it's fixed to work on AGA machines.

bspinner commented 6 years ago

@ZappaUtopia Well, if we start nitpicking: actually those fixed games are AGA (compatible) versions. But yes, there are no official AGA versions with fancier graphics or anything alike by the original developer. :)

@midwan The results are the same with a clean A1200 configuration. Just recompiled latest develop with and without DEBUG-Flag. For whatever reason, the output without the flag produces more output regarding JIT (see amiberry_log.txt).

The H3 error mentioned in first post seems to be gone though. It's either crashing "in emulation" with a guru meditation (forgot to take note on the code...) or crashing the whole emulator.

midwan commented 6 years ago

@bspinner I just tried it on the Tinker board, using the following:

everything else defaults as set from the Quickstart (no JIT).

It seems to work fine on that board at least. No crashes, no H3 error.