ptitSeb / box86

Box86 - Linux Userspace x86 Emulator with a twist, targeted at ARM Linux devices
https://box86.org
MIT License
3.38k stars 233 forks source link

Terraria triggers SIGSEGV in dynarec code #169

Open Icenowy opened 4 years ago

Icenowy commented 4 years ago
icenowy@ice-pbp [ Terraria ] $ coredumpctl gdb              
           PID: 36852 (Main)
           UID: 1000 (icenowy)
           GID: 1001 (aosc)
        Signal: 11 (SEGV)
     Timestamp: Wed 2020-08-05 13:16:23 CST (2min 8s ago)
  Command Line: /usr/bin/qemu-i386-static ./Terraria.bin.x86
    Executable: /usr/bin/qemu-i386-static
 Control Group: /user.slice/user-1000.slice/user@1000.service/apps-org.kde.konsole-c591140a496145f0bf2ed7d17a3f46db.scope
          Unit: user@1000.service
     User Unit: apps-org.kde.konsole-c591140a496145f0bf2ed7d17a3f46db.scope
         Slice: user-1000.slice
     Owner UID: 1000 (icenowy)
       Boot ID: c37dc18f1a984fcdb37dcf89f6378385
    Machine ID: 02941939da51b8a00892c7c25e1ee576
      Hostname: ice-pbp
       Storage: /var/lib/systemd/coredump/core.Main.1000.c37dc18f1a984fcdb37dcf89f6378385.36852.1596604583000000000000.lz4
       Message: Process 36852 (Main) of user 1000 dumped core.

                Stack trace of thread 36852:
                #0  0x0000000002958aac DBGetBlock (qemu-i386-static + 0x158aac)
                #1  0x00000000028e2cfc DynaRun (qemu-i386-static + 0xe2cfc)
                #2  0x00000000028cfc24 my___libc_start_main (qemu-i386-static + 0xcfc24)
                #3  0x00000000028eff0c iFEpippppp (qemu-i386-static + 0xeff0c)
                #4  0x00000000028d47d4 x86Int3 (qemu-i386-static + 0xd47d4)
                #5  0x00000000028a6d78 Run (qemu-i386-static + 0xa6d78)
                #6  0x0000000002858864 main (qemu-i386-static + 0x58864)
                #7  0x00000000f7587880 __libc_start_main (libc.so.6 + 0x17880)

GNU gdb (GDB) 8.3.1
Copyright (C) 2019 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 "aarch64-aosc-linux-gnu".
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 /usr/bin/qemu-i386-static...

warning: core file may not match specified executable file.
[New LWP 36852]
[New LWP 36853]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `/usr/bin/qemu-i386-static ./Terraria.bin.x86'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  DBGetBlock (emu=emu@entry=0x2fa79c8, addr=4120383144, create=create@entry=1, current=current@entry=0xffb44c50) at /home/icenowy/git-repos/box86/src/dynarec/dynablock.c:520
520             uint32_t hash = X31_hash_code(father->x86_addr, father->x86_size);
[Current thread is 1 (Thread 0xf7810010 (LWP 36852))]
(gdb) bt
#0  DBGetBlock (emu=emu@entry=0x2fa79c8, addr=4120383144, create=create@entry=1, current=current@entry=0xffb44c50) at /home/icenowy/git-repos/box86/src/dynarec/dynablock.c:520
#1  0x028e2cfc in DynaRun (emu=emu@entry=0x2fa79c8) at /home/icenowy/git-repos/box86/src/dynarec/dynarec.c:162
#2  0x028cfc24 in my___libc_start_main (emu=emu@entry=0x2fa79c8, main=0x8065fe0, argc=<optimized out>, ubp_av=<optimized out>, init=0x82dcd00, fini=0x82dcd70, rtld_fini=0x0, stack_end=0xf6af20cc)
    at /home/icenowy/git-repos/box86/src/emu/x86run_private.c:52
#3  0x028eff0c in iFEpippppp (emu=emu@entry=0x2fa79c8, fcn=fcn@entry=42793776) at /home/icenowy/git-repos/box86/src/wrapped/generated/wrapper.c:2927
#4  0x028d47d4 in x86Int3 (emu=0x2fa79c8) at /home/icenowy/git-repos/box86/src/emu/x86int3.c:254
#5  0x028a6d78 in Run (emu=0x2fa79c8, step=36852, step@entry=0) at /home/icenowy/git-repos/box86/src/emu/x86run.c:913
#6  0x02858864 in main (argc=<optimized out>, argv=<optimized out>, env=<optimized out>) at /home/icenowy/git-repos/box86/src/main.c:941
Icenowy commented 4 years ago

As I checked, the hash map of dynablocks consists the broken block, which makes the error to happen.

Icenowy commented 4 years ago

after fixing two SIGSEGVs by #172 , there's still SIGSEGV. I will investigate further.

ptitSeb commented 2 years ago

Terraria should works now on box86 (even if latest version are 64bits only now).

Can this ticket be closed?