-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix inconsistent mutex unlocking due to double slot execution #1691
Conversation
This was already implemented since the If the problem was a double mutex unlock, the easy fix (tryLocking before unlocking) is just a one line fix:
Inserting another mutex is useless, the first one already take care about everything |
Yes, for global Auto-Type, the outer mutex also covers the inner one, but non-global Auto-Type should have a mutex as well. Previously, performAutoType used the same mutex, but it makes a lot more sense to keep it local to the function doing the actual work, which prevents a lot of errors. By splitting the logic into two distinct mutexes, I can keep one entirely inside one function and spread the other one over as few as possible (i.e., one that locks and two which unlock, which is far from ideal, but better than having all sorts of functions taking care of it). I also don't mix our two use cases, which are preventing double dialogs and preventing double Auto-Type, making the semantics behind the mutexes a lot more transparent. |
I agree that the double use case mix things up a little bit. The old single-mutex approach already locked multiple global-autotype/single-autotype and mixed global - single autotype. Double dialog is file if the single mutex locks/unlocks fine |
The problem with having only a single mutex is that it's quite easy to produce deadlocks by re-entrance and we cannot set the mutex to be recursive, because we are working only in a single thread. |
So it's fine by me |
Then please approve. 😉 |
I was waiting for @droidmonkey since he explicitly self requested a review 😅 |
Lol sorry I didnt see the core developers already in place. I wanted to run this on my machine to test that it fixed the issue, i trust you guys |
- Enable high entropy ASLR on Windows [#1747] - Enhance favicon fetching [#1786] - Fix crash on Windows due to autotype [#1691] - Fix dark tray icon changing all icons [#1680] - Fix --pw-stdin not using getPassword function [#1686] - Fix placeholders being resolved in notes [#1907] - Enable auto-type start delay to be configurable [#1908] - Browser: Fix native messaging reply size [#1719] - Browser: Increase maximum buffer size [#1720] - Browser: Enhance usability and functionality [#1810, #1822, #1830, #1884, #1906] - SSH Agent: Parse aes-256-cbc/ctr keys [#1682] - SSH Agent: Enhance usability and functionality [#1677, #1679, #1681, #1787]
Description
Fixes crash on Windows due to double mutex unlock. Resolves #1561.
Motivation and context
On Windows, the rejected() slot of the Auto-Type selection dialog was called twice on screen lock, resulting in a double mutex unlock. I have no idea why it's doing that (perhaps a bug introduced in Qt 5.10), but this patch works around it by making sure the mutex is locked before we try to unlock it.
In addition, I added another mutex for the actual auto-typing (not just the dialog) to ensure we are never auto-typing two sequences at the same time (not that this was an issue, but when we're already at it...)
How has this been tested?
Manually on Windows. I could not reproduce the crash anymore after applying the patch.
Types of changes
Checklist:
-DWITH_ASAN=ON
. [REQUIRED]