Skip to content

Commit

Permalink
Fix bug on tool.drcacheoff.getretaddr_record_replace_retaddr
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav92003 committed Nov 22, 2023
1 parent 5a54cb6 commit c7c5575
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions clients/drcachesim/tracer/instru_offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,11 @@ offline_instru_t::record_instr_encodings(void *drcontext, app_pc tag_pc,
dr_app_pc_as_jump_target(instr_get_isa_mode(instrlist_first(ilist)), tag_pc));
log_(2, "%s: Recorded %zu bytes for id " UINT64_FORMAT_STRING " @ %p\n", __FUNCTION__,
enc->length, enc->id, tag_pc);
DR_ASSERT(enc->length > sizeof(encoding_entry_t));
encoding_length_ += (enc->length - sizeof(encoding_entry_t));
// TODO i#2062: If the ilist does not have any app instr, we still somehow need to
// write an entry to the encoding file. For now we keep this behavior. This
// reproduces on the tool.drcacheoff.getretaddr_record_replace_retaddr test.
DR_ASSERT(enc->length >= sizeof(encoding_entry_t));
encoding_length_ += enc->length;
encoding_buf_ptr_ += enc->length;
dr_mutex_unlock(encoding_lock_);
}
Expand Down
4 changes: 2 additions & 2 deletions clients/drcachesim/tracer/raw2trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,12 @@ module_mapper_t::do_encoding_parsing()
uint64_t cumulative_encoding_length = 0;
while (map_at < map_end) {
encoding_entry_t *entry = reinterpret_cast<encoding_entry_t *>(map_at);
if (entry->length <= sizeof(encoding_entry_t))
if (entry->length < sizeof(encoding_entry_t))
return "Encoding file is corrupted";
if (map_at + entry->length > map_end)
return "Encoding file is truncated";
cum_block_enc_len_to_encoding_id_[cumulative_encoding_length] = entry->id;
cumulative_encoding_length += (entry->length - sizeof(encoding_entry_t));
cumulative_encoding_length += entry->length;
encodings_[entry->id] = entry;
map_at += entry->length;
}
Expand Down

0 comments on commit c7c5575

Please sign in to comment.