@@ -77,7 +77,6 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
77
77
state(state),
78
78
cond(NULL ),
79
79
cond_name(" none" ),
80
- supervisor(spawner),
81
80
list_index(-1 ),
82
81
next_port_id(0 ),
83
82
rendezvous_ptr(0 ),
@@ -92,7 +91,8 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
92
91
reentered_rust_stack(false ),
93
92
c_stack(NULL ),
94
93
next_c_sp(0 ),
95
- next_rust_sp(0 )
94
+ next_rust_sp(0 ),
95
+ supervisor(spawner)
96
96
{
97
97
LOGPTR (thread, " new task" , (uintptr_t )this );
98
98
DLOG (thread, task, " sizeof(task) = %d (0x%x)" , sizeof *this , sizeof *this );
@@ -103,6 +103,7 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
103
103
}
104
104
}
105
105
106
+ // NB: This does not always run on the task's scheduler thread
106
107
void
107
108
rust_task::delete_this ()
108
109
{
@@ -112,8 +113,11 @@ rust_task::delete_this()
112
113
name, (uintptr_t )this , ref_count);
113
114
114
115
// FIXME: We should do this when the task exits, not in the destructor
115
- if (supervisor) {
116
- supervisor->deref ();
116
+ {
117
+ scoped_lock with (supervisor_lock);
118
+ if (supervisor) {
119
+ supervisor->deref ();
120
+ }
117
121
}
118
122
119
123
/* FIXME: tighten this up, there are some more
@@ -302,6 +306,7 @@ rust_task::conclude_failure() {
302
306
303
307
void
304
308
rust_task::fail_parent () {
309
+ scoped_lock with (supervisor_lock);
305
310
if (supervisor) {
306
311
DLOG (thread, task,
307
312
" task %s @0x%" PRIxPTR
@@ -317,6 +322,7 @@ rust_task::fail_parent() {
317
322
void
318
323
rust_task::unsupervise ()
319
324
{
325
+ scoped_lock with (supervisor_lock);
320
326
if (supervisor) {
321
327
DLOG (thread, task,
322
328
" task %s @0x%" PRIxPTR
0 commit comments