File tree Expand file tree Collapse file tree 4 files changed +15
-3
lines changed Expand file tree Collapse file tree 4 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -864,8 +864,12 @@ rust_task_kill_other(rust_task *task) { /* Used for linked failure */
864
864
}
865
865
866
866
extern " C" void
867
- rust_task_kill_all (rust_task *task) {
867
+ rust_task_kill_all (rust_task *task) { /* Used for linked failure */
868
868
task->fail_sched_loop ();
869
+ // This must not happen twice.
870
+ static bool main_taskgroup_failed = false ;
871
+ assert (!main_taskgroup_failed);
872
+ main_taskgroup_failed = true ;
869
873
}
870
874
871
875
extern " C" rust_cond_lock*
Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ extern "C" int check_claims;
90
90
// This accounts for logging buffers.
91
91
static size_t const BUF_BYTES = 2048 ;
92
92
93
+ #define INIT_TASK_ID 1
94
+
93
95
// The error status to use when the process fails
94
96
#define PROC_FAIL_CODE 101
95
97
Original file line number Diff line number Diff line change 15
15
rust_kernel::rust_kernel(rust_env *env) :
16
16
_region(env, true ),
17
17
_log(NULL ),
18
- max_task_id(1 ),
18
+ max_task_id(INIT_TASK_ID- 1 ), // sync_add_and_fetch increments first
19
19
max_port_id(1 ),
20
20
rval(0 ),
21
21
max_sched_id(1 ),
Original file line number Diff line number Diff line change @@ -129,11 +129,17 @@ cleanup_task(cleanup_args *args) {
129
129
// assert(task->task_local_data != NULL);
130
130
task->task_local_data_cleanup (task->task_local_data );
131
131
task->task_local_data = NULL ;
132
- } else if (threw_exception) {
132
+ } else if (threw_exception && task-> id == INIT_TASK_ID ) {
133
133
// Edge case: If main never spawns any tasks, but fails anyway, TLS
134
134
// won't be around to take down the kernel (task.rs:kill_taskgroup,
135
135
// rust_task_kill_all). Do it here instead.
136
+ // (Note that children tasks can not init their TLS if they were
137
+ // killed too early, so we need to check main's task id too.)
136
138
task->fail_sched_loop ();
139
+ // This must not happen twice.
140
+ static bool main_task_failed_without_spawning = false ;
141
+ assert (!main_task_failed_without_spawning);
142
+ main_task_failed_without_spawning = true ;
137
143
}
138
144
139
145
// FIXME (#2676): For performance we should do the annihilator
You can’t perform that action at this time.
0 commit comments