crashes: Avoid crash handler on detached threads (#40883)
Set a TLS bit to skip invoking the crash handler when a detached thread panics. cc @P1n3appl3 - is this at odds with what we need the crash handler to do? May close #39289, cannot repro without a nightly build Release Notes: - Fixed extension panics crashing Zed on Linux Co-authored-by: dino <dinojoaocosta@gmail.com>
This commit is contained in:
@@ -2,21 +2,20 @@ use crate::{App, PlatformDispatcher};
|
||||
use async_task::Runnable;
|
||||
use futures::channel::mpsc;
|
||||
use smol::prelude::*;
|
||||
use std::mem::ManuallyDrop;
|
||||
use std::panic::Location;
|
||||
use std::thread::{self, ThreadId};
|
||||
use std::{
|
||||
fmt::Debug,
|
||||
marker::PhantomData,
|
||||
mem,
|
||||
mem::{self, ManuallyDrop},
|
||||
num::NonZeroUsize,
|
||||
panic::Location,
|
||||
pin::Pin,
|
||||
rc::Rc,
|
||||
sync::{
|
||||
Arc,
|
||||
atomic::{AtomicUsize, Ordering::SeqCst},
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
},
|
||||
task::{Context, Poll},
|
||||
thread::{self, ThreadId},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use util::TryFutureExt;
|
||||
@@ -123,7 +122,12 @@ impl TaskLabel {
|
||||
/// Construct a new task label.
|
||||
pub fn new() -> Self {
|
||||
static NEXT_TASK_LABEL: AtomicUsize = AtomicUsize::new(1);
|
||||
Self(NEXT_TASK_LABEL.fetch_add(1, SeqCst).try_into().unwrap())
|
||||
Self(
|
||||
NEXT_TASK_LABEL
|
||||
.fetch_add(1, Ordering::SeqCst)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +275,7 @@ impl BackgroundExecutor {
|
||||
let awoken = awoken.clone();
|
||||
let unparker = unparker.clone();
|
||||
move || {
|
||||
awoken.store(true, SeqCst);
|
||||
awoken.store(true, Ordering::SeqCst);
|
||||
unparker.unpark();
|
||||
}
|
||||
});
|
||||
@@ -287,7 +291,7 @@ impl BackgroundExecutor {
|
||||
max_ticks -= 1;
|
||||
|
||||
if !dispatcher.tick(background_only) {
|
||||
if awoken.swap(false, SeqCst) {
|
||||
if awoken.swap(false, Ordering::SeqCst) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user