debugger: Fix deadlock in on_app_quit with debugger running (#29372)
This fixes a deadlock that would occur when `DapStore` had its on quit handler called. The deadlock was caused by `DapStore` spawning on the main thread while `App::shutdown` blocks the main thread. We added a debug_panic in GPUI that panics if a foreground task is spawned while the App context is shutting down. This will help tests catch hangs in `cx.on_app_quit` calls. Release Notes: - N/A --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
c3570fbcf3
commit
c3177e6f5b
10 changed files with 26 additions and 162 deletions
|
@ -700,6 +700,7 @@ impl Session {
|
|||
BreakpointStoreEvent::ActiveDebugLineChanged => {}
|
||||
})
|
||||
.detach();
|
||||
cx.on_app_quit(Self::on_app_quit).detach();
|
||||
|
||||
let this = Self {
|
||||
mode: Mode::Building,
|
||||
|
@ -1510,6 +1511,16 @@ impl Session {
|
|||
}
|
||||
}
|
||||
|
||||
fn on_app_quit(&mut self, cx: &mut Context<Self>) -> Task<()> {
|
||||
let debug_adapter = self.adapter_client();
|
||||
|
||||
cx.background_spawn(async move {
|
||||
if let Some(client) = debug_adapter {
|
||||
client.shutdown().await.log_err();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn shutdown(&mut self, cx: &mut Context<Self>) -> Task<()> {
|
||||
self.is_session_terminated = true;
|
||||
self.thread_states.exit_all_threads();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue