From e58ba61d8e86dd2a63620d67e22bd5b583cfeafa Mon Sep 17 00:00:00 2001 From: Alex Lin Date: Mon, 14 Sep 2015 11:33:11 -0500 Subject: [PATCH] MTV/variable server crashes if checkpoint has less malfunctions then currently running sim Did two things to stop the crash. 1. When following an address path if we hit a NULL address, stop processing and return the NULL. 2. When trying to resolve addresses in copy_sim_data, if a NULL address is returned then reset the reference to unresolved and return a dummy value. Need to fix MTV to handle dummy value returns. refs #117 --- .../sim_services/MemoryManager/follow_address_path.c | 4 ++++ .../VariableServerThread_copy_sim_data.cpp | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/trick_source/sim_services/MemoryManager/follow_address_path.c b/trick_source/sim_services/MemoryManager/follow_address_path.c index cc982635..90354ed1 100644 --- a/trick_source/sim_services/MemoryManager/follow_address_path.c +++ b/trick_source/sim_services/MemoryManager/follow_address_path.c @@ -24,6 +24,10 @@ void * follow_address_path(REF2 * R) { address = (void *)((char *)address + address_node->operand.offset) ; break ; } + // If we resolve a pointer to NULL this variable is now bad. + if (address == NULL) { + break ; + } } return(address) ; diff --git a/trick_source/sim_services/VariableServer/VariableServerThread_copy_sim_data.cpp b/trick_source/sim_services/VariableServer/VariableServerThread_copy_sim_data.cpp index 699713c2..05ba4284 100644 --- a/trick_source/sim_services/VariableServer/VariableServerThread_copy_sim_data.cpp +++ b/trick_source/sim_services/VariableServer/VariableServerThread_copy_sim_data.cpp @@ -32,7 +32,17 @@ int Trick::VariableServerThread::copy_sim_data() { // if there's a pointer somewhere in the address path, follow it in case pointer changed if ( curr_var->ref->pointer_present == 1 ) { curr_var->address = follow_address_path(curr_var->ref) ; - curr_var->ref->address = curr_var->address ; + if ( curr_var->address == NULL ) { + std::string save_name(curr_var->ref->reference) ; + if ( curr_var->ref->attr) { + free(curr_var->ref->attr) ; + } + free(curr_var->ref) ; + curr_var->ref = make_error_ref(save_name) ; + curr_var->address = curr_var->ref->address ; + } else { + curr_var->ref->address = curr_var->address ; + } } // if this variable is a string we need to get the raw character string out of it.