-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixing valgrind-mmt #7
base: mmt-3.14
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,6 +306,12 @@ static noinline struct mmt_mmap_data *mmt_bsearch(Addr addr) | |
struct mmt_mmap_data *region; | ||
int tmp; | ||
|
||
#ifdef MMT_DEBUG_VERBOSE | ||
mmt_bin_flush(); | ||
VG_(printf)("searching entry for: %p\n", (void*)addr); | ||
verify_state(); | ||
#endif | ||
|
||
if (UNLIKELY(mmt_last_region < 0)) | ||
{ | ||
add_neg(0, (Addr)-1); | ||
|
@@ -497,6 +503,23 @@ void mmt_free_region(struct mmt_mmap_data *m) | |
(mmt_last_region - idx) * sizeof(struct mmt_mmap_data)); | ||
VG_(memset)(&mmt_mmaps[mmt_last_region--], 0, sizeof(struct mmt_mmap_data)); | ||
|
||
/* if we only have one reagion, delete 0-x negative region */ | ||
if (mmt_last_region == 0) { | ||
Bool found; | ||
do { | ||
found = False; | ||
for (i = 0; i < neg_regions_number; ++i) | ||
{ | ||
struct negative_region *neg = &neg_regions[i]; | ||
if (neg->end != (Addr)-1) { | ||
remove_neg_region(i); | ||
found = True; | ||
break; | ||
} | ||
} | ||
} while (found); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look right. It seems you are papering over bug somewhere else. How did the bug manifest? Where is the code that "assumes there is only one negative entry if there is just one positive one"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's kind of mmt_bsearch.. but I think the condition is a bit more complicated:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MMT state gets inconsistent at this line: "adding negative entry: <0x0, 0x5D96000>", so the issue indeed comes from mmt_bsearch - it calls add_neg with parameters it has not verifed are not conflicting with existing negative entries. The proposed solution is not correct though. I'm fixing this right now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, thanks! |
||
|
||
/* if we are releasing last used region, then zero cache */ | ||
if (m == last_used_region) | ||
last_used_region = &null_region; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo