Patch for X11 BadValue errors on SDL_UpdateWindowRects

Hi,

using SDL_UpdateWindowRects () with SDL_Rect instances that do not clip
to the bounds of the SDL_Window causes a BadValue error on X11, if
shared memory is enabled:

X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 142 (MIT-SHM)
Minor opcode of failed request: 3 (X_ShmPutImage)
Value in failed request: 0x5
Serial number of failed request: 67
Current serial number in output stream: 70

Attached is a test program to recreate the behaviour (please give it a
try to see, if it fails for you, too) along with a simple patch for
SDL_x11framebuffer.c (rev. 6303), which reduces the rect area to the
window bounds.

I am not sure, if XPutImage() is more robust here, so I applied it to
the non-shared memory version, too.

Regards
Marcus
-------------- next part --------------
A non-text attachment was scrubbed…
Name: main.c
Type: text/x-csrc
Size: 553 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120327/bbcb5fd6/attachment.c
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL_x11framebuffer.c.patch
Type: text/x-diff
Size: 2498 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120327/bbcb5fd6/attachment.patch
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120327/bbcb5fd6/attachment.pgp

1 Like

That’s strange… I’m running into this problem with this simple program on libsdl 2.0.9. https://github.com/nikolas/sdl-mandelbrot/blob/sdl2/sdlmandel.c

SDL_UpdateWindowSurfaceRects() fails like this:

$ ./sdlmandel 
zoom: 202.375000
center point: -0.500000 +0.000000i
iterations: 45
zoom: 202.375000
center point: -0.500000 +0.000000i
iterations: 45
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  130 (MIT-SHM)
  Minor opcode of failed request:  3 (X_ShmPutImage)
  Value in failed request:  0x255
  Serial number of failed request:  1424
  Current serial number in output stream:  1425

While SDL_UpdateWindowSurface() works with no problems.