initialize memory location first
[c11tester.git] / history.cc
index 5af063e3756fc08de613582d90edb4f458a46b0d..c1c9edf5ae16bf9f4bd47b53333512e6e571ab31 100644 (file)
@@ -29,9 +29,12 @@ void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid)
        if ( thrd_func_list->size() <= id ) {
                uint oldsize = thrd_func_list->size();
                thrd_func_list->resize( id + 1 );
-               for(uint i=oldsize;i<id+1;i++) {
+               for (uint i = oldsize; i < id + 1; i++) {
                        new(&(*thrd_func_list)[i]) func_id_list_t();
+                       // push 0 as a dummy function id to a void seg fault
+                       (*thrd_func_list)[i].push_back(0);
                }
+
                thrd_func_inst_lists->resize( id + 1 );
        }
 
@@ -108,7 +111,9 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
        uint32_t func_id = (*thrd_func_list)[id].back();
        SnapList<func_inst_list_t *> * func_inst_lists = thrd_func_inst_lists->at(id);
 
-       if ( func_nodes.size() <= func_id )
+       if (func_id == 0)
+               return;
+       else if ( func_nodes.size() <= func_id )
                resize_func_nodes( func_id + 1 );
 
        FuncNode * func_node = func_nodes[func_id];
@@ -120,8 +125,8 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
        if (inst == NULL)
                return;
 
-       //      if (inst->is_read())
-       //      func_node->store_read(act, tid);
+       if (inst->is_read())
+               func_node->store_read(act, tid);
 
        if (inst->is_write())
                add_to_write_history(act->get_location(), act->get_write_value());