box86 icon indicating copy to clipboard operation
box86 copied to clipboard

[PPC] Steam segfaults in my_semctl

Open TheCodex6824 opened this issue 3 years ago • 4 comments

Using a powerpc64le system, trying to start Steam doesn't seem to make it very far, and it quickly segfaults in my_semctl:

Debug level is 1
BOX86_LD_LIBRARY_PATH: /usr/x86_64-multilib-linux-gnu/lib32/
Using default BOX86_PATH: ./:bin/
Counted 43 Env var
Looking for /home/user/.local/share/Steam/ubuntu12_32/steam
steam detected, forcing emulated libudev and gtk
Rename process to "steam"
Using native(wrapped) libdl.so.2
Using emulated /home/user/.local/share/Steam/ubuntu12_32/steam-runtime/usr/lib/i386-linux-gnu/libstdc++.so.6
Using native(wrapped) libpthread.so.0
Using native(wrapped) librt.so.1
Using native(wrapped) libX11.so.6
Using native(wrapped) libm.so.6
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux.so.2
Using emulated /home/user/.local/share/Steam/ubuntu12_32/steam-runtime/lib/i386-linux-gnu/libgcc_s.so.1
26498|SIGSEGV @0x62a64900 (my_semctl (/home/user/.local/share/Steam/ubuntu12_32/steam)) (x86pc=0x19f3f9b/???:"???", esp=0xf6eaf5ac), for accessing (nil) (code=1)
26498|Double SIGSEGV (code=1, pc=0x62a64900, addr=(nil))!

Full log is here. CMake options: -DPOWERPCLE=1 -DPOWER9=1 -DSYSV_VARARG=1, toolchain used: powerpcle-unknown-linux-gnu

TheCodex6824 avatar Oct 21 '22 23:10 TheCodex6824

I could not even get the app compiled.

I got lots of errors like this on Fedora 37:

/home/tle/Work/box86/src/wrapped/wrappedsdl2.c:693:5: note: in expansion of macro ‘PREPARE_VALIST’
  693 |     PREPARE_VALIST;
      |     ^~~~~~~~~~~~~~
/home/tle/Work/box86/src/include/myalign.h:7:15: error: request for member ‘overflow_arg_area’ in something not a structure or union
    7 |   sysv_varargs->overflow_arg_area=A;
      |               ^~
/home/tle/Work/box86/src/include/myalign.h:11:24: note: in expansion of macro ‘CREATE_SYSV_VALIST’
   11 | #define PREPARE_VALIST CREATE_SYSV_VALIST(emu->scratch)
      |                        ^~~~~~~~~~~~~~~~~~
/home/tle/Work/box86/src/wrapped/wrappedsdl2.c:693:5: note: in expansion of macro ‘PREPARE_VALIST’
  693 |     PREPARE_VALIST;
      |     ^~~~~~~~~~~~~~
/home/tle/Work/box86/src/wrapped/wrappedsdl2.c: In function ‘my2_SDL_Log’:
/home/tle/Work/box86/src/include/myalign.h:5:15: error: request for member ‘gpr’ in something not a structure or union
    5 |   sysv_varargs->gpr=8; \
      |               ^~
/home/tle/Work/box86/src/include/myalign.h:11:24: note: in expansion of macro ‘CREATE_SYSV_VALIST’
   11 | #define PREPARE_VALIST CREATE_SYSV_VALIST(emu->scratch)
      |                        ^~~~~~~~~~~~~~~~~~
/home/tle/Work/box86/src/wrapped/wrappedsdl2.c:705:5: note: in expansion of macro ‘PREPARE_VALIST’
  705 |     PREPARE_VALIST;
      |     ^~~~~~~~~~~~~~
/home/tle/Work/box86/src/include/myalign.h:6:15: error: request for member ‘fpr’ in something not a structure or union
    6 |   sysv_varargs->fpr=8; \
      |               ^~
/home/tle/Work/box86/src/include/myalign.h:11:24: note: in expansion of macro ‘CREATE_SYSV_VALIST’
   11 | #define PREPARE_VALIST CREATE_SYSV_VALIST(emu->scratch)
      |                        ^~~~~~~~~~~~~~~~~~
/home/tle/Work/box86/src/wrapped/wrappedsdl2.c:705:5: note: in expansion of macro ‘PREPARE_VALIST’
  705 |     PREPARE_VALIST;
      |     ^~~~~~~~~~~~~~
/home/tle/Work/box86/src/include/myalign.h:7:15: error: request for member ‘overflow_arg_area’ in something not a structure or union
    7 |   sysv_varargs->overflow_arg_area=A;
      |               ^~
/home/tle/Work/box86/src/include/myalign.h:11:24: note: in expansion of macro ‘CREATE_SYSV_VALIST’
   11 | #define PREPARE_VALIST CREATE_SYSV_VALIST(emu->scratch)
      |                        ^~~~~~~~~~~~~~~~~~
/home/tle/Work/box86/src/wrapped/wrappedsdl2.c:705:5: note: in expansion of macro ‘PREPARE_VALIST’
  705 |     PREPARE_VALIST;
      |     ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/box86.dir/build.make:922: CMakeFiles/box86.dir/src/wrapped/wrappedlibc.c.o] Error 1
make[2]: *** [CMakeFiles/box86.dir/build.make:1147: CMakeFiles/box86.dir/src/wrapped/wrappedsdl2.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:139: CMakeFiles/box86.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

Help is greatly appreciated

runlevel5 avatar Nov 18 '22 05:11 runlevel5

I did all of this on Gentoo, because I (correctly) figured I would be pretty much on my own in getting a 32-bit toolchain and libraries set up. While ppc64 seems fairly well supported on a lot of distros, ppc is often removed, and little-endian ppc is pretty much impossible to find any support for in any distro as far as I can tell.

I made a Fedora 37 VM to try compiling box86 there, but it looks like they dropped support for all 32-bit powerpc stuff, because things like glibc don't seem to be there anymore (did they make it x86 only?). How did you get the 32-bit environment set up on Fedora?

TheCodex6824 avatar Nov 18 '22 22:11 TheCodex6824

@TheCodex6824 that's exactly what I am trying to figure out. If I could find the answer, I will let you know

runlevel5 avatar Nov 20 '22 14:11 runlevel5

My bad, I thought that output was from running a 32-bit toolchain. You are probably going to have to compile gcc, binutils, and glibc yourself. I followed these instructions and it seemed to build properly, substituting architecture targets and such where needed. I say "build properly" because at least with whatever kernel my Fedora installation pulled in, CONFIG_COMPAT is unset, meaning 32-bit programs won't run. Other than that, the build process mostly went smoothly, except for 2 things:

  1. It seems that glibc uses some instructions that are only available in big-endian mode. I made a patch that at least allows it to compile, but you might want to check my ASM in case I did something stupid like counting the wrong way for the load/store addresses.
  2. Despite following directions, PATH_MAX seems to not be defined anywhere. This leads to libsanitizer failing to build, as well as box86 itself. For libsanitizer I just disabled building that by passing --disable-libsanitizer in the configure stage. For box86, I passed C_FLAGS=-DPATH_MAX=4096 to the make command. I'm not sure if that disables other flags, so you might need to put them back in.

TheCodex6824 avatar Nov 21 '22 03:11 TheCodex6824