Skip to content

Commit 911d95b

Browse files
committed
Don't panic in the coordinator thread, bubble up the failure
Fixes #43402 (take 2)
1 parent 3ed8b69 commit 911d95b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/librustc_trans/back/write.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ fn start_executing_work(tcx: TyCtxt,
11921192
modules_config: Arc<ModuleConfig>,
11931193
metadata_config: Arc<ModuleConfig>,
11941194
allocator_config: Arc<ModuleConfig>)
1195-
-> thread::JoinHandle<CompiledModules> {
1195+
-> thread::JoinHandle<Result<CompiledModules, ()>> {
11961196
let coordinator_send = tcx.tx_to_llvm_workers.clone();
11971197
let mut exported_symbols = FxHashMap();
11981198
exported_symbols.insert(LOCAL_CRATE, tcx.exported_symbols(LOCAL_CRATE));
@@ -1638,7 +1638,7 @@ fn start_executing_work(tcx: TyCtxt,
16381638
Message::Done { result: Err(()), worker_id: _ } => {
16391639
shared_emitter.fatal("aborting due to worker thread failure");
16401640
// Exit the coordinator thread
1641-
panic!("aborting due to worker thread failure")
1641+
return Err(())
16421642
}
16431643
Message::TranslateItem => {
16441644
bug!("the coordinator should not receive translation requests")
@@ -1664,11 +1664,11 @@ fn start_executing_work(tcx: TyCtxt,
16641664
let compiled_metadata_module = compiled_metadata_module
16651665
.expect("Metadata module not compiled?");
16661666

1667-
CompiledModules {
1667+
Ok(CompiledModules {
16681668
modules: compiled_modules,
16691669
metadata_module: compiled_metadata_module,
16701670
allocator_module: compiled_allocator_module,
1671-
}
1671+
})
16721672
});
16731673

16741674
// A heuristic that determines if we have enough LLVM WorkItems in the
@@ -1960,15 +1960,19 @@ pub struct OngoingCrateTranslation {
19601960
coordinator_send: Sender<Box<Any + Send>>,
19611961
trans_worker_receive: Receiver<Message>,
19621962
shared_emitter_main: SharedEmitterMain,
1963-
future: thread::JoinHandle<CompiledModules>,
1963+
future: thread::JoinHandle<Result<CompiledModules, ()>>,
19641964
output_filenames: Arc<OutputFilenames>,
19651965
}
19661966

19671967
impl OngoingCrateTranslation {
19681968
pub fn join(self, sess: &Session, dep_graph: &DepGraph) -> CrateTranslation {
19691969
self.shared_emitter_main.check(sess, true);
19701970
let compiled_modules = match self.future.join() {
1971-
Ok(compiled_modules) => compiled_modules,
1971+
Ok(Ok(compiled_modules)) => compiled_modules,
1972+
Ok(Err(())) => {
1973+
sess.abort_if_errors();
1974+
panic!("expected abort due to worker thread errors")
1975+
},
19721976
Err(_) => {
19731977
sess.fatal("Error during translation/LLVM phase.");
19741978
}

0 commit comments

Comments
 (0)