obhq / obliteration

Experimental PS4 emulator written in Rust for Windows, macOS and Linux
https://obliteration.net
MIT License
601 stars 17 forks source link

info!/warn!/error! crashing when called from a thread #734

Closed mikusp closed 4 months ago

mikusp commented 4 months ago

I'm observing some strange errors when a new thread created by the game hits a macro like info!:

PID 417668 stopped with signal 11
Thread 417668 registers:
rax: 0x7fc55d40c040      r8:  0x1
rbx: 0x7fc55d40ebc0      r9:  0x10
rcx: 0x8      r10: 0x7fc524000bb0
rdx: 0x1      r11: 0x464c20665b1a3a19
rsi: 0x7fc524000bb0      r12: 0x0
rdi: 0x7fc55d40d258      r13: 0x0
rbp: 0x7fc55d40ec20      r14: 0x0
rsp: 0x7fc55d40bdd0      r15: 0x1
fs:  0x0      rip: 0x648d14bf74b7
gs:  0x0      eflags: 0x10202

0x648d14bf74b7 : (alloc::alloc::Global::grow_impl::h95d640f49ed02cd6+0x7) [0x648d14bf74b7] [HOME/git/obliteration/src/target/debug/obkrnl+0x1da4b7]
0x648d14bf7ee0 : (_ZN63_$LT$alloc..alloc..Global$u20$as$u20$core..alloc..Allocato+0x2f) [0x648d14bf7ee0] [HOME/git/obliteration/src/target/debug/obkrnl+0x1daee0]
0x648d14bfffa4 : (alloc::raw_vec::finish_grow::h0e1949cd3b6859f5+0x394) [0x648d14bfffa4] [HOME/git/obliteration/src/target/debug/obkrnl+0x1e2fa4]
0x648d14c01009 : (_ZN5alloc7raw_vec19RawVec$LT$T$C$A$GT$14grow_amortized17hb3fb44+0x308) [0x648d14c01009] [HOME/git/obliteration/src/target/debug/obkrnl+0x1e4009]
0x648d14c012b8 : (_ZN5alloc7raw_vec19RawVec$LT$T$C$A$GT$7reserve21do_reserve_and_+0x17) [0x648d14c012b8] [HOME/git/obliteration/src/target/debug/obkrnl+0x1e42b8]
0x648d14bf549a : (alloc::vec::Vec<T,A>::reserve::ha20a3b12d5a15a70+0x7a) [0x648d14bf549a] [HOME/git/obliteration/src/target/debug/obkrnl+0x1d849a]
0x648d14bf4322 : (_ZN132_$LT$alloc..vec..Vec$LT$T$C$A$GT$$u20$as$u20$alloc..vec..+0xf1) [0x648d14bf4322] [HOME/git/obliteration/src/target/debug/obkrnl+0x1d7322]
0x648d14bf51ed : (_ZN5alloc3vec16Vec$LT$T$C$A$GT$17extend_from_slice17h5090191099+0x8c) [0x648d14bf51ed] [HOME/git/obliteration/src/target/debug/obkrnl+0x1d81ed]
0x648d14a61e18 : (_ZN3std2io5impls74_$LT$impl$u20$std..io..Write$u20$for$u20$allo+0x17) [0x648d14a61e18] [HOME/git/obliteration/src/target/debug/obkrnl+0x44e18]
0x648d14adaa67 : (_ZN59_$LT$termcolor..Ansi$LT$W$GT$$u20$as$u20$std..io..Write$GT+0x16) [0x648d14adaa67] [HOME/git/obliteration/src/target/debug/obkrnl+0xbda67]
0x648d14adfed1 : (termcolor::Ansi<W>::write_str::hfb1a39abfa48d202+0x21) [0x648d14adfed1] [HOME/git/obliteration/src/target/debug/obkrnl+0xc2ed1]
0x648d14adb28b : (termcolor::Ansi<W>::write_color::h93d3ddf24d66e65e+0x34b) [0x648d14adb28b] [HOME/git/obliteration/src/target/debug/obkrnl+0xbe28b]
0x648d14adadac : (_ZN66_$LT$termcolor..Ansi$LT$W$GT$$u20$as$u20$termcolor..WriteC+0x2eb) [0x648d14adadac] [HOME/git/obliteration/src/target/debug/obkrnl+0xbddac]
0x648d14ae0012 : (_ZN59_$LT$termcolor..Buffer$u20$as$u20$termcolor..WriteColor$GT+0x51) [0x648d14ae0012] [HOME/git/obliteration/src/target/debug/obkrnl+0xc3012]
0x7fc5580235bd : (sceKernelWaitSema+0x2d) [0x7fc5580235bd] [libkernel.sprx+0x235bd]
0x7fc52b401d3d : (+0x1d3d) [0x7fc52b401d3d] [libSceNpTus.sprx+0x1d3d]
0x7fc5580075c2 : (pthread_create_name_np+0x762) [0x7fc5580075c2] [libkernel.sprx+0x75c2]
0x648d14b61b56 : (_ZN63_$LT$obkrnl..ee..native..RawFn$u20$as$u20$obkrnl..ee..RawF+0x25) [0x648d14b61b56] [HOME/git/obliteration/src/target/debug/obkrnl+0x144b56]
ultimaweapon commented 4 months ago

One possibility is something wrong with the stack.

mikusp commented 4 months ago

I think you were right, seems that mmap with MAP_STACK expects a pointer to the end of the mapped area to be returned