diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index ab29b1067830e510b28a994ae3ced549c84f8734..31a3324f1d46f5dbd56248a284ff7a265a836389 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -86,6 +86,9 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state, stk = new_stk(sched, this, 0); user.rust_sp = stk->limit; + if (supervisor) { + supervisor->ref(); + } } rust_task::~rust_task() @@ -107,6 +110,10 @@ rust_task::~rust_task() } } + if (supervisor) { + supervisor->deref(); + } + kernel->release_task_id(user.id); /* FIXME: tighten this up, there are some more @@ -294,6 +301,9 @@ rust_task::unsupervise() "task %s @0x%" PRIxPTR " disconnecting from supervisor %s @0x%" PRIxPTR, name, this, supervisor->name, supervisor); + if (supervisor) { + supervisor->deref(); + } supervisor = NULL; propagate_failure = false; } diff --git a/src/test/run-fail/spawnfail.rs b/src/test/run-fail/spawnfail.rs new file mode 100644 index 0000000000000000000000000000000000000000..0ff641fbe953f6f318ce28d3349b9fe74dabc79b --- /dev/null +++ b/src/test/run-fail/spawnfail.rs @@ -0,0 +1,14 @@ +// Currently failure doesn't propagate correctly to owning tasks so xfailed +// xfail-test +// error-pattern:explicit +use std; +import std::task; + +// We don't want to see any invalid reads +fn main() { + fn f() { + fail; + } + let g = f; + task::spawn(g); +} \ No newline at end of file