From: Brian Norris Date: Tue, 24 Apr 2012 03:16:05 +0000 (-0700) Subject: threads: cleanup inconsistencies in memory management X-Git-Tag: pldi2013~512 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=514298ff6ed5841ee771673e7f58885ade0c700e;p=model-checker.git threads: cleanup inconsistencies in memory management --- diff --git a/threads.cc b/threads.cc index 7d4d22e..7e23f59 100644 --- a/threads.cc +++ b/threads.cc @@ -58,7 +58,8 @@ void Thread::complete() if (state != THREAD_COMPLETED) { DEBUG("completed thread %d\n", get_id()); state = THREAD_COMPLETED; - stack_free(stack); + if (stack) + stack_free(stack); } } @@ -85,10 +86,11 @@ Thread::Thread(thrd_t *t) { start_routine = NULL; arg = NULL; + create_context(); + stack = NULL; state = THREAD_CREATED; id = model->get_next_id(); *user_thread = id; - create_context(); model->add_system_thread(this); }