forked from OSchip/llvm-project
[asan] canonicalise the output for double-free and wrong-free. fixes asan issue 18
llvm-svn: 146501
This commit is contained in:
parent
0e5704607b
commit
d47a91ad2a
|
@ -690,12 +690,13 @@ static void Deallocate(uint8_t *ptr, AsanStackTrace *stack) {
|
|||
// Printf("Deallocate %p\n", ptr);
|
||||
AsanChunk *m = PtrToChunk((uintptr_t)ptr);
|
||||
if (m->chunk_state == CHUNK_QUARANTINE) {
|
||||
Printf("attempting double-free on %p:\n", ptr);
|
||||
Report("ERROR: AddressSanitizer attempting double-free on %p:\n", ptr);
|
||||
stack->PrintStack();
|
||||
m->DescribeAddress((uintptr_t)ptr, 1);
|
||||
ShowStatsAndAbort();
|
||||
} else if (m->chunk_state != CHUNK_ALLOCATED) {
|
||||
Printf("attempting free on address which was not malloc()-ed: %p\n", ptr);
|
||||
Report("ERROR: AddressSanitizer attempting free on address which was not"
|
||||
" malloc()-ed: %p\n", ptr);
|
||||
stack->PrintStack();
|
||||
ShowStatsAndAbort();
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ static inline bool RangesOverlap(const char *offset1, const char *offset2,
|
|||
const char *offset2 = (const char*)_offset2; \
|
||||
if (RangesOverlap((const char*)offset1, (const char*)offset2, \
|
||||
length)) { \
|
||||
Printf("ERROR: AddressSanitizer strcpy-param-overlap: " \
|
||||
Report("ERROR: AddressSanitizer strcpy-param-overlap: " \
|
||||
"memory ranges [%p,%p) and [%p, %p) overlap\n", \
|
||||
offset1, offset1 + length, offset2, offset2 + length); \
|
||||
PRINT_CURRENT_STACK(); \
|
||||
|
|
|
@ -606,7 +606,8 @@ void WrongFree() {
|
|||
}
|
||||
|
||||
TEST(AddressSanitizer, WrongFreeTest) {
|
||||
EXPECT_DEATH(WrongFree(), "attempting free.*not malloc");
|
||||
EXPECT_DEATH(WrongFree(),
|
||||
"ERROR: AddressSanitizer attempting free.*not malloc");
|
||||
}
|
||||
|
||||
void DoubleFree() {
|
||||
|
@ -619,7 +620,7 @@ void DoubleFree() {
|
|||
}
|
||||
|
||||
TEST(AddressSanitizer, DoubleFreeTest) {
|
||||
EXPECT_DEATH(DoubleFree(), "attempting double-free");
|
||||
EXPECT_DEATH(DoubleFree(), "ERROR: AddressSanitizer attempting double-free");
|
||||
}
|
||||
|
||||
template<int kSize>
|
||||
|
|
Loading…
Reference in New Issue