@@ -108,6 +108,11 @@ void Trick::ClassicCheckPointAgent::write_decl(std::ostream& chkpnt_os, ALLOC_IN
108108
109109 const char *type_spec;
110110
111+ // Safety check for NULL info pointer or NULL name
112+ if (info == NULL || info->name == NULL ) {
113+ return ;
114+ }
115+
111116 type_spec = trickTypeCharString (info->type , info->user_type_name );
112117
113118 if (info->stcl == TRICK_EXTERN) {
@@ -828,20 +833,33 @@ std::string Trick::ClassicCheckPointAgent::
828833 alloc_info = mem_mgr->get_alloc_info_of ( pointer);
829834
830835 if (alloc_info != NULL ) {
831- int alloc_elem_size;
832- int alloc_elem_index;
833- int misalignment;
836+ // Special handling for character strings: prefer string literal format over allocation reference
837+ // The following info for "char *" is for reference purpose:
838+ // curr_dim = 0
839+ // attr.type = TRICK_CHARACTER (base type)
840+ // attr.num_index = 1 (1D array)
841+ // attr.index[0].size = 0 (not static array)
842+ // attr.size = sizeof(char)
843+ // This prevents anonymous allocations from appearing in subsequent checkpoints
844+ if ((attr != NULL ) && (attr->type == TRICK_CHARACTER || attr->type == TRICK_UNSIGNED_CHARACTER) && ((curr_dim + 1 ) == attr->num_index )) {
845+ std::stringstream ss;
846+ write_quoted_str ( ss, (const char *)pointer);
847+ reference_string = ss.str ();
848+ } else {
849+ int alloc_elem_size;
850+ int alloc_elem_index;
851+ int misalignment;
834852
835- alloc_elem_size = alloc_info->size ;
836- alloc_elem_index = (int ) (((long ) pointer - (long ) alloc_info->start ) / alloc_elem_size);
837- misalignment = (int ) (((long ) pointer - (long ) alloc_info->start ) % alloc_elem_size);
853+ alloc_elem_size = alloc_info->size ;
854+ alloc_elem_index = (int ) (((long ) pointer - (long ) alloc_info->start ) / alloc_elem_size);
855+ misalignment = (int ) (((long ) pointer - (long ) alloc_info->start ) % alloc_elem_size);
838856
839- // If type-checking AND the type specifiers match AND the type we're looking for
840- // is either not structured or if it is, the attr-list that describes the contents
841- // of the structure is the same.
857+ // If type-checking AND the type specifiers match AND the type we're looking for
858+ // is either not structured or if it is, the attr-list that describes the contents
859+ // of the structure is the same.
842860
843- if ( (attr != NULL ) && (attr->type == alloc_info->type ) &&
844- ( (attr->type != TRICK_STRUCTURED) || (attr->attr == alloc_info->attr ))) {
861+ if ( (attr != NULL ) && (attr->type == alloc_info->type ) &&
862+ ( (attr->type != TRICK_STRUCTURED) || (attr->attr == alloc_info->attr ))) {
845863
846864 int ii;
847865 int n_l_ptrs, n_r_ptrs;
@@ -945,6 +963,7 @@ std::string Trick::ClassicCheckPointAgent::
945963 }
946964 }
947965
966+ }
948967 }
949968 } else if ((attr != NULL ) && ((curr_dim + 1 ) == attr->num_index )) {
950969
0 commit comments