Skip to content

Commit 1430675

Browse files
committed
rt: Always delete task stacks on the task thread
There's not a real race here, but it makes helgrind happy and is arguably less prone to future errrors.
1 parent 9ec94f7 commit 1430675

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/rt/rust_task.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,6 @@ rust_task::delete_this()
121121
I(thread, ref_count == 0); // ||
122122
// (ref_count == 1 && this == sched->root_task));
123123

124-
// Delete all the stacks. There may be more than one if the task failed
125-
// and no landing pads stopped to clean up.
126-
// FIXME: We should do this when the task exits, not in the destructor
127-
while (stk != NULL) {
128-
del_stack();
129-
}
130-
131124
thread->release_task(this);
132125
}
133126

@@ -725,6 +718,16 @@ rust_task::check_stack_canary() {
725718
::check_stack_canary(stk);
726719
}
727720

721+
void
722+
rust_task::delete_all_stacks() {
723+
I(thread, !on_rust_stack());
724+
// Delete all the stacks. There may be more than one if the task failed
725+
// and no landing pads stopped to clean up.
726+
while (stk != NULL) {
727+
del_stack();
728+
}
729+
}
730+
728731
void
729732
rust_task::config_notify(chan_handle chan) {
730733
notify_enabled = true;

src/rt/rust_task.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ rust_task : public kernel_owned<rust_task>, rust_cond
205205
void reset_stack_limit();
206206
bool on_rust_stack();
207207
void check_stack_canary();
208+
void delete_all_stacks();
208209

209210
void config_notify(chan_handle chan);
210211

src/rt/rust_task_thread.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ rust_task_thread::reap_dead_tasks() {
144144
rust_task *task = dead_tasks_copy[i];
145145
// Release the task from the kernel so nobody else can get at it
146146
kernel->release_task_id(task->id);
147+
task->delete_all_stacks();
147148
// Deref the task, which may cause it to request us to release it
148149
task->deref();
149150
}

0 commit comments

Comments
 (0)