about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcore/task.rs1
-rw-r--r--src/rt/rust.cpp1
-rw-r--r--src/rt/rust_builtin.cpp3
-rw-r--r--src/rt/rust_kernel.cpp4
-rw-r--r--src/test/run-pass/rt-sched-1.rs3
5 files changed, 9 insertions, 3 deletions
diff --git a/src/libcore/task.rs b/src/libcore/task.rs
index 51f4a7c23cb..9f379bbd94a 100644
--- a/src/libcore/task.rs
+++ b/src/libcore/task.rs
@@ -538,6 +538,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) {
             new_task_in_new_sched(sched_opts)
           }
         };
+        assert !new_task.is_null();
 
         option::iter(opts.notify_chan) {|c|
             // FIXME (#1087): Would like to do notification in Rust
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp
index 67b3bf84938..150156ddae9 100644
--- a/src/rt/rust.cpp
+++ b/src/rt/rust.cpp
@@ -95,6 +95,7 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
     // Create the main scheduler and the main task
     rust_sched_id sched_id = kernel->create_scheduler(env->num_sched_threads);
     rust_scheduler *sched = kernel->get_scheduler_by_id(sched_id);
+    assert(sched != NULL);
     rust_task *root_task = sched->create_task(NULL, "main");
 
     // Build the command line arguments to pass to the root task
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 04d11e020ea..a33d3cb90fe 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -630,7 +630,8 @@ extern "C" CDECL rust_task*
 rust_new_task_in_sched(rust_sched_id id) {
     rust_task *task = rust_get_current_task();
     rust_scheduler *sched = task->kernel->get_scheduler_by_id(id);
-    // FIXME (#2668): What if we didn't get the scheduler?
+    if (sched == NULL)
+        return NULL;
     return new_task_common(sched, task);
 }
 
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index b13b1490c0f..82fec98e86a 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -121,7 +121,9 @@ rust_kernel::get_scheduler_by_id(rust_sched_id id) {
 
 rust_scheduler *
 rust_kernel::get_scheduler_by_id_nolock(rust_sched_id id) {
-    assert(id != 0 && "invalid scheduler id");
+    if (id == 0) {
+        return NULL;
+    }
     sched_lock.must_have_lock();
     sched_map::iterator iter = sched_table.find(id);
     if (iter != sched_table.end()) {
diff --git a/src/test/run-pass/rt-sched-1.rs b/src/test/run-pass/rt-sched-1.rs
index 447380663f4..a8ce61370a6 100644
--- a/src/test/run-pass/rt-sched-1.rs
+++ b/src/test/run-pass/rt-sched-1.rs
@@ -22,6 +22,7 @@ fn main() unsafe {
     let new_sched_id = rustrt::rust_new_sched(num_threads);
     #error("new_sched_id %?", new_sched_id);
     let new_task_id = rustrt::rust_new_task_in_sched(new_sched_id);
+    assert !new_task_id.is_null();
     let f = fn~() {
         let child_sched_id = rustrt::rust_get_sched_id();
         #error("child_sched_id %?", child_sched_id);
@@ -33,4 +34,4 @@ fn main() unsafe {
     rustrt::start_task(new_task_id, fptr);
     unsafe::forget(f);
     comm::recv(po);
-}
\ No newline at end of file
+}