anujdatar / box86-docker

Box86, the x86 emulator, running in a docker
MIT License
11 stars 1 forks source link

Problem with using box86 in docker container. #1

Closed Morritz closed 3 years ago

Morritz commented 3 years ago
0007|SIGSEGV @0x6d3eb524 (???(0x6d3eb524)) (x86pc=0x6d6c6d93//hlds/cstrike/dlls/cs.so:"/hlds/cstrike/dlls/cs.so/_Z14ServerActivateP7edict_sii + 234", esp=0x763cb0c0, stack=0x75bdc000:0x763dc000 own=(nil) fp=(nil)), for accessing (nil) (code=1/prot=0), db=0x64dc57e8(0x6d3eb4b8:0x6d3eb55c/0x6d6c6d7a:0x6d6c6d9b//hlds/cstrike/dlls/cs.so/_Z14ServerActivateP7edict_sii + 234:clean, hash:3c1c1c64/3c1c1c64)
0007|Double SIGSEGV (code=1, pc=0x6d3eb524, addr=(nil))!
Missing shutdown function for Sys_InitAuthentication() : Sys_ShutdownAuthentication()
Missing shutdown function for Host_Init( &host_parms ) : Host_Shutdown()
Missing shutdown function for Sys_InitLauncherInterface() : Sys_ShutdownLauncherInterface()
Missing shutdown function for Sys_InitMemory() : Sys_ShutdownMemory()
Missing shutdown function for Sys_Init() : Sys_Shutdown()
Missing shutdown function for FileSystem_Init(basedir, (void *)filesystemFactory) : FileSystem_Shutdown()
Missing shutdown function for Sys_InitArgv( m_OrigCmd ) : Sys_ShutdownArgv()

The binary crashes with such output. It works normally outside of the docker, the base image is debian:buster-slim and binary is run using box86 binary built from git repository.

Morritz commented 3 years ago

https://github.com/ptitSeb/box86/issues/435

anujdatar commented 3 years ago

Hi, did you figure out the problem? I have not used my docker image with Counter Strike yet, only TeamSpeak. But I have worked with x86 dockers of Counter Strike 1.6. Let me know if you want me to run some tests on my end. I would also need some information on your docker environment, i.e. what packages did you install, dependencies, etc.

anujdatar commented 3 years ago

Also, fyi, i renamed the docker image. The git repo is the same, but now you should do $ docker pull anujdatar/box86 instead of anujdatar/box86-docker the -docker seemed pretty redundant.. I will be pushing most recent builds to anujdatar/box86

Morritz commented 3 years ago

Also, fyi, i renamed the docker image. The git repo is the same, but now you should do $ docker pull anujdatar/box86 instead of anujdatar/box86-docker the -docker seemed pretty redundant.. I will be pushing most recent builds to anujdatar/box86

I once accidentally tried to use box86 without docker , but i had some error that , but if you say it is the latest i will use it

Morritz commented 3 years ago

If you want to reproduce this, i use this package https://drive.google.com/file/d/1GI74449IZyOlR-Kl1xWKCUPkJYXloFn-/view it is ripped rehlds from one of the hosting providers with amxmodx already installed. And i used it in the following way, your image as the base, then i use wget to download the package then unzip it, and run with the box86

anujdatar commented 3 years ago

I once accidentally tried to use box86 without docker , but i had some error that , but if you say it is the latest i will use it

ya, i named the image on docker-hub incorrectly, and forgot to change my github readme.

anujdatar commented 3 years ago

If you want to reproduce this, i use this package https://drive.google.com/file/d/1GI74449IZyOlR-Kl1xWKCUPkJYXloFn-/view it is ripped rehlds from one of the hosting providers with amxmodx already installed. And i used it in the following way, your image as the base, then i use wget to download the package then unzip it, and run with the box86

let me try basic CS 1.6 first. It is not too hard to install amxmodx afterwards. I wasn't sure a raspberry pi was powerful enough to run CS, so i never tried,

Here's my x86 CS1.6 docker that install everything from the source. icluding amxmodx. https://github.com/anujdatar/cstrike_docker

Morritz commented 3 years ago

Do you want me to use your docker and modify it to box86?

anujdatar commented 3 years ago

sure you could give it a try

Morritz commented 3 years ago

i think there might be some difficulties as the box86 docker is not installed in the system, so it doesnt recognize when x86 binary is about to be opened. And i think sh scripts will not be considered as x86

anujdatar commented 3 years ago

True. I think you'd have to update the start script to use the box86 binaries. Not the dockerfile CMD, that should probably still use the original ["sh", "-c", ".....whatever-we-had-here..."]

Morritz commented 3 years ago

True. I think you'd have to update the start script to use the box86 binaries. Not the dockerfile CMD, that should probably still use the original ["sh", "-c", ".....whatever-we-had-here..."]

although i see that box86 docker in interactive mode detects it correctly, so maybe i am wrong or it does not work in some cases, I tested rehlds again and it crashes after i run command map de_dust, when run as following ./hlds_linx -game cstrike.

Now I am about to try original hlds

Morritz commented 3 years ago

Steam is down ...

Morritz commented 3 years ago

Ok, so the original hlds doesn't crash. Although there is a problem that has to be resolved for the docker to be resilient, that I couldn't get it working properly on first run ( connection to steam errors) , but on second run it spinned up. I believe this is fixed by deleting some folders related to steam or something else. So if original hlds works i have suspicion that the rehlds uses some instructions that are not handled correctly by box86?

anujdatar commented 3 years ago

Steam is down ...

welp

Morritz commented 3 years ago

Also have you considered doing exagear docker? I think i will try using it with my rehlds package, it should not have such problems.

anujdatar commented 3 years ago

Ok, so the original hlds doesn't crash. Although there is a problem that has to be resolved for the docker to be resilient, that I couldn't get it working properly on first run ( connection to steam errors) , but on second run it spinned up. I believe this is fixed by deleting some folders related to steam or something else. So if original hlds works i have suspicion that the rehlds uses some instructions that are not handled correctly by box86?

oh, okay.. were you able to connect to the server and play?

Morritz commented 3 years ago

Ok, so the original hlds doesn't crash. Although there is a problem that has to be resolved for the docker to be resilient, that I couldn't get it working properly on first run ( connection to steam errors) , but on second run it spinned up. I believe this is fixed by deleting some folders related to steam or something else. So if original hlds works i have suspicion that the rehlds uses some instructions that are not handled correctly by box86?

oh, okay.. were you able to connect to the server and play?

i did not test connection yet, just that it was running, i can confirm it in in a minute

anujdatar commented 3 years ago

Also have you considered doing exagear docker? I think i will try using it with my rehlds package, it should not have such problems.

Exagear stopped developing their software a few years ago and also stopped giving out licenses for the same. Most exagear binaries out there need to be downloaded from peoples private google drives. From a security perspective, I'm not sure that is advisable.

Morritz commented 3 years ago

yep the original hlds works, so the problem only occurs with rehlds i have

anujdatar commented 3 years ago

I see, that's some good news. I am not familiar with rehlds, but did you try the official ReHLDS release? maybe you could try that before the modded version.

Morritz commented 3 years ago

Another news: I download rehlds newest files and copied over to the hlds directory, and run and it works. Now it is without amxmodx, so i wonder if installing amxmodx may make this sigsegv appear.

anujdatar commented 3 years ago

That's great news. Could be. Maybe amxmodx calls x86 functions in the background, that don't get piped through box86.

Morritz commented 3 years ago

but as i remember outside of docker my package worked, you can try it yourself to see if that really is.

Morritz commented 3 years ago

So it could be something related to the docker not being real system.

anujdatar commented 3 years ago

So it could be something related to the docker not being real system.

Ya, something is different for sure. Because when you install box86 on a regular system, the box86 binary is automatically invoked whenever you try to run an x86 application.

But in a docker container, you need to specifically tell it to use box86 to launch an x86 program

Morritz commented 3 years ago

So it could be something related to the docker not being real system.

Ya, something is different for sure. Because when you install box86 on a regular system, the box86 binary is automatically invoked whenever you try to run an x86 application.

But in a docker container, you need to specifically tell it to use box86 to launch an x86 program

But now in your docker using interactive mode i didnt not have to type box86 to launch anything, so ...

anujdatar commented 3 years ago

but as i remember outside of docker my package worked, you can try it yourself to see if that really is.

Sure, I'll try it out. I tried to quicklly modify my x86 docker image, but it turns out I had a lot of things going on. I did that over a year ago, and then my friends and I moved on to CS:GO after about 6 months. So I haven't looked at the code in a while. 😝

It wasn't as straight forward. Might be easier to test a container from scratch.

anujdatar commented 3 years ago

But now in your docker using interactive mode i didnt not have to type box86 to launch anything, so ...

aah, interesting. i never tried that.

anujdatar commented 3 years ago

would you be willing to share your dockerfiles? it's past midnight here, my mind's not fully here. I keep getting an elf errors and segfaults when trying to run original hlds.

Do you have hlds copied on your system, or are you fetching fresh binaries from akamai?

anujdatar commented 3 years ago

How did you download your original HLDS files? I seem to be having trouble with SteamCMD. Doesn't seem to like box86.

But now in your docker using interactive mode i didnt not have to type box86 to launch anything, so ...

Doesn't seem to work with TeamSpeak. It needs the box86 prefix. $ <path-to-box86> ts3server

Morritz commented 3 years ago

To run your docker container i use "docker run -it anujdatar/box86", then i am dropped in the shell and i can launch everything as in the normally installed raspberry. Maybe it uses the box86 from the system and not container ?, but the log says something different it displays different version from the one that i have on the real system.

Morritz commented 3 years ago

would you be willing to share your dockerfiles? it's past midnight here, my mind's not fully here. I keep getting an elf errors and segfaults when trying to run original hlds.

Do you have hlds copied on your system, or are you fetching fresh binaries from akamai?

Right now I am not tinkering with dockerfile, rather trying to do things in the shell, but i got hlds from the steamcmd, so from the steam directly

Morritz commented 3 years ago

Tried my package once again with newer rehlds files ver 3.10 and it showed error, i decided to disable metamod , so it doesnt load metamod dll but the cs.so and it doesnt crash this time.

anujdatar commented 3 years ago

To run your docker container i use "docker run -it anujdatar/box86", then i am dropped in the shell and i can launch everything as in the normally installed raspberry. Maybe it uses the box86 from the system and not container ?, but the log says something different it displays different version from the one that i have on the real system.

hmm.. which x86 application have you tried in the container this way? I have only tried teamspeak and steamcmd. both say cannot execute binary file: Exec format error if i try to launch them directly. at least temaspeak launches when i prepend it with box86

anujdatar commented 3 years ago

Tried my package once again with newer rehlds files ver 3.10 and it showed error, i decided to disable metamod , so it doesnt load metamod dll but the cs.so and it doesnt crash this time.

i see

Morritz commented 3 years ago

I am going to try to change metamod to some other version, it seems also to be metamod-p

anujdatar commented 3 years ago

Right now I am not tinkering with dockerfile, rather trying to do things in the shell, but i got hlds from the steamcmd, so from the steam directly

SteamCMD isn't working on my sustem, inside the docker at least. what commands are you using to download steamcmd and then hlds?

I am doing this

$ curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -

$ ./steamcmd.sh +login anonymous +force_install_dir /hlds +app_update 90 validate +quit || true

without box86 prepended i get

$ ./steamcmd.sh 

./steamcmd.sh: line 37: /root/Steam/linux32/steamcmd: cannot execute binary file: Exec format error

with box86

$ box86/build/box86 steamcmd.sh 

Box86 with Dynarec v0.2.3 ff365085 built on Aug  4 2021 20:28:52
Error: reading elf header of /root/Steam/steamcmd.sh, try to launch natively instead
Segmentation fault (core dumped)
Morritz commented 3 years ago

Do you have box86 also installed on the host? I replaced metamod-p with original metamod and now it doesnt crash anymore.

Morritz commented 3 years ago
root@a21ec8b0b819:/hlds# box86
Box86 with Dynarec v0.2.3 ff365085 built on Aug  4 2021 16:31:11

This is Box86, the Linux x86 emulator with a twist

Usage is box86 [options] path/to/software [args]
to launch x86 software
 options can be :
    '-v'|'--version' to print box86 version and quit
    '-h'|'--help'    to print box86 help and quit
You can also set some environment variables:
 BOX86_PATH is the box86 version of PATH (default is '.:bin')
 BOX86_LD_LIBRARY_PATH is the box86 version LD_LIBRARY_PATH (default is '.:lib')
 BOX86_LOG with 0/1/2/3 or NONE/INFO/DEBUG/DUMP to set the printed debug info (level 3 is level 2 + BOX86_DUMP)
 BOX86_DUMP with 0/1 to dump elf infos
 BOX86_NOBANNER with 0/1 to enable/disable the printing of box86 version and build at start
 BOX86_DYNAREC_LOG with 0/1/2/3 or NONE/INFO/DEBUG/DUMP to set the printed dynarec info
 BOX86_DYNAREC with 0/1 to disable or enable Dynarec (On by default)
 BOX86_NODYNAREC with address interval (0x1234-0x4567) to forbid dynablock creation in the interval specified
 BOX86_TRACE_FILE with FileName to redirect logs in a file (or stderr to use stderr instead of stdout) BOX86_DLSYM_ERROR with 1 to log dlsym errors
 BOX86_LOAD_ADDR=0xXXXXXX try to load at 0xXXXXXX main binary (if binary is a PIE)
 BOX86_NOSIGSEGV=1 to disable handling of SigSEGV
 BOX86_NOSIGILL=1  to disable handling of SigILL
 BOX86_X11THREADS=1 to call XInitThreads when loading X11 (for old Loki games with Loki_Compat lib) BOX86_LIBGL=libXXXX set the name (and optionnaly full path) for libGL.so.1
 BOX86_LD_PRELOAD=XXXX[:YYYYY] force loading XXXX (and YYYY...) libraries with the binary
 BOX86_ALLOWMISSINGLIBS with 1 to allow to continue even if a lib is missing (unadvised, will probably  crash later)
 BOX86_NOPULSE=1 to disable the loading of pulseaudio libs
 BOX86_NOGTK=1 to disable the loading of wrapped gtk libs
 BOX86_NOVULKAN=1 to disable the loading of wrapped vulkan libs
 BOX86_JITGDB with 1 to launch "gdb" when a segfault is trapped, attached to the offending process
root@a21ec8b0b819:/hlds#

This is my output in the docker container. Box86 is globally available.

Morritz commented 3 years ago

And that's how it is on the host.

root@DietPi:~# box86
Box86 with Dynarec v0.2.2 nogit built on Aug  3 2021 19:43:41

This is Box86, the Linux x86 emulator with a twist

Usage is box86 [options] path/to/software [args]
to launch x86 software
 options can be :
    '-v'|'--version' to print box86 version and quit
    '-h'|'--help'    to print box86 help and quit
You can also set some environment variables:
 BOX86_PATH is the box86 version of PATH (default is '.:bin')
 BOX86_LD_LIBRARY_PATH is the box86 version LD_LIBRARY_PATH (default is '.:lib')
 BOX86_LOG with 0/1/2/3 or NONE/INFO/DEBUG/DUMP to set the printed debug info
 BOX86_NOBANNER with 0/1 to enable/disable the printing of box86 version and build at start
 BOX86_DYNAREC_LOG with 0/1/2/3 or NONE/INFO/DEBUG/DUMP to set the printed dynarec info
 BOX86_DYNAREC with 0/1 to disable or enable Dynarec (On by default)
 BOX86_NODYNAREC with address interval (0x1234-0x4567) to forbid dynablock creation in the interval specified
 BOX86_TRACE_FILE with FileName to redirect logs in a file BOX86_DLSYM_ERROR with 1 to log dlsym errors
 BOX86_LOAD_ADDR=0xXXXXXX try to load at 0xXXXXXX main binary (if binary is a PIE)
 BOX86_NOSIGSEGV=1 to disable handling of SigSEGV
 BOX86_NOSIGILL=1  to disable handling of SigILL
 BOX86_X11THREADS=1 to call XInitThreads when loading X11 (for old Loki games with Loki_Compat lib) BOX86_LIBGL=libXXXX set the name (and optionnaly full path) for libGL.so.1
 BOX86_LD_PRELOAD=XXXX[:YYYYY] force loading XXXX (and YYYY...) libraries with the binary
 BOX86_ALLOWMISSINGLIBS with 1 to allow to continue even if a lib is missing (unadvised, will probably  crash later)
 BOX86_NOPULSE=1 to disable the loading of pulseaudio libs
 BOX86_NOGTK=1 to disable the loading of wrapped gtk libs
 BOX86_NOVULKAN=1 to disable the loading of wrapped vulkan libs
 BOX86_JITGDB with 1 to launch "gdb" when a segfault is trapped, attached to the offending process
root@DietPi:~#
Morritz commented 3 years ago
root@DietPi:~# docker ps -a
CONTAINER ID   IMAGE             COMMAND   CREATED       STATUS                            PORTS     NAMES
a21ec8b0b819   anujdatar/box86   "bash"    2 hours ago   Exited (127) About a minute ago             infallible_heyrovsky
root@DietPi:~#
anujdatar commented 3 years ago

no i don't have it installed locally. didn't think the local system would have anything to do with the container. i recently just wiped my sd card, so it is a fresh system with just docker, git and vim

Morritz commented 3 years ago

You could try if this has impact on this. I use dietpi and they have box86 listed under dietpi-software, so the installation process is fully automated.

anujdatar commented 3 years ago

ya, box86 is available globally in the docker container, but it refuses to run steamcmd for me

keep getting this

$ box86 steamcmd.sh 

Box86 with Dynarec v0.2.3 ff365085 built on Aug  4 2021 20:28:52
Error: reading elf header of /root/Steam/steamcmd.sh, try to launch natively instead
Segmentation fault (core dumped)

let me try to install box86 on the pi and see

anujdatar commented 3 years ago

You could try if this has impact on this. I use dietpi and they have box86 listed under dietpi-software, so the installation process is fully automated.

i see

Morritz commented 3 years ago

It must be connected to this I think obraz_2021-08-04_225316

Morritz commented 3 years ago

Docker does not have systemd, so it may share it with system maybe?

anujdatar commented 3 years ago

Yeah, you are right. Installing box86 on the base system fixed it. Ya, i found out about systemd the hard way a while ago. But it never occured to me that the base system needed box86 too.. especially when it worked out for TS3 without this.

Thanks

Morritz commented 3 years ago

What about using box86 on the files that are truly binary and not scripts? You have tried to run it on .sh file, but this file points to steamcmd_linux file that is the actual binary of steamcmd.