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

Segmentation Fault on start - Stardew Valley on Asahi Linux #1271

Open Ishimachi opened 4 months ago

Ishimachi commented 4 months ago

Unsure if this is an issue on Asahi Linux side or not, but whenever I try to run it I'm getting seg fault?

BOX64_SHOWSEGV=1 LD_LIBRARY_PATH="/home/ishimachi/GOG Games/Stardew Valley/game" box64.asahi '/home/ishimachi/GOG Games/Stardew Valley/game/Stardew Valley' Show Segfault signal even if a signal handler is present
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL SHA1 SHA2 USCAT FLAGM FLAGM2 FRINT PageSize:16384 Running on Blizzard-M2-Max Avalanche-M2-Max with 12 Cores
Params database has 38 entries
Box64 with Dynarec v0.2.6 nogit built on Jan 24 2024 00:00:00
BOX64: Detected 48bits at least of address space
Counted 52 Env var
BOX64 LIB PATH: /home/ishimachi/GOG Games/Stardew Valley/game/:/home/ishimachi/Downloads/box64/x64lib/:/home/ishimachi/Downloads/box64/x64lib/
BOX64 BIN PATH: ./:bin/:/home/ishimachi/.local/bin/:/home/ishimachi/bin/:/usr/lib64/ccache/:/usr/local/bin/:/usr/local/sbin/:/usr/bin/:/usr/sbin/:/home/ishimachi/.dotnet/tools/
Looking for /home/ishimachi/GOG Games/Stardew Valley/game/Stardew Valley
Rename process to "Stardew Valley"
Using native(wrapped) libpthread.so.0
Using native(wrapped) libdl.so.2
Using emulated libstdc++.so.6
Using native(wrapped) libm.so.6
Using emulated 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) librt.so.1
Using native(wrapped) libbsd.so.0
Warning: Global Symbol _ZN9__gnu_cxx21zoneinfo_dir_overrideEv not found, cannot apply R_X86_64_GLOB_DAT @0x7fff0024e268 ((nil)) in libstdc++.so.6
Using emulated /home/ishimachi/GOG Games/Stardew Valley/game/libhostfxr.so
Using emulated /home/ishimachi/GOG Games/Stardew Valley/game/libhostpolicy.so
Using emulated /home/ishimachi/GOG Games/Stardew Valley/game/libcoreclr.so
Warning: Global Symbol _ZTH12t_ThreadType not found, cannot apply R_X86_64_GLOB_DAT @0x7fff046a3110 ((nil)) in /home/ishimachi/GOG Games/Stardew Valley/game/libcoreclr.so
Warning: Global Symbol _ZTH27t_pStackWalkerWalkingThread not found, cannot apply R_X86_64_GLOB_DAT @0x7fff046a3128 ((nil)) in /home/ishimachi/GOG Games/Stardew Valley/game/libcoreclr.so
Warning: Global Symbol _ZTHN9StressLog19t_pCurrentThreadLogE not found, cannot apply R_X86_64_GLOB_DAT @0x7fff046a3148 ((nil)) in /home/ishimachi/GOG Games/Stardew Valley/game/libcoreclr.so
Warning: Global Symbol _ZTH15t_CantStopCount not found, cannot apply R_X86_64_GLOB_DAT @0x7fff046a3160 ((nil)) in /home/ishimachi/GOG Games/Stardew Valley/game/libcoreclr.so
Warning: Global Symbol _ZTH16t_CantAllocCount not found, cannot apply R_X86_64_GLOB_DAT @0x7fff046a3250 ((nil)) in /home/ishimachi/GOG Games/Stardew Valley/game/libcoreclr.so
Warning: Weak Symbol __gmon_start__ not found, cannot apply R_X86_64_JUMP_SLOT @0x7fff046a3650 (0x71e86)
Warning: Weak Symbol _ZTH12t_ThreadType not found, cannot apply R_X86_64_JUMP_SLOT @0x7fff046a36e8 (0x71fb6)
Warning: Weak Symbol _ZTH27t_pStackWalkerWalkingThread not found, cannot apply R_X86_64_JUMP_SLOT @0x7fff046a36f0 (0x71fc6)
Warning: Weak Symbol _ZTHN9StressLog19t_pCurrentThreadLogE not found, cannot apply R_X86_64_JUMP_SLOT @0x7fff046a3708 (0x71ff6)
Warning: Weak Symbol _ZTH15t_CantStopCount not found, cannot apply R_X86_64_JUMP_SLOT @0x7fff046a3710 (0x72006)
Warning: Weak Symbol _ZTH16t_CantAllocCount not found, cannot apply R_X86_64_JUMP_SLOT @0x7fff046a3778 (0x720d6)
Using emulated /home/ishimachi/GOG Games/Stardew Valley/game/libcoreclrtraceptprovider.so
Error loading needed lib liblttng-ust.so.0
Error loading one of needed lib
Error initializing needed lib /home/ishimachi/GOG Games/Stardew Valley/game/libcoreclrtraceptprovider.so
Error loading needed lib liblttng-ust-tracepoint.so.0
Warning: Cannot dlopen("liblttng-ust-tracepoint.so.0"/0x7fff04591e30, 102)
Error loading needed lib liblttng-ust-tracepoint.so.0
Warning: Cannot dlopen("liblttng-ust-tracepoint.so.0"/0x7fff04591e30, 102)
14787|SIGSEGV @0xfffee01a8490 (???(0xfffee01a8490)) (x64pc=0x7fff04178bce//home/ishimachi/GOG Games/Stardew Valley/game/libcoreclr.so:"/home/ishimachi/GOG Games/Stardew Valley/game/libcoreclr.so + 0x178bc0", rsp=0x100a2e760, stack=0x100230000:0x100a30000 own=(nil) fp=0x100a2e780), for accessing 0x8 (code=1/prot=0), db=0xfffee0db0828(0xfffee01a8458:0xfffee01a84e0/0x7fff04178bc0:0x7fff04178bcf//home/ishimachi/GOG Games/Stardew Valley/game/libcoreclr.so + 0x178bc0:clean, hash:a5c029d7/a5c029d7) handler=(nil)
RAX:0x0000000000000002 RCX:0x0000000000000003 RDX:0x0000000100a2ede8 RBX:0x00007fff0325a0b0 
RSP:0x0000000100a2e760 RBP:0x0000000100a2e760 RSI:0x00000000357ffc80 RDI:0x0000fffee10e2340 
 R8:0x0000000000000001  R9:0x0000000046c01ba8 R10:0x0000000000000001 R11:0x0000000000000000 
R12:0x0000000000000001 R13:0x0000000046c01b10 R14:0x0000000100a2e798 R15:0x00007fff030487a1 
ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053 
Segmentation fault (core dumped)

box64 works perfectly fine as I managed to get a different game working (amazing performance with it too) so unsure whats going on here?

I tried looking for dyn lib of liblttng-ust.so.0 and liblttng-ust-tracepoint.so.0 but couldn't find it anywhere. However, I saw some issue here where someone had a similar output on RISC-V and it worked for them regardless.

ksco commented 4 months ago

A related fix https://github.com/ptitSeb/box64/commit/f3d1ffbe0133a70fc210f04d4151637536d8ef8f was just pushed to main, can you pull the latest code and retry?

Ishimachi commented 4 months ago

A related fix f3d1ffb was just pushed to main, can you pull the latest code and retry?

Recompiled the lib and built it for M1 rather than installing box64.asahi on Asahi Linux and it looks worse, less output:

Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 USCAT FLAGM FLAGM2 FRINT PageSize:16384 Running on Blizzard-M2-Max Avalanche-M2-Max with 12 Cores
Params database has 58 entries
Using bash "/home/ishimachi/Downloads/box64/tests/bash"
Box64 with Dynarec v0.2.7 f09b541a built on Feb 21 2024 18:12:08
BOX64: Detected 48bits at least of address space
Counted 51 Env var
BOX64 LIB PATH: /home/ishimachi/Downloads/box64/x64lib/:/home/ishimachi/Downloads/box64/x64lib/:/lib/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/
BOX64 BIN PATH: ./:bin/:/home/ishimachi/.local/bin/:/home/ishimachi/bin/:/usr/lib64/ccache/:/usr/local/bin/:/usr/local/sbin/:/usr/bin/:/usr/sbin/:/home/ishimachi/.dotnet/tools/
Looking for /home/ishimachi/Downloads/box64/tests/bash
bash detected, disabling banner
Apply RC params for bash
Cannot create memory map (@0x100121000 0x17000/0xfff) for elf "/home/ishimachi/Downloads/box64/tests/bash" error=22/Invalid argument
Error: Loading elf /home/ishimachi/Downloads/box64/tests/bash

tested it with another game but that one works fine.

teohhanhui commented 3 months ago

box64 81ca016

When running:

$ BOX64_LOG=1 BOX64_ROLLING_LOG=1 BOX64_DLSYM_ERROR=1 BOX64_SHOWSEGV=1 BOX64_SHOWBT=1 BOX64_DYNAREC_LOG=3 box64 'Stardew Valley' &> 'Stardew Valley.log'

https://gist.github.com/teohhanhui/abd5c89efcd040e7d530481002f25f91

The main thing is:

Cannot create memory map (@0x7fff0305d000 0x2000/0xfff) for elf "/home/teohhanhui/.local/share/Steam/steamapps/common/Stardew Valley/libhostpolicy.so" error=22/Invalid argument Error: loading for elf /home/teohhanhui/.local/share/Steam/steamapps/common/Stardew Valley/libhostpolicy.so Failed to load /home/teohhanhui/.local/share/Steam/steamapps/common/Stardew Valley/libhostpolicy.so, error: Cannot dlopen("/home/teohhanhui/.local/share/Steam/steamapps/common/Stardew Valley/libhostpolicy.so"/0x44cbedd8, 1)

An error occurred while loading required library libhostpolicy.so from [/home/teohhanhui/.local/share/Steam/steamapps/common/Stardew Valley/]

KnedlikMCPE commented 3 months ago

I have the same issue. When I try replacing the libhostpolicy.so with one I found online, it just throws a generic memcpy segfault.

ptitSeb commented 3 months ago

I'll check soon, this game must works!

josch commented 3 months ago

I ran into what looks like the same segfault as OP with stardew valley 1.6.3:

1140107|SIGSEGV @0xffff6ab2c76c (???(0xffff6ab2c76c)) (x64pc=0x7fff04383af2//home/josch/Downloads/stardew16/data/noarch/game/libcoreclr.so:"/home/josch/Downloads/stardew16/data/noarch/game/libcoreclr.so + 0x383ae9", rsp=0x1264cd4c8, stack=0x125cd0000:0x1264d0000 own=0x125cd0000 fp=0x1264cd640), for accessing 0x10000000000 (code=1/prot=0), db=0xffff6ab14e50(0xffff6ab2c718:0xffff6ab2cd20/0x7fff04383ae9:0x7fff04383b96//home/josch/Downloads/stardew16/data/noarch/game/libcoreclr.so + 0x383ae9:clean, hash:4335ab57/4335ab57) handler=(nil)
RAX:0x00000000696c7730 RCX:0x00000001264ce2d8 RDX:0x0000000000000000 RBX:0x0000000103cdc130 
RSP:0x00000001264cd4c8 RBP:0x00000001264cd640 1140072|SIGSEGV @0xffff6ab2c78c (???(0xffff6ab2c78c)) (x64pc=0x7fff04383af2//home/josch/Downloads/stardew16/data/noarch/game/libcoreclr.so:"/home/josch/Downloads/stardew16/data/noarch/game/libcoreclr.so + 0x383ae9", rsp=0x10082ddd8, stack=0x100030000:0x100830000 own=(nil) fp=0x10082df50), for accessing 0xffff929e7c20 (code=2/prot=0), db=0xffff6ab14e50(0xffff6ab2c718:0xffff6ab2cd20/0x7fff04383ae9:0x7fff04383b96//home/josch/Downloads/stardew16/data/noarch/game/libcoreclr.so + 0x383ae9:clean, hash:4335ab57/4335ab57) handler=(nil)
RAX:0x000000005a4d57f0 RCX:0xffffffffffffffff RSI:0x0000010000000000 RDI:0x00000001264cd558 RDX:0x0000ffff92be0760 RBX:0x0000000000000000 
 R8:0x0000000000000000  R9:0x0000000103cde130 R10:0x00007fff0470b0e0 R11:0x0000000104159000 
R12:0x00007ffe8b1f9450 R13:0x0000000000000d87 R14:0x00007fff046bb008 R15:0x0000000000000000 
ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053 
RSP-0x20:0x0000000000000d87 RSP-0x18:0x00007fff046bb008 RSP-0x10:0x0000000000000000 RSP-0x08:0x00000001264cd640
RSP+0x00:0x00007fff04224e78 RSP+0x08:0x00007fff00000000 RSP+0x10:0x00000000696c7730
RSP:0x000000010082ddd8 RBP:0x000000010082df50 RSI:0x0000ffff929e7c20 RDI:0x000000010082de60 
 R8:0x0000000000000000  R9:0x000000010082db78 R10:0x00000000000000b5 R11:0x0000000102b0ee30 
R12:0x000000010082de60 R13:0x000000010082de20 R14:0x000000010082de30  RSP+0x18:0x00007fff04215820
R15:0x00007fff041de730 
ES:0x002b CS:0x0033 SS:0x002b ./StardewValley: line 27: 1140072 Segmentation fault      ./"Stardew Valley" $@

I've had these problems with versions of Stardew Valley before 1.6 as well but worked around it by running the windows version of Stardew Valley under box64 with wine. Unfortunately, Stardew Valley 1.6 doesn't work with my wine anymore, so I'm back at running the native Linux Version with box64.

For me, the game can work fine for three hours (as it did yesterday) but on other days (like today) it crashes multiple times with messages like the above. But there are other crash reasons:

1139600|Double SIGSEGV (code=1, pc=0xffff6d2c2c20, addr=0x6624046f0f66ff, prot=00)!
Sigfault/Segbus while quitting, exiting silently
1140065|Double SIGSEGV (code=1, pc=0xffff5a4ded60, addr=0x43f5000044d80028, prot=00)!
Sigfault/Segbus while quitting, exiting silently
1139720|SIGABRT @0xffffb0a80a10 (???(/lib/aarch64-linux-gnu/libc.so.6+0x80a10)) (x64pc=0x70093/???:"???", rsp=0x10082b548, stack=0x100030000:0x100830000 own=(nil) fp=0x10082b560), for accessing 0x3e800116408 (code=-6/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0) handler=(nil)
RSP-0x20:0x00007fff042d5279 RSP-0x18:0x00000000c0000005 RSP-0x10:0x0000000000000001 RSP-0x08:0x000000010082b560
RSP+0x00:0x00007fff045129fb RSP+0x08:0x0000000000000000 RSP+0x10:0x0000000000000001 RSP+0x18:0x000000010082b590
RAX:0x0000000000000000 RCX:0x0000000000000000 RDX:0x0000000000000000 RBX:0x0000000000000006 
RSP:0x000000010082b548 RBP:0x000000010082b560 RSI:0x00007fff047242b0 RDI:0x0000000000000006 
 R8:0x000000004b0a9800  R9:0x0000000000000000 R10:0x000000010082af36 R11:0x000000010082af3a 
R12:0x000000005c439c00 R13:0x00007fff042d5279 R14:0x00000000c0000005 R15:0x0000000000000001 
ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053 
./StardewValley: line 27: 1139720 Aborted                 ./"Stardew Valley" $@
ptitSeb commented 3 months ago

box64 still have some issue with elf loading on non-4k pagesize, like Asahi on mac. I plan to have a look at that soon-ish. This is probbaly a side-effect of that you have.

ptitSeb commented 3 months ago

I have updated stuffs in box64. I tried Stardexw Valley on a max M1 with Fedora Remix 39 and it's now starting fine. Can you update and try again?

teohhanhui commented 3 months ago

box64 3d21114

When running:

$ BOX64_LOG=1 BOX64_ROLLING_LOG=1 BOX64_DLSYM_ERROR=1 BOX64_SHOWSEGV=1 BOX64_SHOWBT=1 BOX64_DYNAREC_LOG=1 box64 'Stardew Valley' &> 'Stardew Valley.log'

https://gist.github.com/teohhanhui/3a6812b588c3fa9cf4d5c6949e1d4db2

ptitSeb commented 3 months ago

there is an unstability somewhere in the dynarec, so might need to run it again if it crashes. Appart from this, its working fine on my side (I didn't even installed libFAudio).

teohhanhui commented 2 months ago

For those who are using mods (SMAPI), you need to set SMAPI_NO_TERMINAL=true env var.

Setting SMAPI_USE_CURRENT_SHELL=true seems to cause the game to not launch. (I'm not certain about this, as SMAPI console's output would hide box64's output lol)

@ptitSeb Is there a way to escape the emulator / run something on the host? In this case, the SMAPI launcher is trying to run my current terminal, which is konsole.

ptitSeb commented 2 months ago

@ptitSeb Is there a way to escape the emulator / run something on the host? In this case, the SMAPI launcher is trying to run my current terminal, which is konsole.

Probably, but I'm not sure what you mean. What would you do if you were running native?

teohhanhui commented 2 months ago

Probably, but I'm not sure what you mean. What would you do if you were running native?

It's entirely possible that I'm misunderstanding the problem.

I think it's much easier if you try installing SMAPI using SMAPI's installer, and you'll see the first symptom of the problem: the chmod of the game files would fail, on this line:

https://github.com/Pathoschild/SMAPI/blob/d1bb94121d6d860305566abeca3140e3dfa9b0f3/src/SMAPI.Installer/InteractiveInstaller.cs#L408

If you complete the rest of the installation manually, and try to launch the game using SMAPI's launcher (replaced StardewValley script), then you'll encounter the problem I've mentioned above about the SMAPI console.

(All of the above with BOX64_BASH set to the x86_64 version of bash.)

ptitSeb commented 2 months ago

Mmm, that chmod should work. I guess some path is not resolved correctly. I'll try to have look at that later.