diff options
author | David Hewitt <1939362+davidhewitt@users.noreply.github.com> | 2019-12-12 15:01:23 +0000 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2019-12-12 16:01:23 +0100 |
commit | 6deb274b8283b1d5afe0666d21d6093c89a0835d (patch) | |
tree | 9176379f26570d05daf4ca0508358c1d31cb3d3c /alacritty/src | |
parent | 4d3f6de41a4bb999c8941cab2962a2cb5fb91393 (diff) | |
download | r-alacritty-6deb274b8283b1d5afe0666d21d6093c89a0835d.tar.gz r-alacritty-6deb274b8283b1d5afe0666d21d6093c89a0835d.tar.bz2 r-alacritty-6deb274b8283b1d5afe0666d21d6093c89a0835d.zip |
Fix deadlock when closing on Windows using Conpty
Fixes #3042.
Diffstat (limited to 'alacritty/src')
-rw-r--r-- | alacritty/src/main.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/alacritty/src/main.rs b/alacritty/src/main.rs index 871c816e..9b5b8eb8 100644 --- a/alacritty/src/main.rs +++ b/alacritty/src/main.rs @@ -222,6 +222,19 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(), // Start event loop and block until shutdown processor.run(terminal, window_event_loop); + // This explicit drop is needed for Windows, ConPTY backend. Otherwise a deadlock can occur. + // The cause: + // - Drop for Conpty will deadlock if the conout pipe has already been dropped. + // - The conout pipe is dropped when the io_thread is joined below (io_thread owns pty). + // - Conpty is dropped when the last of processor and io_thread are dropped, because both of + // them own an Arc<Conpty>. + // + // The fix is to ensure that processor is dropped first. That way, when io_thread (i.e. pty) + // is dropped, it can ensure Conpty is dropped before the conout pipe in the pty drop order. + // + // FIXME: Change PTY API to enforce the correct drop order with the typesystem. + drop(processor); + // Shutdown PTY parser event loop loop_tx.send(Msg::Shutdown).expect("Error sending shutdown to pty event loop"); io_thread.join().expect("join io thread"); |