DynamoRIO / DynamoRIO/drmemory

CRASH (-replace_malloc on wincrt and wincrtdbg tests)

Open
#950 4 comments 0 reactions 0 assignees View on GitHub
Component-Tests Migrated Priority-Medium
Dominant language
C
Stars
2.7k
Forks
290
PR merge metrics
No merged PRs in 30d

Description

_From [bruen...@google.com](https://code.google.com/u/109494838902877177630/) on July 20, 2012 15:08:01_

the test clobbers the header:
static void
oob_write_test(void)
{
/\* test issue #51: this should NOT raise a msgbox from dbgcrt _/
unsigned char *foo = (unsigned char_) malloc(8);
*(foo-1) = 0xab;
free(foo);
}

which then clobbers user_data:
Local var @ 0xa8f934 Type _chunk_header_t*
0x01374110
+0x000 request_size : 8
+0x004 alloc_size : 8
+0x008 flags : 1
+0x00a magic : 0x5244
+0x00c user_data : 0xabb5e5d4

which causes a crash:
0:000> kn
**\* Stack trace for last set context - .thread/.cxr resets it
# ChildEBP RetAddr
00 00a8f7b4 7396add8 drmemorylib!atomic_add32_return_sum+0x9 [d:\derek\drmemory\git\src\common\utils.h @ 479]
01 00a8f7f0 73974b0a drmemorylib!packed_callstack_free+0x2a8 [d:\derek\drmemory\git\src\common\callstack.c @ 1570]
02 00a8f828 73978a66 drmemorylib!shared_callstack_free+0x1a [d:\derek\drmemory\git\src\drmemory\alloc_drmem.c @ 343]
03 00a8f888 7394bbe3 drmemorylib!client_malloc_data_to_free_list+0x556 [d:\derek\drmemory\git\src\drmemory\alloc_drmem.c @ 891]
04 00a8f940 7394c1bf drmemorylib!replace_free_common+0x833 [d:\derek\drmemory\git\src\common\alloc_replace.c @ 918]
05 00a8fac8 013312f1 drmemorylib!replace_free+0x1af [d:\derek\drmemory\git\src\common\alloc_replace.c @ 1303]
06 00a8fad8 01331107 wincrt!oob_write_test+0x21 [d:\derek\drmemory\git\src\tests\wincrt.cpp @ 97]
07 00a8fae0 01331dbd wincrt!main+0x17 [d:\derek\drmemory\git\src\tests\wincrt.cpp @ 110]

it is reported:
~~Dr.M~~ Error `#5`: UNADDRESSABLE ACCESS: writing 0x0137411f-0x01374120 1 byte(s)
~~Dr.M~~ # 0 oob_write_test [d:\derek\drmemory\git\src\tests\wincrt.cpp:96]
~~Dr.M~~ # 1 main [d:\derek\drmemory\git\src\tests\wincrt.cpp:109]
~~Dr.M~~ Note: @0:00:02.785 in thread 6504
~~Dr.M~~ Note: next higher malloc: 0x01374120-0x01374128
~~Dr.M~~ Note: prev lower malloc: 0x01373f20-0x01373fa0

so how can we get drmem to report this as an app crash? we could implement DRi#50 and see whether the fault is in the alloc_replace code (not sure how to tell: check each one by name, or set flag)

_Original issue: http://code.google.com/p/drmemory/issues/detail?id=950_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.