Skip to content

Commit 07771ec

Browse files
committed
Fix run-fail/spawnfail
Catch the case where a parent is killed immediately before it terminates normally.
1 parent fcdb313 commit 07771ec

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/rt/rust_task.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,20 @@ void task_start_wrapper(spawn_args *a)
191191
task->free(env);
192192
}
193193

194+
task->die();
195+
196+
if (task->killed && !failed) {
197+
LOG(task, task, "Task killed during termination");
198+
failed = true;
199+
}
200+
194201
if (failed) {
195202
#ifndef __WIN32__
196203
task->conclude_failure();
197204
#else
198205
A(task->sched, false, "Shouldn't happen");
199206
#endif
200207
} else {
201-
task->die();
202208
task->lock.lock();
203209
task->notify_tasks_waiting_to_join();
204210
task->lock.unlock();
@@ -316,13 +322,13 @@ rust_task::fail() {
316322
#ifndef __WIN32__
317323
throw this;
318324
#else
325+
die();
319326
conclude_failure();
320327
#endif
321328
}
322329

323330
void
324331
rust_task::conclude_failure() {
325-
die();
326332
// Unblock the task so it can unwind.
327333
unblock();
328334
fail_parent();

src/test/run-fail/spawnfail.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
// xfail-test
1+
// xfail-win32
22
// error-pattern:explicit
33
use std;
44
import std::task;
55

66
// We don't want to see any invalid reads
77
fn main() {
8-
fn f() {
8+
fn f(&&_i: ()) {
99
fail;
1010
}
11-
let g = f;
12-
task::spawn(g);
11+
task::spawn((), f);
1312
}

0 commit comments

Comments
 (0)