-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MIT-SHM error solutions #359
Comments
Another possibility to avoid MIT-SHM error is to disable the extension in Xorg.
Though, this may cause a performance loss for all GUI applications (including those from host) as the shared memory provided by the |
Faking Open a shell Inside the container, create a #include <X11/Xlib.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
Bool XShmQueryExtension(Display *display) {
return 0;
} Install $ gcc docker_xnoshm.c -shared -o docker_xnoshm.so
$ export LD_PRELOAD=$(realpath docker_xnoshm.so)
$ your_application_here Bonus: Dockerfile recipe#####################
# BUILD XNOSHM HACK #
#####################
# See: https://github.com/jessfraz/dockerfiles/issues/359#issuecomment-828714848
FROM docker.io/library/alpine:3.13 AS docker_xnoshm
RUN apk add --no-cache gcc musl-dev libxext-dev
COPY docker_xnoshm.c /
RUN gcc /docker_xnoshm.c -shared -nostdlib -o /docker_xnoshm.so
################################################################################
# Use the image you want here
FROM docker.io/library/debian:buster
#######################
# INSTALL XNOSHM HACK #
#######################
COPY --from=docker_xnoshm /docker_xnoshm.so /usr/lib/docker_xnoshm.so
ENV LD_PRELOAD="/usr/lib/docker_xnoshm.so"
# ... |
Another way that I've found that has a different set of tradeoffs is using an untrusted X11 cookie (NOTE: This is how The backdraw of this method is that performance is worse (due to disabled extensions) and some applications depend on X11 extensions so they just don't work. Simple demo: truncate -s0 /tmp/untrusted_cookie
xauth -f /tmp/untrusted_cookie generate "$DISPLAY" MIT-MAGIC-COOKIE-1 untrusted
untrusted_cookie_data=$(XAUTHORITY=/tmp/untrusted_cookie xauth list "$DISPLAY" | awk '{print $NF}')
truncate -s0 /tmp/untrusted_cookie_fixhost
xauth -f /tmp/untrusted_cookie_fixhost add somehostname/unix"$DISPLAY" MIT-MAGIC-COOKIE-1 "$untrusted_cookie_data"
docker run --hostname somehostname \
-v /tmp/untrusted_cookie_fixhost:/root/.Xauthority \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY="$DISPLAY" \
-e XAUTHORITY=/root/.Xauthority \
-it alpine:3.13 sh -c 'apk add xeyes && xeyes' NOTE: You shouldn't stuff like |
@joanbm I have tried your I've compiled the script as you suggested, but still get MIT-SHM errors with some applications.
Do you have an idea what might be wrong? |
@mviereck Just as a sanity check that the library is loading correctly, can you confirm that DBeaver / Spicy do never throw a MIT-SHM error when using The reason Interestingly while looking around GitHub, I found the following code on GitHub which is a more robust version of the Can you try to use this code in place of
EDIT1: Also, change the Otherwise, it would be great to know which application(s) are failing, to find out how they are still detecting MIT-SHM support. |
Thank you very much @joanbm ! The extended MIT-SHM hack along with the finetuning added with your post edits solved all issues! |
@mviereck Hi,sorry to bother you here,I meet the same error when I try to run the orb slam2 in my container like below: |
@Hezhexi2002 It'd likely be better if you set up your container using a Dockerfile and/or volumes so you can re-create it quickly. But otherwise... The Otherwise, you should be able to 'add' |
@Hezhexi2002 As @joanbm pointed out, you can use his solution. You could compile within the container, or, if the host has the same system, compile on host and use the shared |
ok,really thank you for your sincere reply,but the error disappeared as soon as I restart the container and run orb slam again.However,it throw the segmentation fault now like this: |
The easiest solution for the MIT-SHM error is a change of xorg.conf: #359 (comment) |
Thanks for your patient reply,and now I have successfully run the orb slam2 in tum dataset: |
Running dockered GUI applications on host display
:0
can lead to MIT-SHM errors and rendering issues. Sample setup:Sample error message:
I got this
MIT-SHM
error quite often if I share host display:0
. Though, normally it does not crash the application, but leads to rendering issues and artefacts after some time. (Some applications regardunix
inunix$DISPLAY
and don't useMIT-SHM
. But that is not reliable.)To avoid this error it is possible to disable IPC namespacing, thus allowing shared memory:
I don't like the solution to disable IPC namespacing with
--ipc=host
because of isolation loss. Instead I prefer to run additional X servers with extensionMIT-SHM
disabled. Simpified example:I gave a more extended example on stack overflow.
@jessfraz Hello jess!
I want to thank you for your work at docker and for your investigations to run GUI applications, too.
Inspired by your examples I developed a tool to run GUI applications and desktops in docker containers that also adresses X security issues and additionally provides features like sound and hardware acceleration.
I often thought about how to tell you about this without looking like someone who wants to advertise his project. Well, I take this opportunity, and I hope you like it.
The project is hosted on github: x11docker
Examples:
The text was updated successfully, but these errors were encountered: