From 3e2ec3ed4b37f4e6aa8e5e0e9e3241890948c3ac Mon Sep 17 00:00:00 2001 From: weiyu Date: Wed, 25 Mar 2020 12:48:50 -0700 Subject: [PATCH] Make our pthread id starts from 2. Reserve id 1 for main thread --- execution.cc | 15 +++++++++------ include/mutex.h | 1 - newfuzzer.cc | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/execution.cc b/execution.cc index de54394c..97e58511 100644 --- a/execution.cc +++ b/execution.cc @@ -53,7 +53,7 @@ ModelExecution::ModelExecution(ModelChecker *m, Scheduler *scheduler) : scheduler(scheduler), thread_map(2), /* We'll always need at least 2 threads */ pthread_map(0), - pthread_counter(1), + pthread_counter(2), action_trace(), obj_map(), condvar_waiters_map(), @@ -1605,18 +1605,21 @@ Thread * ModelExecution::get_thread(const ModelAction *act) const * @return A Thread reference */ Thread * ModelExecution::get_pthread(pthread_t pid) { + // pid 1 is reserved for the main thread, pthread ids should start from 2 + if (pid == 1) + return get_thread(pid); + union { pthread_t p; uint32_t v; } x; x.p = pid; uint32_t thread_id = x.v; - return get_thread(thread_id); // Temporary fix for firefox -/* - if (thread_id < pthread_counter + 1) return pthread_map[thread_id]; - else return NULL; -*/ + if (thread_id < pthread_counter + 1) + return pthread_map[thread_id]; + else + return NULL; } /** diff --git a/include/mutex.h b/include/mutex.h index 64473b2a..f5894952 100644 --- a/include/mutex.h +++ b/include/mutex.h @@ -14,7 +14,6 @@ struct mutex_state { void *locked; /* Thread holding the lock */ thread_id_t alloc_tid; modelclock_t alloc_clock; - int init; // WL }; class mutex { diff --git a/newfuzzer.cc b/newfuzzer.cc index fca9da8d..01eed86b 100644 --- a/newfuzzer.cc +++ b/newfuzzer.cc @@ -447,5 +447,5 @@ bool NewFuzzer::find_threads(ModelAction * pending_read) bool NewFuzzer::shouldWait(const ModelAction * act) { - return random() & 1; + return true; } -- 2.34.1