Bug 1466044

Summary: Crash in keybinder (or its python bindings)
Product: [Fedora] Fedora Reporter: Christian Stadelmann <fedora>
Component: keybinder3Assignee: Patrick Griffis <tingping>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 26CC: tingping
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: keybinder3-0.3.2-2.fc26 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-07 23:05:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
A full backtrace from gdb attached to python
none
a simple reproducer none

Description Christian Stadelmann 2017-06-28 20:57:32 UTC
Created attachment 1292699 [details]
A full backtrace from gdb attached to python

Description of problem:
Every time I call Keybinder.bind(), it crashes with SIGSEGV.

Version-Release number of selected component (if applicable):
keybinder3-0.3.0-7.fc26.x86_64

How reproducible:
always with the python script I'll attach

Steps to Reproduce:
1. start python script, which calls Keybinder.bind()

Actual results:
Crash. Full backtrace attached. Truncated backtrace:

Thread 1 "python2" received signal SIGSEGV, Segmentation fault.
XkbUseExtension (dpy=0x5555559a38b0, major_rtrn=major_rtrn@entry=0x0, minor_rtrn=minor_rtrn@entry=0x0) at XKBUse.c:652
652	        dpy->free_funcs->xkb = _XkbFreeInfo;
#0  0x00007fffe8dbd154 in XkbUseExtension (dpy=0x5555559a38b0, major_rtrn=major_rtrn@entry=0x0, minor_rtrn=minor_rtrn@entry=0x0) at XKBUse.c:652
#1  0x00007fffe8db7a79 in XkbGetUpdatedMap (dpy=0x5555559a38b0, which=7, xkb=0x555555b95d20) at XKBGetMap.c:574
#2  0x00007fffe8db7afd in XkbGetMap (dpy=0x5555559a38b0, which=which@entry=7, deviceSpec=deviceSpec@entry=256) at XKBGetMap.c:603
#3  0x00007fffd5cb468f in grab_ungrab (rootwin=rootwin@entry=0x5555559a6000 [GdkWaylandWindow], keyval=269025044, modifiers=0, grab=grab@entry=1) at bind.c:203
#4  0x00007fffd5cb484f in do_grab_key (binding=binding@entry=0x555555b64530) at bind.c:326
#5  0x00007fffd5cb4a20 in keybinder_bind_full (keystring=0x555555b8fc00 "XF86AudioPlay", handler=0x7ffff7ee6050, user_data=0x555555d0c2d0, notify=0x7fffefcbc660 <_pygi_invoke_closure_free>) at bind.c:586
#6  0x00007fffef0f5bde in ffi_call_unix64 () at ../src/x86/unix64.S:76
#7  0x00007fffef0f554f in ffi_call (cif=cif@entry=0x555555d6c9a8, fn=<optimized out>, rvalue=<optimized out>, rvalue@entry=0x7fffffffc778, avalue=<optimized out>)
    at ../src/x86/ffi64.c:525
#8  0x00007fffefcbece4 in pygi_invoke_c_callable (function_cache=0x555555d6c900, state=<optimized out>, py_args=<optimized out>, py_kwargs=<optimized out>)
    at pygi-invoke.c:679
#9  0x00007fffefcc0838 in pygi_function_cache_invoke (function_cache=<optimized out>, py_args=<optimized out>, py_kwargs=<optimized out>) at pygi-cache.c:861
#10 0x00007ffff7a2bea3 in PyObject_Call () at /lib64/libpython2.7.so.1.0

Expected results:
No crash

Additional info:
Upstream has released 0.3.2 on February 28. You might want to update to 0.3.2 which might fix this bug.

Comment 1 Christian Stadelmann 2017-06-28 20:58:36 UTC
Created attachment 1292700 [details]
a simple reproducer

Python backtrace:

Traceback (most recent call first):
  File "./keybinder_crash/__main__.py", line 38, in do_activate
    Keybinder.bind('XF86AudioPlay', foo)
  File "./keybinder_crash/__main__.py", line 49, in main
    ret = application.run(sys.argv)
  File "./keybinder_crash/__main__.py", line 56, in <module>
    main()

Comment 2 Patrick Griffis 2017-06-28 21:05:06 UTC
Is this on Wayland? If so 0.3.2 will be the fix (it simply returns and does nothing on Wayland)

Comment 3 Christian Stadelmann 2017-06-28 23:17:13 UTC
(In reply to Patrick Griffis from comment #2)
> Is this on Wayland?

Yes, this is wayland.

> If so 0.3.2 will be the fix (it simply returns and does nothing on Wayland)

Hm, thats not nice. Any chance to get this into the documentation? And maybe a warning?

Comment 4 Patrick Griffis 2017-06-28 23:34:28 UTC
(In reply to Christian Stadelmann from comment #3)
> (In reply to Patrick Griffis from comment #2)
> > If so 0.3.2 will be the fix (it simply returns and does nothing on Wayland)
> 
> Hm, thats not nice. Any chance to get this into the documentation? And maybe
> a warning?

What documentation? If your code handles bind() failing you can print your own warnings that it failed.

Global bindings are a concept that don't really exist in Wayland. A workaround would be for example configuring bindings in Gnome-Shell to run a custom command.

Comment 5 Christian Stadelmann 2017-06-29 10:42:36 UTC
(In reply to Patrick Griffis from comment #4)
> (In reply to Christian Stadelmann from comment #3)
> > (In reply to Patrick Griffis from comment #2)
> > > If so 0.3.2 will be the fix (it simply returns and does nothing on Wayland)
> > 
> > Hm, thats not nice. Any chance to get this into the documentation? And maybe
> > a warning?
> 
> What documentation? If your code handles bind() failing you can print your
> own warnings that it failed.

The one shipped by keybinder3-doc on Keybinder.bind(). Having it simply return and doing nothing is bad. It should print a warning to console so anyone having a look at "why did nothing happen?" after a Keybinder.bind() call has a clue on what really happens.

> Global bindings are a concept that don't really exist in Wayland. A
> workaround would be for example configuring bindings in Gnome-Shell to run a
> custom command.

is there an API for that?

Comment 6 Patrick Griffis 2017-06-29 18:53:23 UTC
(In reply to Christian Stadelmann from comment #5)
> The one shipped by keybinder3-doc on Keybinder.bind().

Ah, looking upstream they didn't document it in the next version either, but that is a discussion to have with them.

https://github.com/kupferlauncher/keybinder

> Having it simply
> return and doing nothing is bad. It should print a warning to console so
> anyone having a look at "why did nothing happen?" after a Keybinder.bind()
> call has a clue on what really happens.

Well like I said, your application *should* be handling the return value anyway. It not working isn't a surprise your code should handle it.

> > Global bindings are a concept that don't really exist in Wayland. A
> > workaround would be for example configuring bindings in Gnome-Shell to run a
> > custom command.
> 
> is there an API for that?

No.

Comment 7 Fedora Update System 2017-06-29 21:05:01 UTC
keybinder3-0.3.2-2.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-737d3789d3

Comment 8 Christian Stadelmann 2017-06-30 10:45:53 UTC
(In reply to Patrick Griffis from comment #6)
> (In reply to Christian Stadelmann from comment #5)
> > The one shipped by keybinder3-doc on Keybinder.bind().
> 
> Ah, looking upstream they didn't document it in the next version either, but
> that is a discussion to have with them.
> 
> https://github.com/kupferlauncher/keybinder

Ok, will try to contribute docs or add an issue there.

> > Having it simply
> > return and doing nothing is bad. It should print a warning to console so
> > anyone having a look at "why did nothing happen?" after a Keybinder.bind()
> > call has a clue on what really happens.
> 
> Well like I said, your application *should* be handling the return value
> anyway. It not working isn't a surprise your code should handle it.

You're right. I'll fix that upstream at https://github.com/exaile/exaile/pull/402/commits/e13fe377645361eb4ae2c93dfe2c4e0174e7c7a3.

Thanks for getting keybinder updated so fast!

Comment 9 Patrick Griffis 2017-06-30 16:26:35 UTC
(In reply to Christian Stadelmann from comment #8)
> You're right. I'll fix that upstream at
> https://github.com/exaile/exaile/pull/402/commits/
> e13fe377645361eb4ae2c93dfe2c4e0174e7c7a3.


Looks good.

Comment 10 Fedora Update System 2017-06-30 20:25:50 UTC
keybinder3-0.3.2-2.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-737d3789d3

Comment 11 Fedora Update System 2017-07-07 23:05:33 UTC
keybinder3-0.3.2-2.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.