Xwayland crash when calling XPutImage with large image sizes
Hopefully this is the right category for this.
I've discovered what I think is a bug that only manifests when running an X server via Xwayland. A simplified version of the code that causes the issue:
int width = ...;
int height = ...;
unsigned char* data = malloc(width * height * 4);
memset(data, 0, width * height * 4);
XImage* ximage = XCreateImage(
display,
DefaultVisual(display, DefaultScreen(display)),
32,
ZPixmap,
0,
data,
width, height,
32,
0
);
Pixmap pixmap = XCreatePixmap(
display,
window,
width, height,
32
);
GC gc = XCreateGC(display, pixmap, 0, 0);
XPutImage(
display,
pixmap,
gc,
ximage,
0, 0,
0, 0,
width, height
);
XInternAtom(display, "WM_DELETE_WINDOW", 0);
- If
width
andheight
are 128 or lower, this code executes fine. - If
width
andheight
is 256 or 512, a segmentation fault will be triggered when callingXPutImage
. - If
width
andheight
are 1024 or higher,XPutImage
will succeed but the call toXInternAtom
will fail with the following error, causing the program to exit immediately:
XIO: fatal IO error 14 (Bad address) on X server ":0"
- Non-power of two sizes and non-square images were not tested.
- The same code works fine when a normal X server is running.
The full code where I originally discovered the error can be found in my project here, around line 169.
- Removing the
XPutImage
line causes the program to run normally. - Removing the
XInternAtom
line (and the lines that depend upon it) just delays the crash until cursor pixmap initialization further down the same function. - Removing cursor initialization further delays the crash until
vkCreateXlibSurfaceKHR
elsewhere in the program.
System Information:
-
xorg-xwayland
version 23.1.2-1 -
xorg-server-common
version 21.1.8-1 -
sway
wayland compositor version 1:1.8.1-1 - Arch Linux 6.3.9-arch1-1
- AMD graphics