mymemory: enforce that user allocations come from user context
authorBrian Norris <banorris@uci.edu>
Sat, 9 Mar 2013 20:54:58 +0000 (12:54 -0800)
committerBrian Norris <banorris@uci.edu>
Sat, 9 Mar 2013 20:54:58 +0000 (12:54 -0800)
model.cc
mymemory.cc
schedule.cc

index 0cc20794d61f1217163743de2f3147459d5d1466..2aa94cfd84b4da470277f0ea81f6118d880e9f3e 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -3021,6 +3021,7 @@ uint64_t ModelChecker::switch_to_master(ModelAction *act)
 {
        DBG();
        Thread *old = thread_current();
+       scheduler->set_current_thread(NULL);
        ASSERT(!old->get_pending());
        old->set_pending(act);
        if (Thread::swap(old, &system_context) < 0) {
index ea8670d60ccdf7250307b7ae4bb55bc89f5507c5..c79ad9a47d8f2a6208f6f38853866fa77afdcf64 100644 (file)
@@ -8,6 +8,8 @@
 #include "mymemory.h"
 #include "snapshot.h"
 #include "common.h"
+#include "threads-model.h"
+#include "model.h"
 
 #define REQUESTS_BEFORE_ALLOC 1024
 
@@ -176,9 +178,11 @@ static void * user_malloc(size_t size)
  */
 void *malloc(size_t size)
 {
-       if (user_snapshot_space)
+       if (user_snapshot_space) {
+               /* Only perform user allocations from user context */
+               ASSERT(!model || thread_current());
                return user_malloc(size);
-       else
+       else
                return HandleEarlyAllocationRequest(size);
 }
 
index 1eb57d7515823012c51026db219af0e6e9bf0a77..62ba8fb3ff0ee631d960649286142d0608560135 100644 (file)
@@ -250,7 +250,7 @@ void Scheduler::set_scheduler_thread(thread_id_t tid) {
  */
 void Scheduler::set_current_thread(Thread *t)
 {
-       ASSERT(t && !t->is_model_thread());
+       ASSERT(!t || !t->is_model_thread());
 
        current = t;
        if (DBG_ENABLED())