Skip to content

Commit

Permalink
Double check that the deadlock handler doesn't get overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Mar 7, 2024
1 parent e2bee64 commit c30186c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_interface/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub struct Compiler {
pub compiler_for_deadlock_handler: Arc<AtomicPtr<()>>,
}

impl !Sync for Compiler {}
impl !rustc_data_structures::sync::DynSync for Compiler {}

/// Converts strings provided as `--cfg [cfgspec]` into a `Cfg`.
pub(crate) fn parse_cfg(dcx: &DiagCtxt, cfgs: Vec<String>) -> Cfg {
cfgs.into_iter()
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![feature(let_chains)]
#![feature(thread_spawn_unchecked)]
#![feature(try_blocks)]
#![feature(negative_impls)]

#[macro_use]
extern crate tracing;
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_interface/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ impl<'tcx> Queries<'tcx> {
&self.hir_arena,
);

self.compiler
let old = self
.compiler
.compiler_for_deadlock_handler
.store(qcx as *const _ as *mut _, Ordering::Relaxed);
.swap(qcx as *const _ as *mut _, Ordering::Relaxed);
assert!(old.is_null());

qcx.enter(|tcx| {
let feed = tcx.feed_local_crate();
Expand Down Expand Up @@ -321,6 +323,7 @@ impl Compiler {
// is accessing the `GlobalCtxt`.
self.compiler_for_deadlock_handler.store(std::ptr::null_mut(), Ordering::Relaxed);
});
assert!(self.compiler_for_deadlock_handler.load(Ordering::Relaxed).is_null());
let queries = Queries::new(self);
let ret = f(&queries);

Expand Down

0 comments on commit c30186c

Please sign in to comment.