ptitSeb / box64

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

Are there some ways to check the wrapped functions? #1645

Open Coekjan opened 2 months ago

Coekjan commented 2 months ago

I am now struggling with some weird bugs :disappointed:

My gui apps got stuck, and I saw the last wrapped functions these apps called are all calloc and from /usr/lib/libglib-2.0.so.0. The debug logs all looks like:

(( omitted ))
Calling Init for /usr/lib/libgobject-2.0.so.0 @0x3f4900c000
Done Init for /usr/lib/libgobject-2.0.so.0
Calling Init[0] for /usr/lib/libgobject-2.0.so.0 @0x3f4900f110
Calling Init[1] for /usr/lib/libgobject-2.0.so.0 @0x3f4900f040
222680|0x3f0d0b9383: Calling malloc(0x38, 0x7D0C7FFFE218, 0x1, ...) => return 0x3768A100
222680|0x3f0d0b9396: Calling pthread_rwlock_init(0x3768A100, 0x0, 0x1, ...) => return 0x0
(( omitted ))
222680|0x3f0d06334b: Calling realloc(0x3769D350, 0x200, 0x0, ...) => return 0x3769EC60
Run X86 (0x37051730), RIP=0x3f0d042dc4, Stack=0x7d0c7fffde98 is32bits=0
222680|0x3f0d06334b: Calling realloc(0x3769D460, 0x100, 0x0, ...) => return 0x3769D350
222680|0x3f0d043513: Calling memset(0x3769EBD0, 0x0, 0x80, ...) => return 0x3769EBD0
Run X86 (0x37051730), RIP=0x3f0d043523, Stack=0x7d0c7fffdeb8 is32bits=0
222680|0x3f0d063293: Calling calloc(0x1, 0x8, 0x0, ...) => return 0x3769BD10
(( !stuck! ))

Even the gdb could not stop the programs when they got stuck.


I am now suspecting the function wrapping and I also see calloc wrapping seems good. So what I am actually suspecting is that maybe some functions wrappings are bad and affect the future behavior of the programs.

I see all the wrapping seemed to be created manually, so if the wrapping is buggy, the function calling from one library to another library can be buggy - I can imagine how difficult to debug such wrapping issue...

Could you help me to debug this issue? Thanks in advance!