From c76b81cddf7cd7b4aaebbe64bbf8c6565e3ce682 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 4 Feb 2012 23:42:27 -0800 Subject: rt: Delete schedulers immediately upon release This will be needed once we support dynamically changing schedulers. --- src/rt/rust_scheduler.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/rt/rust_scheduler.cpp') diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp index 904eb5cafcb..666733a4318 100644 --- a/src/rt/rust_scheduler.cpp +++ b/src/rt/rust_scheduler.cpp @@ -56,6 +56,11 @@ rust_scheduler::destroy_task_threads() { void rust_scheduler::start_task_threads() { + // Copy num_threads because it's possible for the last thread + // to terminate and have the kernel delete us before we + // hit the last check against num_threads, in which case + // we would be accessing invalid memory. + uintptr_t num_threads = this->num_threads; for(size_t i = 0; i < num_threads; ++i) { rust_task_thread *thread = threads[i]; thread->start(); -- cgit 1.4.1-3-g733a5