Skip to content

Commit 854daae

Browse files
committed
rt: Lock before using the random number generator
Seeing crashes here trying to stress test concurrent tasks
1 parent aeadc62 commit 854daae

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/rt/rust_kernel.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,11 @@ rust_kernel::fail() {
150150

151151
rust_task_id
152152
rust_kernel::create_task(rust_task *spawner, const char *name) {
153+
scoped_lock with(_kernel_lock);
153154
rust_scheduler *thread = threads[isaac_rand(&rctx) % num_threads];
154155
rust_task *t = thread->create_task(spawner, name);
155-
{
156-
scoped_lock with(_kernel_lock);
157-
t->user.id = max_id++;
158-
task_table.put(t->user.id, t);
159-
}
156+
t->user.id = max_id++;
157+
task_table.put(t->user.id, t);
160158
return t->user.id;
161159
}
162160

0 commit comments

Comments
 (0)