diff options
| author | Eric Holk <eholk@mozilla.com> | 2011-07-07 18:18:52 -0700 |
|---|---|---|
| committer | Eric Holk <eholk@mozilla.com> | 2011-07-07 18:22:27 -0700 |
| commit | 4739953b84b814de3b2b80f273f6292c33e33010 (patch) | |
| tree | 6d8a7753de5404b18ecfcae5a8080b5820ddc2ce /src/rt/rust_task.cpp | |
| parent | 2d57b25f6b3803ec505ba4909302bebb2cad4afd (diff) | |
| download | rust-4739953b84b814de3b2b80f273f6292c33e33010.tar.gz rust-4739953b84b814de3b2b80f273f6292c33e33010.zip | |
Fixed two races.
The first is that the memory_region destructor would complain there is still an outstanding allocation. This is because circular_buffer from rust_chan wasn't refing its task, so the task was being destructed too soon. The second was where the program could deadlock while joining a task. The target task would die in the time between checking whether the task should block and then actually blocking. The fix is to use the target task's lock.
Diffstat (limited to 'src/rt/rust_task.cpp')
| -rw-r--r-- | src/rt/rust_task.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 6c7ab554002..70afcdd9d58 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -118,12 +118,15 @@ void task_start_wrapper(spawn_args *a) a->f(&rval, task, a->a3, a->a4); LOG(task, task, "task exited with value %d", rval); + LOG(task, task, "task ref_count: %d", task->ref_count); A(task->sched, task->ref_count >= 0, "Task ref_count should not be negative on exit!"); task->die(); + task->lock.lock(); task->notify_tasks_waiting_to_join(); + task->lock.unlock(); task->yield(1); } |
