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.
This commit is contained in:
@@ -393,11 +393,16 @@ task_yield(rust_task *task) {
|
||||
extern "C" CDECL void
|
||||
task_join(rust_task *task, rust_task *join_task) {
|
||||
// If the other task is already dying, we don't have to wait for it.
|
||||
join_task->lock.lock();
|
||||
if (join_task->dead() == false) {
|
||||
join_task->tasks_waiting_to_join.push(task);
|
||||
task->block(join_task, "joining local task");
|
||||
join_task->lock.unlock();
|
||||
task->yield(2);
|
||||
}
|
||||
else {
|
||||
join_task->lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/* Debug builtins for std.dbg. */
|
||||
|
||||
Reference in New Issue
Block a user