ptitSeb / box64

Box64 - Linux Userspace x86_64 Emulator with a twist, targeted at ARM64 Linux devices
https://box86.org
MIT License
3.39k stars 239 forks source link

Dwarf Fortress 0.50.x Linux Compatibility #939

Open cocona20xx opened 10 months ago

cocona20xx commented 10 months ago

OS: Asahi Fedora Remix (pre-release) Hardware: Apple Silicon M1 Mac Mini (8 cores, 16gb ram) Log output upon crash:

[rin@2603-7000-da42-f100-32a5-f063-50d6-8706 dflinux]$ box64 dwarfort
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS PageSize:16384 Running on Icestorm Firestorm with 8 Cores
Params database has 25 entries
Box64 with Dynarec v0.2.4 45c4117a built on Aug 20 2023 00:36:40
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 77 Env var
Looking for dwarfort
Rename process to "dwarfort"
Using emulated libg_src_lib.so
Using native(wrapped) libSDL2-2.0.so.0
Using native(wrapped) libdl.so.2
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) libutil.so.1
Using native(wrapped) librt.so.1
Using native(wrapped) libm.so.6
Using native(wrapped) libSDL2_image-2.0.so.0
Using emulated libsteam_api.so
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using emulated ./libfmod_plugin.so
Using emulated libfmod.so.13
Loading audio...Audio loaded successfully!refreshProtection(0x37f88010): 0x37f88000/0x7 (ret=-1/Permission denied)
Strange SIGSEGV with Access error on 0x37f88010 for 0x37f88010, db=0x37f3efe0, prot=0x7 (old_addr=(nil))
refreshProtection(0x37f88010): 0x37f88000/0x7 (ret=-1/Permission denied)
refreshProtection(0x37f88010): 0x37f88000/0x7 (ret=-1/Permission denied)
Strange SIGSEGV with Access error on 0x37f88010 for 0x37f88010, db=0x37f3efe0, prot=0x7 (old_addr=0x37f88010)
9890|SIGSEGV @0x37f88010 (???(0x37f88010)) (x64pc=0x104bdc310//lib/x86_64-linux-gnu/libstdc++.so.6:"/lib/x86_64-linux-gnu/libstdc++.so.6 + 0x9c310", rsp=0x1046ee438, stack=0x103ef0000:0x1046f0000 own=(nil) fp=0x1), for accessing 0x37f88010 (code=2/prot=7), db=0x37f3efe0(0x37f88010:0x37f88088/0x104bdc310:0x104bdc316//lib/x86_64-linux-gnu/libstdc++.so.6 + 0x9c310:clean, hash:b5642473/b5642473) handler=(nil)
RAX:0x0000000000000001 RCX:0x0000000037ee0bb9 RDX:0x0000000000000000 RBX:0x00000001046ee968 
RSP:0x00000001046ee438 RBP:0x0000000000000001 RSI:0x0000000000000001 RDI:0x0000000037ecb8d0 
 R8:0x00000000ffffffff  R9:0x000000000000003a R10:0x00000001046ee700 R11:0x0000000037f25920 
R12:0x00000001046ee968 R13:0x00000001046ee8f0 R14:0x000000000000000d R15:0x00000001046ee810 
ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053 
RSP-0x20:0x00000001046ee900 RSP-0x18:0x00000001046eeb30 RSP-0x10:0x00000001046ee968 RSP-0x08:0x00000001046ee8f0
RSP+0x00:0x0000000104c09fe0 RSP+0x08:0x00000001046ee900 RSP+0x10:0x0000000104c4e313 RSP+0x18:0x00000001046eeb30
Segmentation fault (core dumped)

With this being a beta for the 0.50 release (the version present in the premium versions of DF on steam), it'd be nice to have some attention on this before the actual Linux release.

ptitSeb commented 10 months ago

I don't have that game on my steam collection, so cannot test / fix myself.

Can you try to run the game:

  1. Without dynarec, using BOX64_DYNAREC=0 to see if it's a dynarec issue.
  2. With some more tracing (with dynarec), incase it's a wrapping issue, using BOX64_ROLLING_LOG=1 BOX64_SHOWBT=1

Hopefully this will gives me more info on what is going on.

cocona20xx commented 10 months ago

With dynarec off:

[rin@2603-7000-da42-f100-32a5-f063-50d6-8706 dflinux]$ BOX64_DYNAREC=0 box64 dwarfort
Dynarec is off
Running on Icestorm Firestorm with 8 Cores
Params database has 25 entries
Box64 with Dynarec v0.2.4 45c4117a built on Aug 20 2023 00:36:40
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 77 Env var
Looking for dwarfort
Rename process to "dwarfort"
Using emulated libg_src_lib.so
Using native(wrapped) libSDL2-2.0.so.0
Using native(wrapped) libdl.so.2
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) libutil.so.1
Using native(wrapped) librt.so.1
Using native(wrapped) libm.so.6
Using native(wrapped) libSDL2_image-2.0.so.0
Using emulated libsteam_api.so
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using emulated ./libfmod_plugin.so
Using emulated libfmod.so.13
Loading audio...Audio loaded successfully!3312|SIGSEGV @0x3482b810 (???(dwarfort+0x3482b810)) (x64pc=0x40233/???:"???", rsp=0x1046eeb38, stack=0x103ef0000:0x1046f0000 own=(nil) fp=0x1046eebf0), for accessing 0x80 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0) handler=(nil)
RSP-0x20:0x000000010366ff60 RSP-0x18:0x000000010366ff88 RSP-0x10:0x000000006cb2f7d0 RSP-0x08:0x00000000000000ab
RSP+0x00:0x0000000104711330 RSP+0x08:0x000000010366ab58 RSP+0x10:0x000000010366ffc0 RSP+0x18:0x0000000103691ca8
RAX:0x0000ffff82e20020 RCX:0x00000001034528a0 RDX:0x0000000000000000 RBX:0x0000000000000001 
RSP:0x00000001046eeb38 RBP:0x00000001046eebf0 RSI:0x0000000000000000 RDI:0x00000001047445e0 
 R8:0x0000000104d5c720  R9:0x0000000104d4fe98 R10:0x0000000104d5c780 R11:0x00000000ffffffff 
R12:0x00000001046eec10 R13:0x0000000000000000 R14:0x0000000000000000 R15:0x0000000000000000 
ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053 
Segmentation fault (core dumped)

With dynarec enabled & the other flags set:

[rin@2603-7000-da42-f100-32a5-f063-50d6-8706 dflinux]$ BOX64_ROLLING_LOG=1 BOX64_SHOWBT=1 box64 dwarfort
Rolling log, showing last 16 function call on signals
Show a Backtrace when a Segfault signal is caught
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS PageSize:16384 Running on Icestorm Firestorm with 8 Cores
Params database has 25 entries
Box64 with Dynarec v0.2.4 45c4117a built on Aug 20 2023 00:36:40
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 77 Env var
Looking for dwarfort
Rename process to "dwarfort"
Using emulated libg_src_lib.so
Using native(wrapped) libSDL2-2.0.so.0
Using native(wrapped) libdl.so.2
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) libutil.so.1
Using native(wrapped) librt.so.1
Using native(wrapped) libm.so.6
Using native(wrapped) libSDL2_image-2.0.so.0
Using emulated libsteam_api.so
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using emulated ./libfmod_plugin.so
Using emulated libfmod.so.13
Loading audio...Audio loaded successfully!refreshProtection(0x68f38010): 0x68f38000/0x7 (ret=-1/Permission denied)
Strange SIGSEGV with Access error on 0x68f38010 for 0x68f38010, db=0xffffabcfbd78, prot=0x7 (old_addr=(nil))
refreshProtection(0x68f38010): 0x68f38000/0x7 (ret=-1/Permission denied)
refreshProtection(0x68f38010): 0x68f38000/0x7 (ret=-1/Permission denied)
Strange SIGSEGV with Access error on 0x68f38010 for 0x68f38010, db=0xffffabcfbd78, prot=0x7 (old_addr=0x68f38010)
Last calls
3918|0x104772ba2: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE7F0, 0x10479AEC8, 0xC, ...) => return 0x1
3918|0x104772642: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE7F0, 0x10479AED5, 0xD, ...) => return 0x1
3918|0x1047753c5: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE7F0, 0x10479AEE5, 0xA, ...) => return 0x1
3918|0x104772d0b: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE7F0, 0x10479AEF0, 0xD, ...) => return 0x1
3918|0x10477053d: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE7F0, 0x10479AF17, 0xD, ...) => return 0x1
3918|0x104770557: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE7F0, 0x10479B057, 0xD, ...) => return 0x1
3918|0x104770571: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE7F0, 0x10479AF25, 0xD, ...) => return 0x1
3918|0x1047736a9: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE7F0, 0x10479B160, 0xD, ...) => return 0x1
3918|0x1047705d0: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE7F0, 0x10479AF3C, 0xD, ...) => return 0x1
3918|0x1047705ea: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE7F0, 0x10479AF4D, 0xD, ...) => return 0xFFFFFFFFFFFFFFFF
3918|0x104c0a032: Calling fileno_unlocked (/lib64/libc.so.6)(0x68EBEF30, 0x68ECD560, 0x1FFF, ...) => return 0x8
3918|0x104c0a03f: Calling read (/lib64/libc.so.6)(0x8, 0x68ECD560, 0x1FFF, ...) => return 0x0
3918|0x10476fa34: Calling free (dwarfort)(0x68F12FA0, 0x17B, 0x100, ...) => return 0x17A
3918|PltResolver "_ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv" => return 0x17A
3918|PltResolver "_ZNSt13basic_filebufIcSt11char_traitsIcEE19_M_terminate_outputEv" => return 0x101
3918|0x104772b7c: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE7F0, 0x10479AEBA, 0xD, ...) => return 0x1
NativeBT: dwarfort() [0x34877a3c]
NativeBT: linux-vdso.so.1(__kernel_rt_sigreturn+0) [0xffffacf04800]
NativeBT: [0x68f38010]
EmulatedBT: /lib/x86_64-linux-gnu/libstdc++.so.6(_ZNSt13basic_filebufIcSt11char_traitsIcEE19_M_terminate_outputEv+4) [0x104c4b2a4]
EmulatedBT: ??? [0x1046eeb30]
EmulatedBT: libg_src_lib.so(main+7f) [0x10471133f]
EmulatedBT: ??? [0x30080]
EmulatedBT: /home/rin/Desktop/dflinux/dwarfort+1e4735 [0x1019e4735]
3918|SIGSEGV @0x68f38010 (???(0x68f38010)) (x64pc=0x104c4b2a4//lib/x86_64-linux-gnu/libstdc++.so.6:"/lib/x86_64-linux-gnu/libstdc++.so.6/_ZNSt13basic_filebufIcSt11char_traitsIcEE19_M_terminate_outputEv", rsp=0x1046ee448, stack=0x103ef0000:0x1046f0000 own=(nil) fp=0x1046eeb30), for accessing 0x68f38010 (code=2/prot=7), db=0xffffabcfbd78(0x68f38010:0x68f381b8/0x104c4b2a0:0x104c4b2fd//lib/x86_64-linux-gnu/libstdc++.so.6/_ZNSt13basic_filebufIcSt11char_traitsIcEE19_M_terminate_outputEv:clean, hash:1732f31c/1732f31c) handler=(nil)
RAX:0x0000000000000101 RCX:0x0000000068ece6d9 RDX:0x0000000000000100 RBX:0x00000001046ee900 
RSP:0x00000001046ee448 RBP:0x00000001046eeb30 RSI:0x000000000000017b RDI:0x00000001046ee900 
 R8:0x00000000ffffffff  R9:0x000000000000003a R10:0x00000001046ee700 R11:0x0000000068e339c0 
R12:0x00000001046ee968 R13:0x00000001046ee8f0 R14:0x000000000000000d R15:0x00000001046ee810 
ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053 
RSP-0x20:0x00000001046ee7d0 RSP-0x18:0x000000000000003a RSP-0x10:0x0000000068affc50 RSP-0x08:0x000000000000017d
RSP+0x00:0x0000000104c4e2b0 RSP+0x08:0x00000001046eeb30 RSP+0x10:0x00000001046ee900 RSP+0x18:0x0000000104d53df0
Segmentation fault (core dumped)
ptitSeb commented 10 months ago

Still unsure what's wrong there. I have changed a few things on symbol loading that might have helped a bit, can you retry with latest version of box64?

cocona20xx commented 10 months ago

with the latest version of box64 built from src:

w. default settings:

[rin@2603-7000-da42-f100-32a5-f063-50d6-8706 dflinux]$ box64 dwarfort
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS PageSize:16384 Running on Icestorm Firestorm with 8 Cores
Params database has 25 entries
Box64 with Dynarec v0.2.5 728ec2e7 built on Sep  2 2023 21:30:44
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 77 Env var
Looking for dwarfort
Rename process to "dwarfort"
Using emulated libg_src_lib.so
Using native(wrapped) libSDL2-2.0.so.0
Using native(wrapped) libdl.so.2
Using native(wrapped) libm.so.6
Using native(wrapped) librt.so.1
Using native(wrapped) libpthread.so.0
Using native(wrapped) libSDL2_image-2.0.so.0
Using emulated libsteam_api.so
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libutil.so.1
Using native(wrapped) libresolv.so.2
Using emulated ./libfmod_plugin.so
Using emulated libfmod.so.13
Loading audio...Audio loaded successfully!refreshProtection(0x759b4010): 0x759b4000/0x7 (ret=-1/Permission denied)
Strange SIGSEGV with Access error on 0x759b4010 for 0x759b4010, db=0xffffaf31a918, prot=0x7 (old_addr=(nil))
refreshProtection(0x759b4010): 0x759b4000/0x7 (ret=-1/Permission denied)
refreshProtection(0x759b4010): 0x759b4000/0x7 (ret=-1/Permission denied)
Strange SIGSEGV with Access error on 0x759b4010 for 0x759b4010, db=0xffffaf31a918, prot=0x7 (old_addr=0x759b4010)
10209|SIGSEGV @0x759b4010 (???(0x759b4010)) (x64pc=0x10476bc31/libg_src_lib.so:"libg_src_lib.so/_ZN6initst5beginEv + 737", rsp=0x1046ee4a0, stack=0x103ef0000:0x1046f0000 own=(nil) fp=0x1), for accessing 0x759b4010 (code=2/prot=7), db=0xffffaf31a918(0x759b4010:0x759b4120/0x10476bc31:0x10476bc7c/libg_src_lib.so/_ZN6initst5beginEv + 737:clean, hash:6f1ee25d/6f1ee25d) handler=(nil)
RAX:0x00000001046ee920 RCX:0x0000000075953b49 RDX:0x0000000000000000 RBX:0x0000000104d53df0 
RSP:0x00000001046ee4a0 RBP:0x00000001046eeb50 RSI:0x0000000000000001 RDI:0x0000ffffb0a4d570 
 R8:0x00000000ffffffff  R9:0x000000000000003a R10:0x00000001046ee720 R11:0x00000000758b8e30 
R12:0x00000001046ee7e0 R13:0x00000001046ee910 R14:0x000000000000000d R15:0x00000001046ee830 
ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053 
RSP-0x20:0x0000000104d53df0 RSP-0x18:0x00000001046eeb50 RSP-0x10:0x00000001046ee7e0 RSP-0x08:0x000000010476bc31
RSP+0x00:0x0000000000000000 RSP+0x08:0x0000000000000000 RSP+0x10:0x0000000000000000 RSP+0x18:0x0000000000000000
Segmentation fault (core dumped)

w. BOX64_DYNAREC=0

[rin@2603-7000-da42-f100-32a5-f063-50d6-8706 dflinux]$ BOX64_DYNAREC=0 box64 dwarfort
Dynarec is off
Running on Icestorm Firestorm with 8 Cores
Params database has 25 entries
Box64 with Dynarec v0.2.5 728ec2e7 built on Sep  2 2023 21:30:44
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 77 Env var
Looking for dwarfort
Rename process to "dwarfort"
Using emulated libg_src_lib.so
Using native(wrapped) libSDL2-2.0.so.0
Using native(wrapped) libdl.so.2
Using native(wrapped) libm.so.6
Using native(wrapped) librt.so.1
Using native(wrapped) libpthread.so.0
Using native(wrapped) libSDL2_image-2.0.so.0
Using emulated libsteam_api.so
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libutil.so.1
Using native(wrapped) libresolv.so.2
Using emulated ./libfmod_plugin.so
Using emulated libfmod.so.13
Loading audio...Audio loaded successfully!10880|SIGSEGV @0x3482b80c (???(dwarfort+0x3482b80c)) (x64pc=0x40233/???:"???", rsp=0x1046eeb58, stack=0x103ef0000:0x1046f0000 own=(nil) fp=0x1046eec10), for accessing 0x80 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0) handler=(nil)
RSP-0x20:0x000000010366ff60 RSP-0x18:0x000000010366ff88 RSP-0x10:0x000000004d1bf7b0 RSP-0x08:0x00000000000000ab
RSP+0x00:0x0000000104711330 RSP+0x08:0x000000010366ab58 RSP+0x10:0x000000010366ffc0 RSP+0x18:0x0000000103691ca8
RAX:0x0000ffffb2934020 RCX:0x00000001034528a0 RDX:0x0000000000000000 RBX:0x0000000000000001 
RSP:0x00000001046eeb58 RBP:0x00000001046eec10 RSI:0x0000000000000000 RDI:0x00000001047445e0 
 R8:0x0000000104d5c720  R9:0x0000000104d4fe98 R10:0x0000000104d5c780 R11:0x00000000ffffffff 
R12:0x00000001046eec30 R13:0x0000000000000000 R14:0x0000000000000000 R15:0x0000000000000000 
ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053 
Segmentation fault (core dumped)

w. BOX64_ROLLING_LOG=1 BOX64_SHOWBT=1:

[rin@2603-7000-da42-f100-32a5-f063-50d6-8706 dflinux]$ BOX64_ROLLING_LOG=1 BOX64_SHOWBT=1 box64 dwarfort
Rolling log, showing last 16 function call on signals
Show a Backtrace when a Segfault signal is caught
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS PageSize:16384 Running on Icestorm Firestorm with 8 Cores
Params database has 25 entries
Box64 with Dynarec v0.2.5 728ec2e7 built on Sep  2 2023 21:30:44
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 77 Env var
Looking for dwarfort
Rename process to "dwarfort"
Using emulated libg_src_lib.so
Using native(wrapped) libSDL2-2.0.so.0
Using native(wrapped) libdl.so.2
Using native(wrapped) libm.so.6
Using native(wrapped) librt.so.1
Using native(wrapped) libpthread.so.0
Using native(wrapped) libSDL2_image-2.0.so.0
Using emulated libsteam_api.so
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libutil.so.1
Using native(wrapped) libresolv.so.2
Using emulated ./libfmod_plugin.so
Using emulated libfmod.so.13
Loading audio...Audio loaded successfully!refreshProtection(0x45f78010): 0x45f78000/0x7 (ret=-1/Permission denied)
Strange SIGSEGV with Access error on 0x45f78010 for 0x45f78010, db=0xffffa94ba210, prot=0x7 (old_addr=(nil))
refreshProtection(0x45f78010): 0x45f78000/0x7 (ret=-1/Permission denied)
refreshProtection(0x45f78010): 0x45f78000/0x7 (ret=-1/Permission denied)
Strange SIGSEGV with Access error on 0x45f78010 for 0x45f78010, db=0xffffa94ba210, prot=0x7 (old_addr=0x45f78010)
Last calls
10928|0x104772642: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE810, 0x10479AED5, 0xD, ...) => return 0x1
10928|0x1047753c5: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE810, 0x10479AEE5, 0xA, ...) => return 0x1
10928|0x104772d0b: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE810, 0x10479AEF0, 0xD, ...) => return 0x1
10928|0x10477053d: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE810, 0x10479AF17, 0xD, ...) => return 0x1
10928|0x104770557: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE810, 0x10479B057, 0xD, ...) => return 0x1
10928|0x104770571: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE810, 0x10479AF25, 0xD, ...) => return 0x1
10928|0x1047736a9: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE810, 0x10479B160, 0xD, ...) => return 0x1
10928|0x1047705d0: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE810, 0x10479AF3C, 0xD, ...) => return 0x1
10928|0x1047705ea: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE810, 0x10479AF4D, 0xD, ...) => return 0xFFFFFFFFFFFFFFFF
10928|0x104c0a032: Calling fileno_unlocked (/lib64/libc.so.6)(0x45F05EA0, 0x45F144D0, 0x1FFF, ...) => return 0x8
10928|0x104c0a03f: Calling read (/lib64/libc.so.6)(0x8, 0x45F144D0, 0x1FFF, ...) => return 0x0
10928|0x10476fa34: Calling free (dwarfort)(0x45F53070, 0x17B, 0x100, ...) => return 0x17A
10928|PltResolver "_ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv" => return 0x17A
10928|PltResolver "_ZNSt13basic_filebufIcSt11char_traitsIcEE19_M_terminate_outputEv" => return 0x101
10928|PltResolver "_ZNSt13basic_filebufIcSt11char_traitsIcEE26_M_destroy_internal_bufferEv" => return 0x1
10928|0x104772ba2: Calling __memcmpeq (/lib64/libc.so.6)(0x1046EE810, 0x10479AEC8, 0xC, ...) => return 0x1
NativeBT: dwarfort() [0x34874478]
NativeBT: linux-vdso.so.1(__kernel_rt_sigreturn+0) [0xffffaad84800]
NativeBT: [0x45f78010]
EmulatedBT: /lib/x86_64-linux-gnu/libstdc++.so.6(_ZNSt13basic_filebufIcSt11char_traitsIcEE26_M_destroy_internal_bufferEv+4) [0x104c4b064]
EmulatedBT: ??? [0x1046eeb50]
10928|SIGSEGV @0x45f78010 (???(0x45f78010)) (x64pc=0x104c4b064//lib/x86_64-linux-gnu/libstdc++.so.6:"/lib/x86_64-linux-gnu/libstdc++.so.6/_ZNSt13basic_filebufIcSt11char_traitsIcEE26_M_destroy_internal_bufferEv", rsp=0x1046ee468, stack=0x103ef0000:0x1046f0000 own=(nil) fp=0x1), for accessing 0x45f78010 (code=2/prot=7), db=0xffffa94ba210(0x45f78010:0x45f78160/0x104c4b060:0x104c4b0c8//lib/x86_64-linux-gnu/libstdc++.so.6/_ZNSt13basic_filebufIcSt11char_traitsIcEE26_M_destroy_internal_bufferEv:clean, hash:41022368/41022368) handler=(nil)
RAX:0x0000000000000001 RCX:0x0000000045f15649 RDX:0x0000000000000100 RBX:0x00000001046ee920 
RSP:0x00000001046ee468 RBP:0x0000000000000001 RSI:0x000000000000017b RDI:0x00000001046ee920 
 R8:0x00000000ffffffff  R9:0x000000000000003a R10:0x00000001046ee720 R11:0x0000000045e7a930 
R12:0x00000001046ee988 R13:0x00000001046ee910 R14:0x000000000000000d R15:0x00000001046ee830 
ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053 
RSP-0x20:0x00000001046ee988 RSP-0x18:0x00000001046ee910 RSP-0x10:0x0000000045b44220 RSP-0x08:0x00000000000001a1
RSP+0x00:0x0000000104c4e2c8 RSP+0x08:0x00000001046eeb50 RSP+0x10:0x00000001046ee920 RSP+0x18:0x0000000104d53df0
Segmentation fault (core dumped)

w. BOX64_ROLLING_LOG=1 BOX64_SHOWBT=1 BOX64_DYNAREC=0 for good measure:

[rin@2603-7000-da42-f100-32a5-f063-50d6-8706 dflinux]$ BOX64_ROLLING_LOG=1 BOX64_SHOWBT=1 BOX64_DYNAREC=0 box64 dwarfort
Rolling log, showing last 16 function call on signals
Dynarec is off
Show a Backtrace when a Segfault signal is caught
Running on Icestorm Firestorm with 8 Cores
Params database has 25 entries
Box64 with Dynarec v0.2.5 728ec2e7 built on Sep  2 2023 21:30:44
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 77 Env var
Looking for dwarfort
Rename process to "dwarfort"
Using emulated libg_src_lib.so
Using native(wrapped) libSDL2-2.0.so.0
Using native(wrapped) libdl.so.2
Using native(wrapped) libm.so.6
Using native(wrapped) librt.so.1
Using native(wrapped) libpthread.so.0
Using native(wrapped) libSDL2_image-2.0.so.0
Using emulated libsteam_api.so
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libutil.so.1
Using native(wrapped) libresolv.so.2
Using emulated ./libfmod_plugin.so
Using emulated libfmod.so.13
Loading audio...Audio loaded successfully!Last calls
11069|0x30080: Calling my___cxa_atexit (dwarfort)(0x104BF9400, 0x103EEEBBD, 0x103416008, ...) => return 0x0
11069|0x30080: Calling my___cxa_atexit (dwarfort)(0x104BF9400, 0x103EEEBBE, 0x103416008, ...) => return 0x0
11069|0x30080: Calling my___cxa_atexit (dwarfort)(0x104BF9400, 0x103EEEBBF, 0x103416008, ...) => return 0x0
11069|0x30080: Calling my___cxa_atexit (dwarfort)(0x104BF9400, 0x103EEEBC0, 0x103416008, ...) => return 0x0
11069|0x30080: Calling my___cxa_atexit (dwarfort)(0x104BF9400, 0x103EEEBC1, 0x103416008, ...) => return 0x0
11069|0x30080: Calling my___cxa_atexit (dwarfort)(0x104BF9400, 0x103EEEBC2, 0x103416008, ...) => return 0x0
11069|0x30080: Calling my___cxa_atexit (dwarfort)(0x104BF9400, 0x103EEEBC3, 0x103416008, ...) => return 0x0
11069|PltResolver "setlocale" => return 0x0
11069|0x1047112f8: Calling setlocale (/lib64/libc.so.6)(0x6, 0x104799B13, 0x1046EEC40, ...) => return 0x4FA1C480
11069|PltResolver "SDL_Init" => return 0x4FA1C480
11069|0x104711302: Calling SDL_Init (/lib64/libSDL2-2.0.so.0)(0x1, 0x104799B13, 0x1046EEC40, ...) => return 0x0
11069|PltResolver "SDL_ThreadID" => return 0x0
11069|0x104711312: Calling SDL_ThreadID (/lib64/libSDL2-2.0.so.0)(0x1, 0x104799B13, 0x1046EEC40, ...) => return 0xFFFFA30F8020
11069|PltResolver "SDL_CreateThread" => return 0xFFFFA30F8020
11069|0x104711330: Calling my2_SDL_CreateThread (dwarfort)(0x1047445E0, 0x0, 0x0, ...) => return 
11069|0x30080: Calling my___cxa_atexit (dwarfort)(0x104BF9400, 0x103EEEBBC, 0x103416008, ...) => return 0x0
NativeBT: dwarfort() [0x34874478]
NativeBT: linux-vdso.so.1(__kernel_rt_sigreturn+0) [0xffffa3138800]
NativeBT: dwarfort() [0x3482b80c]
NativeBT: dwarfort() [0x34bfb448]
NativeBT: dwarfort() [0x34bfb7c0]
NativeBT: dwarfort() [0x34878ae4]
NativeBT: dwarfort(my2_SDL_CreateThread+0x38) [0x34b2f73c]
NativeBT: dwarfort() [0x3497dbd0]
NativeBT: dwarfort() [0x34848d1c]
NativeBT: dwarfort() [0x34bc3d4c]
NativeBT: dwarfort() [0x348346e8]
NativeBT: dwarfort(my___libc_start_main+0x300) [0x3484f8a4]
NativeBT: dwarfort() [0x349a5f10]
NativeBT: dwarfort() [0x34848d1c]
NativeBT: dwarfort() [0x34bc3d4c]
NativeBT: dwarfort() [0x34826df0]
NativeBT: /lib64/libc.so.6(+0x30598) [0xffffa2f30598]
NativeBT: /lib64/libc.so.6(__libc_start_main+0x9c) [0xffffa2f30670]
NativeBT: dwarfort(_start+0x30) [0x348212f0]
EmulatedBT: ??? [0x40220]
EmulatedBT: libg_src_lib.so(main+70) [0x104711330]
EmulatedBT: ??? [0x30080]
EmulatedBT: /home/rin/Desktop/dflinux/dwarfort+1e4735 [0x1019e4735]
11069|SIGSEGV @0x3482b80c (???(dwarfort+0x3482b80c)) (x64pc=0x40233/???:"???", rsp=0x1046eeb58, stack=0x103ef0000:0x1046f0000 own=(nil) fp=0x1046eec10), for accessing 0x80 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0) handler=(nil)
RSP-0x20:0x000000010366ff60 RSP-0x18:0x000000010366ff88 RSP-0x10:0x000000004f77d330 RSP-0x08:0x00000000000000ab
RSP+0x00:0x0000000104711330 RSP+0x08:0x000000010366ab58 RSP+0x10:0x000000010366ffc0 RSP+0x18:0x0000000103691ca8
RAX:0x0000ffffa30f8020 RCX:0x00000001034528a0 RDX:0x0000000000000000 RBX:0x0000000000000001 
RSP:0x00000001046eeb58 RBP:0x00000001046eec10 RSI:0x0000000000000000 RDI:0x00000001047445e0 
 R8:0x0000000104d5c720  R9:0x0000000104d4fe98 R10:0x0000000104d5c780 R11:0x00000000ffffffff 
R12:0x00000001046eec30 R13:0x0000000000000000 R14:0x0000000000000000 R15:0x0000000000000000 
ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053 
Segmentation fault (core dumped)
ptitSeb commented 10 months ago

Hey, can you try to build latest box64 from sources, but uncommenting line 33 of src/custommem.c so from

//#define USE_MMAP

to

#define USE_MMAP

And see if it improve the situation?

ptitSeb commented 9 months ago

Bah, don't bother with the change, I have just made it default now.

So you just need to update to latest box64 and try again (no source code changes needed).

seeschloss commented 9 months ago

It works for me, no SIGSEV, I do have another problem though, it doesn't crash but stops later at:

Error: PltResolver: Symbol SDL_SetSurfaceColorMod(ver 1: SDL_SetSurfaceColorMod) not found, cannot apply R_X86_64_JUMP_SLOT 0x105fb2630 (0x105f0ac60) in libg_src_lib.so
Full output here
[seeschloss@citropsis:df] box64 dwarfort
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS PageSize:16384 Running on Icestorm-M1-Pro Firestorm-M1-Pro with 8 Cores
Params database has 25 entries
Box64 with Dynarec v0.2.5 81e8ce49 built on Sep  9 2023 14:15:45
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 61 Env var
BOX64 try to Preload /usr/lib/libinput-config.so /usr/lib/libinput-config.so /usr/lib/libinput-config.so
Looking for dwarfort
Rename process to "dwarfort"
Warning, cannot pre-load of /usr/lib/libinput-config.so
Warning, cannot pre-load of /usr/lib/libinput-config.so
Warning, cannot pre-load of /usr/lib/libinput-config.so
Using emulated libg_src_lib.so
Using native(wrapped) libSDL2-2.0.so.0
Using native(wrapped) libdl.so.2
Using native(wrapped) libm.so.6
Using native(wrapped) librt.so.1
Using native(wrapped) libpthread.so.0
Using native(wrapped) libSDL2_image-2.0.so.0
Using emulated libsteam_api.so
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libutil.so.1
Using native(wrapped) libresolv.so.2
Using emulated ./libfmod_plugin.so
Using emulated libfmod.so.13
Loading audio...Audio loaded successfully!Loading bindings from prefs/interface.txt
Loading bindings from data/init/interface.txt
Broken unicode: [KEY:{]
Broken unicode: [KEY:|]
Broken unicode: [KEY:}]
Broken unicode: [KEY:~]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY: ]
Broken unicode: [KEY:¡]
Broken unicode: [KEY:¢]
Broken unicode: [KEY:£]
Broken unicode: [KEY:¤]
Broken unicode: [KEY:¥]
Broken unicode: [KEY:¦]
Broken unicode: [KEY:§]
Broken unicode: [KEY:¨]
Broken unicode: [KEY:©]
Broken unicode: [KEY:ª]
Broken unicode: [KEY:«]
Broken unicode: [KEY:¬]
Broken unicode: [KEY:­]
Broken unicode: [KEY:®]
Broken unicode: [KEY:¯]
Broken unicode: [KEY:°]
Broken unicode: [KEY:±]
Broken unicode: [KEY:²]
Broken unicode: [KEY:³]
Broken unicode: [KEY:´]
Broken unicode: [KEY:µ]
Broken unicode: [KEY:¶]
Broken unicode: [KEY:·]
Broken unicode: [KEY:¸]
Broken unicode: [KEY:¹]
Broken unicode: [KEY:º]
Broken unicode: [KEY:»]
Broken unicode: [KEY:¼]
Broken unicode: [KEY:½]
Broken unicode: [KEY:¾]
Broken unicode: [KEY:¿]
Broken unicode: [KEY:À]
Broken unicode: [KEY:Á]
Broken unicode: [KEY:Â]
Broken unicode: [KEY:Ã]
Broken unicode: [KEY:Ä]
Broken unicode: [KEY:Å]
Broken unicode: [KEY:Æ]
Broken unicode: [KEY:Ç]
Broken unicode: [KEY:È]
Broken unicode: [KEY:É]
Broken unicode: [KEY:Ê]
Broken unicode: [KEY:Ë]
Broken unicode: [KEY:Ì]
Broken unicode: [KEY:Í]
Broken unicode: [KEY:Î]
Broken unicode: [KEY:Ï]
Broken unicode: [KEY:Ð]
Broken unicode: [KEY:Ñ]
Broken unicode: [KEY:Ò]
Broken unicode: [KEY:Ó]
Broken unicode: [KEY:Ô]
Broken unicode: [KEY:Õ]
Broken unicode: [KEY:Ö]
Broken unicode: [KEY:×]
Broken unicode: [KEY:Ø]
Broken unicode: [KEY:Ù]
Broken unicode: [KEY:Ú]
Broken unicode: [KEY:Û]
Broken unicode: [KEY:Ü]
Broken unicode: [KEY:Ý]
Broken unicode: [KEY:Þ]
Broken unicode: [KEY:ß]
Broken unicode: [KEY:à]
Broken unicode: [KEY:á]
Broken unicode: [KEY:â]
Broken unicode: [KEY:ã]
Broken unicode: [KEY:ä]
Broken unicode: [KEY:å]
Broken unicode: [KEY:æ]
Broken unicode: [KEY:ç]
Broken unicode: [KEY:è]
Broken unicode: [KEY:é]
Broken unicode: [KEY:ê]
Broken unicode: [KEY:ë]
Broken unicode: [KEY:ì]
Broken unicode: [KEY:í]
Broken unicode: [KEY:î]
Broken unicode: [KEY:ï]
Broken unicode: [KEY:ð]
Broken unicode: [KEY:ñ]
Broken unicode: [KEY:ò]
Broken unicode: [KEY:ó]
Broken unicode: [KEY:ô]
Broken unicode: [KEY:õ]
Broken unicode: [KEY:ö]
Broken unicode: [KEY:÷]
Broken unicode: [KEY:ø]
Broken unicode: [KEY:ù]
Broken unicode: [KEY:ú]
Broken unicode: [KEY:û]
Broken unicode: [KEY:ü]
Broken unicode: [KEY:ý]
Broken unicode: [KEY:þ]
Broken unicode: [KEY:ÿ]
[S_API] SteamAPI_Init(): SteamAPI_IsSteamRunning() did not locate a running instance of Steam.
Using emulated /home/seeschloss/.local/share/Steam/linux64/steamclient.so
Warning: Weak Symbol _ITM_RU1 not found, cannot apply R_X86_64_JUMP_SLOT @0x108ba3fb8 (0x32a296)
Warning: Weak Symbol _ZGTtnam not found, cannot apply R_X86_64_JUMP_SLOT @0x108ba3fc0 (0x32a2a6)
Warning: Weak Symbol _ITM_memcpyRtWn not found, cannot apply R_X86_64_JUMP_SLOT @0x108ba3fc8 (0x32a2b6)
Warning: Weak Symbol _ITM_RU8 not found, cannot apply R_X86_64_JUMP_SLOT @0x108ba3fd0 (0x32a2c6)
[S_API] SteamAPI_Init(): Loaded '/home/seeschloss/.local/share/Steam/linux64/steamclient.so' OK.
[S_API FAIL] SteamAPI_Init() failed; create pipe failed.New window size: 1512x945
Font size: 8x12
Resizing grid to 189x78
Resizing font to 8x12

Error: PltResolver: Symbol SDL_SetSurfaceColorMod(ver 1: SDL_SetSurfaceColorMod) not found, cannot apply R_X86_64_JUMP_SLOT 0x105fb2630 (0x105f0ac60) in libg_src_lib.so
The "Broken unicode" lines are output by Dwarf Fortress.

I do have /usr/lib/libSDL2-2.0.so.0 which seems to provide SDL_SetSurfaceColorMod though, but I'm not sure if I should be looking for something else.

cocona20xx commented 9 months ago

having updated my install of box64 as well, I'm getting what is presumably the same crash, considering the log vomiting out a bunch of Broken unicode warnings...

[rin@2603-7000-da42-f100-32a5-f063-50d6-8706 build]$ cd ~/Desktop/dflinux
[rin@2603-7000-da42-f100-32a5-f063-50d6-8706 dflinux]$ box64 dwarfort
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS PageSize:16384 Running on Icestorm Firestorm with 8 Cores
Params database has 27 entries
Box64 with Dynarec v0.2.5 28dcd346 built on Sep 13 2023 17:38:36
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 77 Env var
Looking for dwarfort
Rename process to "dwarfort"
Using emulated libg_src_lib.so
Using native(wrapped) libSDL2-2.0.so.0
Using native(wrapped) libdl.so.2
Using native(wrapped) libm.so.6
Using native(wrapped) librt.so.1
Using native(wrapped) libpthread.so.0
Using native(wrapped) libSDL2_image-2.0.so.0
Using emulated libsteam_api.so
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libutil.so.1
Using native(wrapped) libresolv.so.2
Using emulated ./libfmod_plugin.so
Using emulated libfmod.so.13
Loading audio...Audio loaded successfully!Loading bindings from prefs/interface.txt
Loading bindings from data/init/interface.txt
Broken unicode: [KEY:{]
Broken unicode: [KEY:|]
Broken unicode: [KEY:}]
Broken unicode: [KEY:~]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:
Broken unicode: [KEY:]

notably, however, it doesn't actually list the cause of the crash; going to update to the recent beta build with its own crash handler code and see what that gives me

edit: behaves the exact same way as before.

seeschloss commented 9 months ago

I think the "Broken unicode" lines are... more or less normal. I think I remember already seeing them in the past, and they also happen when I run DF on an amd64 machine.

What's more surprising is that it stops there for you, though.

I have the exact same output with 0.50.9 and 0.50.10, by the way.

cocona20xx commented 9 months ago

Fyi @ptitSeb: 0.50.10's full release for both the freeware and premium versions of DF is out now (https://www.bay12games.com/dwarves/ for the former, steam/itchio for the latter ofc), so you dont need to own the steam version to play 0.50 on linux anymore! That should hopefully help with you debugging why it crashes?

ptitSeb commented 9 months ago

Ah yes good. I'll check that next week.

seeschloss commented 9 months ago

Well after adding these two functions (I just took inspiration from similar bug reports like #616), it works for me.

Performance is about the same as on my x86_64 machine but it's difficult to compare. Especially since I'm not home and I don't have an ARM64 machine with me here, so I've only tested it remotely through Xvnc for now.

cocona20xx commented 9 months ago

Can confirm that DF itself now works entirely as expected; DFHack (a very commonly used modding utility) does not—but that looks to be tied to using ARM64 versions of SDL2 via wrapper instead of any issues with box64 or DFHack directly, as it's all issues with the overlay GUIs. What are the commands required to set SDL2 and SDL2-image to run as emulated instead of native-via-wrapper again?

(For posterity, releases of DFHack can be found here: https://github.com/dfhack/dfhack/releases)

ptitSeb commented 9 months ago

Can confirm that DF itself now works entirely as expected; DFHack (a very commonly used modding utility) does not—but that looks to be tied to using ARM64 versions of SDL2 via wrapper instead of any issues with box64 or DFHack directly, as it's all issues with the overlay GUIs. What are the commands required to set SDL2 and SDL2-image to run as emulated instead of native-via-wrapper again?

You can use BOX64_EMULATED_LIBS=libSDL2-2.0.so.0:libSDL2_image-2.0.so.0 to have those 2 emulated instead of wrapped.

cocona20xx commented 9 months ago

Hm. Regardless of what's done with the library emulation, there's still some issues with DFHack; honestly since it depends so heavily on direct memory manipulation it wouldn't be too shocking if it's just not going to work under box64, since bugs like this haven't been reported elsewhere.

The console produces the following logs when running box64 dwarfort with DFHack installed:

[rin@2603-7000-da42-f100-32a5-f063-50d6-8706 ~]$ cd ~/Desktop/df50_10_linux_dfhack
[rin@2603-7000-da42-f100-32a5-f063-50d6-8706 df50_10_linux_dfhack]$ box64 dwarfort
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS PageSize:16384 Running on Icestorm Firestorm with 8 Cores
Params database has 27 entries
Box64 with Dynarec v0.2.5 b6633aa3 built on Sep 25 2023 15:49:29
Counted 77 Env var
BOX64 LIB PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/:/lib/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/
BOX64 BIN PATH: ./:bin/:/home/rin/.local/bin/:/home/rin/bin/:/usr/lib64/ccache/:/usr/local/bin/:/usr/bin/:/bin/:/usr/local/sbin/:/usr/sbin/:/sbin/
Looking for dwarfort
Rename process to "dwarfort"
Using emulated libg_src_lib.so
Using native(wrapped) libSDL2-2.0.so.0
Using native(wrapped) libdl.so.2
Using native(wrapped) libm.so.6
Using native(wrapped) librt.so.1
Using native(wrapped) libpthread.so.0
Using native(wrapped) libSDL2_image-2.0.so.0
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libutil.so.1
Using native(wrapped) libresolv.so.2
Using emulated ./libfmod_plugin.so
Using emulated libfmod.so.13
Loading audio...Audio loaded successfully!Loading bindings from prefs/interface.txt
Loading bindings from data/init/interface.txt
Broken unicode: [KEY:{]
Broken unicode: [KEY:|]
Broken unicode: [KEY:}]
Broken unicode: [KEY:~]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:]
Broken unicode: [KEY:
Broken unicode: [KEY:]
Broken unicode: [KEY:Can't load plugin stonesense
Loading script: dfhack-config/init/default.dfhack.init
Loading script: hack/init/dfhack.default.init
Loading script: hack/init/dfhack.keybindings.init
Loading script: hack/init/dfhack.tools.init
Could not enable plugin: overlay
Loading script: dfhack-config/init/dfhack.init
Loading script: dfhack-config/init/dfhack.control-panel-system.init
DFHack is ready. Have a nice day!
DFHack version 50.10-r1 (release) on x86_64
Type in '?' or 'help' for general help, 'ls' to see all commands.
Loading script: dfhack-config/init/default.onLoad.init
Loading script: hack/init/onLoad.default.init
Loading script: dfhack-config/init/onLoad.init
Loading script: dfhack-config/init/default.onMapLoad.init
Loading script: hack/init/onMapLoad.default.init
Loading script: dfhack-config/init/onMapLoad.init
Loading script: dfhack-config/init/onMapLoad.control-panel-new-fort.init
Loading script: dfhack-config/init/onMapLoad.control-panel-repeats.init
combined 1051 MEAT items from 37 stacks into 36
combined 297 PLANT items from 19 stacks into 13
combined 843 PLANT_GROWTH items from 55 stacks into 49

This goes on, but after this point it's entirely dfhack in-game console logs. Interestingly, the game cannot be properly quit when dfhack is installed by just closing the game window or quitting from the main menu, the terminal window (which dfhack is technically running in) must be closed instead. This does not happen without dfhack installed. Furthermore, the files stderr.log and stdout.log contain a bunch of other error logging and don't even show up when running 'vanilla' df. I've put the contents of those two files here due to their length.

It'd be entirely fair for you to not try and fix dfhack's missing graphical features and other oddities, considering such a fix likely being significantly more complicated than getting .50.x df to run properly, but I thought I'd post these here for posterity's sake anyways.

(Also, I'm going to change the name of this issue thread after I make this post to something along the lines of 'Dwarf Fortress 0.50.x compatibility' or something since it no longer SIGSEVs. Feel free to close it if this is as far as you want to work on the problem, and thanks for your hard work on box64!)

lethosor commented 9 months ago

Feel free to report that in the DFHack issue tracker. We would probably be interested in fixing at least the shutdown issue. I'm not sure what other issues you're referring to (the Broken unicode is a vanilla DF issue). stderr.log and stdout.log are created by DFHack so that part is expected as well.

seeschloss commented 9 months ago

Using dfhack, I've just had a crash on: Error: PltResolver: Symbol mbrtoc32(ver 7: mbrtoc32@GLIBC_2.16) not found, cannot apply R_X86_64_JUMP_SLOT 0x104cca750 (0x104694ea0) in hack/libdfhack.so

Might be easy to implement, but probably not as easy as the sdl functions I added before, as it already exists in src/wrapped/wrappedlibc_private.h but commented out, and with a "!" in the signature (//GOW(mbrtoc32, LFppL!)), that only ever appears in commented out functions (removing the comment confirms that it's more complicated than that...).

@ptitSeb I suppose this ! is related to something that's not yet supported by box64?

ptitSeb commented 9 months ago

@ptitSeb I suppose this ! is related to something that's not yet supported by box64?

The ! means it's a pointer to a structure that might need special care, or a callback. Need to chack the actual signature. I checked and the mbstate_t looks like it doesn't need wrapping, so you can replace ! with p.

seeschloss commented 9 months ago

Fumbled a bit with my commit, but anyway I found what was breaking dfhack's console.

seeschloss commented 9 months ago

Thanks @ptitSeb, now that I have enabled more logging I see the following message:

0x103e37045: Dynarec stopped because of Opcode F3 48 0F AE E9 48 2D FF 00 00 00 48 3D FF 00 ( => /lib/x86_64-linux-gnu/libgcc_s.so.1:_Unwind_RaiseException + 853)

I supposed implementing the opcode would be better for performance, but this is way over my head.

ptitSeb commented 9 months ago

Yeah, but that's an unsuported opcode for now, even on the interpreter. It's some "dead code" for now (branch of code never executed because the cpu flag doesn't have a certain bit enabled).

seeschloss commented 9 months ago

I see, in any case it runs well enough now.

In the DFHack issue (https://github.com/DFHack/dfhack/issues/3831) @lethosor mentions that a mprotect() call might be failing, all I can see is that it seems to be wrapped by box64 but do you have any lead as to why mprotect() might fail under box64?

ptitSeb commented 9 months ago

memory protection is tricky on box64. It's tracked and used as part of the dynarec. That being, said, mprotect have no more reason to fail under box64 then on native. You can temporary put some printf in the wrapped mprotect in case of error (i.e. ret==-1) to show the error message if you want.

seeschloss commented 9 months ago

So it was just a check on dfhack's part that seems to be somewhat wrong, it checks that memory is allocated contiguously for no obvious reason, and it's not the case when run through box64. Just disabling the check works, so I think the rest is on dfhack's side and the box64 side is finished now.

It works fine for me now, I don't know if @cocona20xx's problems have been fixed as well.

ptitSeb commented 9 months ago

So it was just a check on dfhack's part that seems to be somewhat wrong, it checks that memory is allocated contiguously for no obvious reason, and it's not the case when run through box64. Just disabling the check works, so I think the rest is on dfhack's side and the box64 side is finished now.

It works fine for me now, I don't know if @cocona20xx's problems have been fixed as well.

Can you point me to the piece of code that is doing this check? I would like box64 to behave as much as possible as native.

seeschloss commented 9 months ago

Here's the code I removed to make it run: https://github.com/seeschloss/dfhack/commit/5102b21af0087621882e80c40a35ac9da2e498b4

You can see the last few comments on the issue there, starting from https://github.com/DFHack/dfhack/issues/3831#issuecomment-1745020308, for more context.

lethosor commented 8 months ago

From looking at this on the DFHack side, I think part of the cause of that particular issue is that there are a lot of duplicated memory ranges. Here's a snippet of the output from one of our internal tools, which should match /proc/self/maps:

01a8c000-01aa0000 r-xp
01a8c000-01aa0000 r-xp
01aa0000-01bdc000 rwxp
01aa0000-01bdc000 rwxp
01bdc000-01be8000 r-xp
01bdc000-01be8000 r-xp
01be8000-02a04000 rwxp
01be8000-02a04000 rwxp

I think this should be pretty easy to work around on our end, but I am curious what's going on here.

For reference: the check on our end is to ensure that, if we patch memory that crosses range boundaries, those ranges are contiguous. i.e. we want to preemptively avoid a segfault from attempting to write 0x2000 bytes starting at 0x3ff0 if 0x4000-0x4fff are unmapped in the middle. In the case that's failing, we're only attempting to patch 8 bytes (a pointer), and since all of the ranges I've seen are aligned to at least 4096 bytes, an 8-byte-aligned 8-byte value shouldn't cross range boundaries, so I'm not still sure why our check for memory continuity would be triggering (but that's a problem for us to figure out).

baahb commented 3 weeks ago

trying to run from debian on a 64 bit arm device. running without emulated libSDL2 results in previously noted "Broken Unicode" errors.

root@localhost:~/DF/df_50_13_linux# box64 dwarfort Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory PageSize:4096 Running on Unknown CPU with 8 Cores Will use Hardware counter measured at 24.5 MHz emulating 3.1 GHz Params database has 74 entries Box64 with Dynarec v0.2.9 8b3cd230 built on Jun 11 2024 00:28:02 BOX64: Didn't detect 48bits of address space, considering it's 39bits Counted 29 Env var BOX64 LIB PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/:/lib/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/ BOX64 BIN PATH: ./:bin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/sbin/:/bin/ Looking for dwarfort Apply RC params for dwarfort Applying BOX64_EMULATED_LIBS=libSDL2-2.0.so.0 Rename process to "dwarfort" Using emulated libg_src_lib.so Using emulated /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 Using native(wrapped) libSDL2_image-2.0.so.0 Using native(wrapped) libasound.so.2 Using native(wrapped) libm.so.6 Using native(wrapped) libdl.so.2 Using native(wrapped) libpulse-simple.so.0 Using native(wrapped) libpulse.so.0 Using emulated /lib/x86_64-linux-gnu/libsndio.so.7.0 Using native(wrapped) libX11.so.6 Using native(wrapped) libxcb.so.1 Using native(wrapped) libXau.so.6 Using native(wrapped) libXdmcp.so.6 Using native(wrapped) libXext.so.6 Using native(wrapped) libXcursor.so.1 Using native(wrapped) libXfixes.so.3 Using native(wrapped) libXrender.so.1 Using native(wrapped) libXinerama.so.1 Using native(wrapped) libXi.so.6 Using native(wrapped) libXrandr.so.2 Using native(wrapped) libXss.so.1 Using native(wrapped) libXxf86vm.so.1 Using native(wrapped) libwayland-egl.so.1 Using native(wrapped) libwayland-client.so.0 Using native(wrapped) libwayland-cursor.so.0 Using native(wrapped) libxkbcommon.so.0 Using native(wrapped) libpthread.so.0 Using native(wrapped) librt.so.1 Using native(wrapped) libc.so.6 Using native(wrapped) ld-linux-x86-64.so.2 Using native(wrapped) libutil.so.1 Using native(wrapped) libresolv.so.2 Using native(wrapped) libbsd.so.0 Error: Global Symbol wl_list_insert_list not found, cannot apply R_X86_64_GLOB_DAT @0x3f01135608 ((nil)) in /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 Error: Global Symbol wl_list_init not found, cannot apply R_X86_64_GLOB_DAT @0x3f01135658 ((nil)) in /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 Error: Global Symbol wl_list_remove not found, cannot apply R_X86_64_GLOB_DAT @0x3f011357b8 ((nil)) in /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 Error: Global Symbol wl_log_set_handler_client not found, cannot apply R_X86_64_GLOB_DAT @0x3f011357e8 ((nil)) in /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 Error: Global Symbol wl_proxy_get_class not found, cannot apply R_X86_64_GLOB_DAT @0x3f011358b0 ((nil)) in /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 Error: Global Symbol wl_list_length not found, cannot apply R_X86_64_GLOB_DAT @0x3f011358d0 ((nil)) in /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 Error: Global Symbol wl_list_insert not found, cannot apply R_X86_64_GLOB_DAT @0x3f01135b18 ((nil)) in /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 Error: Global Symbol wl_list_empty not found, cannot apply R_X86_64_GLOB_DAT @0x3f01135cc8 ((nil)) in /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6 Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1 lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory Using emulated ./libfmod_plugin.so Using emulated libfmod.so.13 Loading audio...Audio loaded successfully!18049|SIGSEGV @0x745b8d5ee4 (???(/lib/aarch64-linux-gnu/libSDL2-2.0.so.0+0x98ee4)) (x64pc=0x1b0b00/???:"???", rsp=0x745c463308, stack=0x745bc64000:0x745c464000 own=(nil) fp=0x1), for accessing 0x40 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0) handler=(nil) RSP-0x20:0x0000003f0106bd1f RSP-0x18:0x0000000036cec440 RSP-0x10:0x0000003f0106bd1f RSP-0x08:0x000000745c463538 RSP+0x00:0x0000003f000e07a3 RSP+0x08:0x000000000000000d RSP+0x10:0x000000000219c080 RSP+0x18:0x0000000000000089 RAX:0x0000000000000080 RCX:0x00000000000000c0 RDX:0x00000000000000c0 RBX:0x000000000219c028 RSP:0x000000745c463308 RBP:0x0000000000000001 RSI:0x0000000036ce8370 RDI:0x0000000000000200 R8:0x00000000000001fc R9:0x0000000000000080 R10:0x00000000000000c0 R11:0x0000000000000080 R12:0x0000000000000000 R13:0x0000000036c7cd78 R14:0x0000000036c7cd70 R15:0x0000000036c78580 ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053 Segmentation fault note this is not DFHack, though i'm likely to try this next.