Skycoder42 / QHotkey

A global shortcut/hotkey for Desktop Qt-Applications
BSD 3-Clause "New" or "Revised" License
552 stars 162 forks source link

Infinite loop (ending in a segmentation fault) upon BadAccess #4

Closed ArsenArsen closed 7 years ago

ArsenArsen commented 7 years ago

When a BadAccess failure occurs during registering shortcuts QHotkey will go into an infinite loop, spamming the console each iteration.

WARN: Failed to unregister hotkey. Error: BadAccess (attempt to access private resource denied)

This time I tested it seems to have crashed. Segmentation fault @ qhotkey_x11.cpp:133 (The XSync line).

Tried again, the SIGSEGV is reproducable.

Skycoder42 commented 7 years ago

Which key did you try to register? I cannot test unless I am able to reproduce this myself.

ArsenArsen commented 7 years ago

Oh whoops. Sorry. It fails if a keybind is already registered. Does not matter which one.

EDIT: I assume it tries to unregister it. My suggested solution would be failing the bind and leaving it as unregistered, with no sequence.

Skycoder42 commented 7 years ago

Bug confirmed, I was able to reproduce it. Working on a solution

Skycoder42 commented 7 years ago

Okay, it's a simple copy paste error… Of course, trying to unregister when unregistering fails is a nogo.

Skycoder42 commented 7 years ago

Apparently, the call to XSync has more sideeffects than expected. As soon as one registration fails, all subsequent ones will as well. In other words, XSync renders QHotkey unusable after the first fail.

Without using this, however, no errors are reported at all. I will keep this issue open, until I can find a way to report errors properly, but I will remove XSync to make it usable again.

EDIT: With the laters qpm release, You should already have a "working" version (I replaced XSync by XFlush a while ago). but the log error persists

ArsenArsen commented 7 years ago

Seems to have been fixed. Thanks! One question stands though, how do we actually properly handle registration failures?

ArsenArsen commented 7 years ago

Actually, seems that isRegistered() keeps returning true, which would be wrong because the hotkey is not really registered.

Skycoder42 commented 7 years ago

Just like I said, error detection is not working yet. Neither can I receive error messages, nor can I detect whether registerings works or not.

Right now, there is no way to detect errors. I will have to find out why it is not possible to register hotkeys after the first fail (if error reporting is enabled) and find a fix.

ArsenArsen commented 7 years ago

Ah, I see. Excuse me. I'll keep the issue open for future reference. Thanks!

Skycoder42 commented 7 years ago

Apparently, it was just me not clearing the static error flag...