]> git.lizzy.rs Git - rust.git/commitdiff
rt: Lock before using the random number generator
authorBrian Anderson <banderson@mozilla.com>
Wed, 21 Dec 2011 04:55:52 +0000 (20:55 -0800)
committerBrian Anderson <banderson@mozilla.com>
Wed, 21 Dec 2011 04:56:06 +0000 (20:56 -0800)
Seeing crashes here trying to stress test concurrent tasks

src/rt/rust_kernel.cpp

index 347b7907b533221a401068ab42fcbd7cd00b31f2..f009541053d08d85094c479232928d5aa9477653 100644 (file)
@@ -150,13 +150,11 @@ rust_kernel::fail() {
 
 rust_task_id
 rust_kernel::create_task(rust_task *spawner, const char *name) {
+    scoped_lock with(_kernel_lock);
     rust_scheduler *thread = threads[isaac_rand(&rctx) % num_threads];
     rust_task *t = thread->create_task(spawner, name);
-    {
-        scoped_lock with(_kernel_lock);
-        t->user.id = max_id++;
-        task_table.put(t->user.id, t);
-    }
+    t->user.id = max_id++;
+    task_table.put(t->user.id, t);
     return t->user.id;
 }