My last patch on this issue turned out not to solve the underlying problem, however since discovering it is fully reproducible I have been able to implement a complete fix building off the previous patches AppRunFlags support.
To replicate the issue under Mono, the following steps are needed:
Under the best case, KeePass will freeze, under Cinnamon, the entire desktop will freeze accepting input (but the mouse will keep moving).
This problem is due to the fact that the X clipboard isn't a separate memory space, and so Mono simply passes a pointer to the clipboard's memory location. However, since this is in the main UI thread (which is blocked waiting for xsel), xsel blocks waiting for the clipboard's ownership to be released, the UI thread blocks waiting for xsel, and the window manager blocks waiting for UI thread.
This problem is entirely resolved in this patch by modifying NativeLib.RunConsoleApp() to asynchronously execute and wait for the xsel process in a separate thread, and then calling DoEvents() while waiting, which allows the UI thread to handle events such as requests for the clipboard. To prevent problems with re-entrant functions, all forms are disabled during this time, and re-enabled afterwards.
This implementation perfectly preserves the synchronous nature of the RunConsoleApp() call otherwise, and absent the RunAppFlags.DoEventsWorkAround flag, executes the call synchronously.
Log in to post a comment.