Skip to content
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

X11_KeyRepeat crash #839

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

X11_KeyRepeat crash #839

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

SDLBugzilla commented Feb 10, 2021

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: Linux, All

Comments on the original bug report:

On 2013-04-18 05:36:33 +0000, driedfruit wrote:

Created attachment 1116
gdb backtrace

On X11, sometimes, when you move your mouse and release the keyboard
key at the same time, you get a SIGSERV crash.

I've "tracked" it down to the X11_KeyRepeat function in
SDL_x11events.c. The function looks for next X11 event in the queue and
compares it to the current one, working around keyboard auto-repeat
feature of X11.

The culprit is XPeekEvent, which either crashes itself, either
corrupts something, so next XNextEvent call crashes.

To easier reproduce this, change "2" to "10" or a larger value here:

src/video/x11/SDL_x11events.c:113
((peekevent.xkey.time-event->xkey.time) < 2)) {

You're aiming to "inject" a MotionNotify event inbetween the
KeyRelease and the auto-repeated KeyPress. For me, it crashes reliably
when this happens.

I've tested this on different hardware (32 and 64 bit) and different libX11 versions, it doesn't seem to be an X bug, but an SDL2 bug :(

On 2013-04-18 05:37:03 +0000, driedfruit wrote:

Created attachment 1117
valgrind output

On 2013-04-18 05:37:39 +0000, driedfruit wrote:

Created attachment 1118
minimal test program

On 2013-04-18 19:08:30 +0000, Ondra Hošek wrote:

I can't reproduce this with the minimal program (and modification) you provided.

  • Xlib 1.5.0
  • X server 1.14.1
  • awesome v3.5.1-1-g2d31033 (window manager)
  • tip-of-the-trunk SDL2

What is your X server version? Which window manager are you using?

On 2013-04-19 02:38:42 +0000, driedfruit wrote:

  • i686
  • Xlib 1.4.1
  • Xserver 1.9.4
  • awesome 3.4.8 (wm)
  • latest SDL hg

and

  • amd64
  • Xlib 1.3.3-4
  • X server 1.7.7-14
  • enlightenment wm (don't have info on the version right now)
  • latest SDL hg

On 2013-04-30 11:10:05 +0000, driedfruit wrote:

After investigating more upon it, I've found that the reason for this crash has nothing to do with SDL2, but all with libXi:

http://cgit.freedesktop.org/xorg/lib/libXi/commit/?id=af65475b1f6b7209750220a74aaad9968d54aaf7

Applying this patch to 1.4.1 libXi fixes the issue. It's part of the more recent libXi releases. Sorry!

On 2013-07-15 15:31:48 +0000, Steve Soule wrote:

Created attachment 1236
patch to workaround this libXi bug

This patch is a workaround for the bug in libXi. It avoids calling X functions that trigger the bug. See the forum thread http://forums.libsdl.org/viewtopic.php?p=38071 for my explanation of what this workaround is intended to do.

On 2013-07-16 03:30:51 +0000, Sam Lantinga wrote:

Reopened to investigate Steve's patch.

On 2013-07-18 23:05:10 +0000, Ryan C. Gordon wrote:

That email thread has some really impressive research.

This patch looks good to me. Sam, you want to give this a looking at before I apply it?

Thanks,
--ryan.

On 2013-07-20 01:40:12 +0000, Sam Lantinga wrote:

It looks good to me. Go for it. Great work everyone!

On 2013-07-20 13:12:26 +0000, Ryan C. Gordon wrote:

This patch is now http://hg.libsdl.org/SDL/rev/c244bc85fb84, thanks!

--ryan.

On 2013-07-27 00:33:18 +0000, Ryan C. Gordon wrote:

*** Bug 1683 has been marked as a duplicate of this bug. ***

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant