mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 02:37:21 +00:00
Annotate that the bug is due to a deadlock, fixing now
This commit is contained in:
parent
37e04320aa
commit
568017da85
1 changed files with 36 additions and 6 deletions
|
@ -6,6 +6,7 @@ use futures::{future::BoxFuture, FutureExt};
|
||||||
use gpui::executor::Background;
|
use gpui::executor::Background;
|
||||||
use language::{LanguageServerName, LspAdapter};
|
use language::{LanguageServerName, LspAdapter};
|
||||||
use plugin_runtime::{Plugin, PluginBuilder, WasiFn};
|
use plugin_runtime::{Plugin, PluginBuilder, WasiFn};
|
||||||
|
use std::task::Poll;
|
||||||
use std::{any::Any, path::PathBuf, sync::Arc};
|
use std::{any::Any, path::PathBuf, sync::Arc};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
|
@ -20,14 +21,22 @@ pub async fn new_json(executor: Arc<Background>) -> Result<PluginLspAdapter> {
|
||||||
let command = args.next().unwrap();
|
let command = args.next().unwrap();
|
||||||
dbg!("Running command");
|
dbg!("Running command");
|
||||||
let future = smol::process::Command::new(command).args(args).output();
|
let future = smol::process::Command::new(command).args(args).output();
|
||||||
|
dbg!("Awaiting command");
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
fn heck_point() {
|
||||||
|
dbg!("command awaited");
|
||||||
|
}
|
||||||
|
|
||||||
let future = future.wrap(|fut, cx| {
|
let future = future.wrap(|fut, cx| {
|
||||||
dbg!("Poll command start");
|
dbg!("Poll command!");
|
||||||
|
|
||||||
let res = fut.poll(cx);
|
let res = fut.poll(cx);
|
||||||
dbg!("Poll command end");
|
|
||||||
res
|
res
|
||||||
});
|
});
|
||||||
|
let future = future.await;
|
||||||
|
heck_point();
|
||||||
dbg!("blocked on future");
|
dbg!("blocked on future");
|
||||||
let future = smol::block_on(future);
|
|
||||||
future.log_err().map(|output| {
|
future.log_err().map(|output| {
|
||||||
dbg!("done running command");
|
dbg!("done running command");
|
||||||
output.stdout
|
output.stdout
|
||||||
|
@ -71,11 +80,32 @@ struct Versions {
|
||||||
server_version: String,
|
server_version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: is this the root cause?
|
||||||
|
// sketch:
|
||||||
|
// - smol command is run, hits await, switches
|
||||||
|
// - name is run, blocked on
|
||||||
|
// - smol command is still pending
|
||||||
|
// - name is stuck for some reason(?)
|
||||||
|
// - no progress made...
|
||||||
|
// - deadlock!!!?
|
||||||
|
// I wish there was high-level instrumentation for this...
|
||||||
|
// - it's totally a deadlock, the proof is in the pudding
|
||||||
|
|
||||||
macro_rules! call_block {
|
macro_rules! call_block {
|
||||||
($self:ident, $name:expr, $arg:expr) => {
|
($self:ident, $name:expr, $arg:expr) => {
|
||||||
$self
|
$self.executor.block(async {
|
||||||
.executor
|
dbg!("starting to block on something");
|
||||||
.block(async { $self.runtime.lock().await.call($name, $arg).await })
|
let locked = $self.runtime.lock();
|
||||||
|
dbg!("locked runtime");
|
||||||
|
// TODO: No blocking calls!
|
||||||
|
let mut awaited = locked.await;
|
||||||
|
dbg!("awaited lock");
|
||||||
|
let called = awaited.call($name, $arg);
|
||||||
|
dbg!("called function");
|
||||||
|
let result = called.await;
|
||||||
|
dbg!("awaited result");
|
||||||
|
result
|
||||||
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue