ptitSeb / box64

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

Error when running MTA server on RISC-V via box64 #401

Open boosterl opened 2 years ago

boosterl commented 2 years ago

I was trying out box64 on a RISC-V SBC (a MangoPi MQ-Pro with an Allwinner D1 CPU). After successfully running a simple "Hello, world!"-style C program compiled for x86_64, I moved to something more difficult; running MTA server for x86_64. This however threw some errors which stopped the execution of the server:

$ ./mta-server64 
Box64 v0.1.9 742742f built on Sep  2 2022 11:43:07
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 23 Env var
Looking for ./mta-server64
Rename process to "mta-server64"
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) librt.so.1
Using emulated ./x64/core.so
Using native(wrapped) libncursesw.so.5
Using native(wrapped) libtinfo.so.5
Warning: Weak Symbol _ZGTtnam not found, cannot apply R_X86_64_JUMP_SLOT @0x3fb81c0018 (0x1d030)
Warning: Weak Symbol _ITM_RU1 not found, cannot apply R_X86_64_JUMP_SLOT @0x3fb81c0260 (0x1d4c0)
Warning: Weak Symbol _ITM_memcpyRtWn not found, cannot apply R_X86_64_JUMP_SLOT @0x3fb81c0430 (0x1d860)
Warning: Weak Symbol _ITM_RU8 not found, cannot apply R_X86_64_JUMP_SLOT @0x3fb81c07c8 (0x1df90)
Warning: Weak Symbol _ITM_memcpyRnWt not found, cannot apply R_X86_64_JUMP_SLOT @0x3fb81c08a8 (0x1e150)
Error: Symbol wprintw not found, cannot apply R_X86_64_JUMP_SLOT @0x3fb81c0950 (0x1e2a0) in ./x64/core.so
Warning: Weak Symbol _ZGTtdlPv not found, cannot apply R_X86_64_JUMP_SLOT @0x3fb81c0a38 (0x1e470)
Error: relocating Plt symbols in elf core.so
Error initializing needed lib core.so
Cannot dlopen("./x64/core.so"/0x3fb785b051, 2)

ERROR: Could not load ./x64/core.so
* Check installed data files.
Press enter to continue...
ptitSeb commented 2 years ago

It seems I'll need to wrap wprintw symbol. I'll do it later.

boosterl commented 1 year ago

@ptitSeb thanks for 43850ac85693d653251c17517a2843d7ff23a3d1. After this the software became functional! There does appear to be an issue whit ncurses. Running the software without ncurses just works. But when trying to run with ncurses (the default behavior), the program exits with corrupted size vs. prev_size. The full error log when running with BOX64_LOG=2:

Global LINES workaround, @0x3fbec5f60c <- 0x654d0b24
Global TABSIZE workaround, @0x3fbec5e1f0 <- 0x654d0b28
Global curscr workaround, @0x3fbec5f5e8 <- 0x654d0b30
Global newscr workaround, @0x3fbec5f5f0 <- 0x654d0b38
Global stdscr workaround, @0x3fbec5f290 <- 0x654d0b40
Global acs_map workaround, @0x3fbec5f2a0 <- 0x654d0b48
Global UP workaround, @0x3fbec5f6c8 <- 0x654d0f48
Global BC workaround, @0x3fbec5f6c0 <- 0x654d0f50
Global PC workaround, @0x3fbec5f7d8 <- 0x654d0f58
Global ospeed wor
karound, @0x3fbec5f7da <- 0x654d0f5a
Global ttytype workaround, @0x3fbec5f6d8 <- 0x654d0f60
return 0x931FB490
0261|0x3fbec882cd: Calling keypad (/usr/lib/libncursesw.so.5)(0x931FB490, 0x1, 0x3FBECFBB20, ...) =>0261|
SIGSEGV @(nil) (???((nil))) (x64pc=0xb0033/???:"???", rsp=0x3fbe281298), for accessing 0x2d0 (code=1)
Sigactionhanlder for signal #11 called (jump to 0x3fbeca9ad0/???(0x3fbeca9ad0))
0261|signal function handler 0x3fbeca9ad0 called, RSP=0x92fb1e58
Run X86 (0x92fb2230), RIP=0x3fbeca9ad0, Stack=0x92fb1e50
0261|0x3fbeca9b25: Calling my___pthread_mutex_lock (./mta-server64)(0x3FBECFCAC0, 0x3FE0961CD0, 0x92FB1E58, ...) => return 0x0
0261|0x3fbeca9b31: Calling my_sigaction (./mta-server64)(0xB, 0x0, 0x92FB1D78, ...) => return 0x0
0261|0x3fbeca9ccd: Calling sigemptyset (/usr/lib/libc.so.6)(0x92FB1D80, 0x0, 0x92FB1D78, ...) => return 0x0
0261|0x3fbeca9cd7: Calling sigaddset (/usr/lib/libc.so.6)(0x92FB1D80, 0xB, 0x92FB1D78, ...) => return 0x0
0261|0x3fbeca9cf9: Calling my_sigaction (./mta-server64)(0xB, 0x92FB1D78, 0x0, ...) => return 0x0
0261|0x3fbeca9d0a: Calling my_pthread_mutex_unlock (./mta-server64)(0x3FBECFCAC0, 0x92FB1D78, 0x0, ...) => return 0x0
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x92fb1e58, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Sigactionhanlder main function returned (exit=0, restorer=(nil))
0261|Double SIGSEGV (code=1, pc=(nil), addr=0x2d0)!
Calling atexit registered functions (exiting box64)
Calling atexit registered functions
Call cleanup #18
Run X86 (0x92fb2230), RIP=0x3fbeca8e70, Stack=0x3fbe281288
0261|0x3fbeca8e9f: Calling my___pthread_mutex_lock (./mta-server64)(0x3FBECFCAC0, 0x1, 0x3FBECFBB20, ...) => return 0x0
0261|0x3fbeca8ffd: Calling __libc_free (/usr/lib/libc.so.6)(0x931576B0, 0x18, 0x931576D8, ...) => return 0x0
0261|0x3fbeca9091: Calling
my_sigaction (./mta-server64)(0xB, 0x3FBECFCB40, 0x0, ...) => return 0x0
0261|0x3fbeca9091: Calling my_sigaction (./mta-server64)(0x6, 0x3FBECFCBD8, 0x0, ...) => return 0x0
0261|0x3fbeca9091: Calling my_sigaction (
./mta-server64)(0x8, 0x3FBECFCC70, 0x0, ...) => return 0x0
0261|0x3fbeca9091: Calling my_sigaction (./mta-server64)(0x4, 0x3FBECFCD08, 0x0, ...) => return 0x0
0261|0x3fbeca9091: Calling my_sigaction (./mta-server64)
(0x7, 0x3FBECFCDA0, 0x0, ...) => return 0x0
0261|0x3fbeca9091: Calling my_sigaction (./mta-server64)(0x5, 0x3FBECFCE38, 0x0, ...) => return 0x0
0261|0x3fbeca8f45: Calling my_pthread_mutex_unlock (./mta-server64)(0x3
FBECFCAC0, 0x3FBECFCE38, 0x0, ...) => return 0x0
0261|0x3fbeca8fa3: Calling __libc_free (/usr/lib/libc.so.6)(0x93157620, 0x3FBECFCE38, 0x0, ...) => return 0x3FBECFC098
0261|0x3fbeca8fb5: Calling __libc_free (/usr/li
b/libc.so.6)(0x93157580, 0x3FBECFCE38, 0x0, ...) => return 0x3FBECFC078
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #17
Run X86 (0x
92fb2230), RIP=0x3fbecc39d0, Stack=0x3fbe281288
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #16
Run X86 (0x92fb2230), RIP=0x3fbecc3
a10, Stack=0x3fbe281288
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #15
Run X86 (0x92fb2230), RIP=0x3fbeca2ed0, Stack=0x3fbe281288
0
261|0x300c0: Calling __libc_free (/usr/lib/libc.so.6)(0x931449C0, 0x1, 0x0, ...) => return 0x3FBECFA6A0
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->q
uit=1
Call cleanup #14
Run X86 (0x92fb2230), RIP=0x3fbec89e10, Stack=0x3fbe281288
0261|0x3fbec89e20: Calling my_pthread_mutex_destroy (./mta-server64)(0x93144990, 0x1, 0x0, ...) => return 0x0
0261|0x300c0: Calling __l
ibc_free (/usr/lib/libc.so.6)(0x93144990, 0x28, 0x0, ...) => return 0x0
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #13
Run X86 (0x
92fb2230), RIP=0x3fbeca2f40, Stack=0x3fbe281288
0261|0x3fbeca30a4: Calling __libc_free (/usr/lib/libc.so.6)(0x931447A0, 0x1, 0x93144768, ...) => return 0x93144768
0261|0x300c0: Calling __libc_free (/usr/lib/libc.so.
6)(0x93144750, 0x1, 0x93144768, ...) => return 0x93144768
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #12
Run X86 (0x92fb2230), RIP
=0x3fbec843b0, Stack=0x3fbe281288
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #11
Run X86 (0x92fb2230), RIP=0x3fbec843b0, Stack=0x3
fbe281288
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #10
Run X86 (0x92fb2230), RIP=0x3fbec843b0, Stack=0x3fbe281288
End of X86 run
(0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #9
Run X86 (0x92fb2230), RIP=0x3fbeca3620, Stack=0x3fbe281288
End of X86 run (0x92fb2230), RIP=0x300cb
, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #8
Run X86 (0x92fb2230), RIP=0x3fbec89e10, Stack=0x3fbe281288
0261|0x3fbec89e20: Calling my_pthread_mutex_destroy (./mta-server
64)(0x93143B30, 0x1, 0x93144768, ...) => return 0x0
0261|0x300c0: Calling __libc_free (/usr/lib/libc.so.6)(0x93143B30, 0x28, 0x93144768, ...) => return 0x0
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe28129
0, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #7
Run X86 (0x92fb2230), RIP=0x3fbec85300, Stack=0x3fbe281288
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0,
emu->uc_link=(nil), emu->quit=1
Call cleanup #6
Run X86 (0x92fb2230), RIP=0x3fbec85300, Stack=0x3fbe281288
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->
quit=1
Call cleanup #5
Run X86 (0x92fb2230), RIP=0x3fbec85300, Stack=0x3fbe281288
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #4
Run
X86 (0x92fb2230), RIP=0x3fbec843b0, Stack=0x3fbe281288
0261|0x300c0: Calling __libc_free (/usr/lib/libc.so.6)(0x93156C90, 0x1, 0x93144768, ...) => return 0x0
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281
290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #3
Run X86 (0x92fb2230), RIP=0x3fbec843b0, Stack=0x3fbe281288
0261|0x300c0: Calling __libc_free (/usr/lib/libc.so.6)(0x931570A0, 0x1, 0x93144768
, ...) => return 0x0
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #2
Run X86 (0x92fb2230), RIP=0x3fbe390460, Stack=0x3fbe281288
End o
f X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #1
Run X86 (0x92fb2230), RIP=0x3fbe3904a0, Stack=0x3fbe281288
End of X86 run (0x92fb2230), R
IP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Call cleanup #0
Run X86 (0x92fb2230), RIP=0x3fbe2f36f0, Stack=0x3fbe281288
...  =>PltResolver: Addr=0x92fb3240, Slot=66 Return=0x
3fbe35a873: elf is /home/booster/multitheftauto_linux_x64/mta-server64 (VerSym=0x587b8)
Apply Global R_X86_64_JUMP_SLOT 0x3fbe3cf8f0 with sym=fflush(ver 2: fflush@GLIBC_2.2.5) (0x3fbe2ee450 -> 0x50860 / (noelf))
return 0x3FBE3CC628
0261|0x3fbe35a873: Calling fflush (/usr/lib/libc.so.6)(0x3FBEF5E3F8, 0x1, 0x3FBE3D2CB4, ...) => return 0x0
0261|0x3fbe35a873: Calling fflush (/usr/lib/libc.so.6)(0x3FBEF5E318, 0x1, 0x3FBE3D2CB4, ...) => return 0x0
0261|0x3fbe35a873: Calling fflush (/usr/lib/libc.so.6)(0x3FBEF5E318, 0x1, 0x3FBE3D2CB4, ...) => return 0x0
0261|0x3fbe35cfc3: Calling fflush (/usr/lib/libc.so.6)(0x3FBEF5E3F8, 0x1, 0x3FBE3D2CB4, ...) => return 0x0
0261|0x3fbe35cfc3: Calling fflush (/usr/lib/libc.so.6)(0x3FBEF5E318, 0x1, 0x3FBE3D2CB4, ...) => return 0x0
0261|0x3fbe35cfc3: Calling fflush (/usr/lib/libc.so.6)(0x3FBEF5E318, 0x1, 0x3FBE3D2CB4, ...) => return 0x0
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Calling fini for all loaded elfs and unload native libs
Calling Fini[0] for /home/booster/multitheftauto_linux_x64/mta-server64 @0x3fbe2f1e80
Run X86 (0x92fb2230), RIP=0x3fbe2f1e80, Stack=0x3fbe281288
0261|0x3fbe2f1ea7: Calling my___cxa_finalize (./mta-server64)(0x3FBE3D0008, 0x1, 0x3FBE3D2CB4, ...) =>Calling atexit registered functions for 0x3fbe3d0008 mask
return 0x3FBE3D09E0
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Calling Fini for /home/booster/multitheftauto_linux_x64/mta-server64 @0x3fbe3955e8
Run X86 (0x92fb2230), RIP=0x3fbe3955e8, Stack=0x3fbe281288
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Closing 1 libs from maplib 0x92fb1630
Free core.so
Calling Fini[0] for ./x64/core.so @0x3fbec82c90
Run X86 (0x92fb2230), RIP=0x3fbec82c90, Stack=0x3fbe281288
0261|0x3fbec82cb7: Calling my___cxa_finalize (./mta-server64)(0x3FBECFBB20, 0x1, 0x3FBE3D2CB4, ...) =>Calling atexit registered functions for 0x3fbecfbb20 mask
return 0x3FBE3D0170
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Calling Fini for ./x64/core.so @0x3fbecdb6d4
Run X86 (0x92fb2230), RIP=0x3fbecdb6d4, Stack=0x3fbe281288
End of X86 run (0x92fb2230), RIP=0x300cb, Stack=0x3fbe281290, unimp=0, emu->fork=0, emu->uc_link=(nil), emu->quit=1
Closing 7 libs from maplib 0x92fa08d0
Free libncursesw.so.5
Free libtinfo.so.5
Free libdl.so.2
Free libc.so.6
Free librt.so.1
Free libpthread.so.0
Free ld-linux-x86-64.so.2
Waiting for all threads to finish before unloading box64context
0261|Free a X86_64 Emu (0x92fb2230)
corrupted size vs. prev_size
Aborted
paulwratt commented 1 year ago

I was trying out box64 on a RISC-V SBC (a MangoPi MQ-Pro with an Allwinner D1 CPU).

thanks for looking into this @boosterl , saved me some headaches :) when I finally get around to turning it on ..