weixin_39817347 2020-11-29 13:27
浏览 0

[drmem] DrMemory doesn't handle thread creation correctly

From timurrrr.com on April 05, 2010 10:50:58

I've been testing Chromium base_unittests under DrMemory 1.0.10 on Windows and sometimes it was giving me some strange reports when threads were created. I was able to reproduce these reports by running ThreadSanitizer unittests. Here is a short reproducer:

include

include

class MyThread { public: typedef void (*worker_t)();

MyThread(worker_t worker, const char *name = NULL) :w_(worker), name_(name) {}

~MyThread(){}

void Start() { DWORD thr_id = 0; t_ = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadBody, this, 0, &thr_id); // Line 15 }

void Join() { ::WaitForSingleObject(t_, INFINITE); }

HANDLE tid() const { return t_; } private: static DWORD WINAPI ThreadBody(MyThread my_thread) { if (my_thread->name_) { // Line 25 printf("Started thread '%s'\n", my_thread->name_); }
my_thread->w_(); // Line 28 return 0; } HANDLE t_; worker_t w_; const char
name_; };

void foo() { printf("foo()\n"); }

int main() { MyThread mt(foo); mt.Start(); mt.Join(); // Line 43 return 0; }

To my mind, this code doesn't have any uninitialized reads.

Here is the report: Error #1: UNINITIALIZED READ 136 byte(s) Elapsed time = 0:00:00.734 in thread 5768 system call NtCreateThread
0x7c8106f5 KERNEL32.dll!CreateThread+0x1e ??:0 0x00401149 test.exe!MyThread::Start+0x29 z:\dr-sandbox\test.cc:15+0x19 0x0040108d test.exe!main+0x1d z:\dr-sandbox\test.cc:43+0x0 0x00401510 test.exe!__tmainCRTStartup+0x15f f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c:327+0x12 0x7c817077 KERNEL32.dll!RegisterWaitForInputIdle+0x49 ??:0

Error #2: UNADDRESSABLE ACCESS 1 byte(s) Elapsed time = 0:00:00.781 in thread 4368 0x7c91b02a ntdll.dll!RtlUnicodeStringToInteger+0x199 ??:0

Error #3: UNADDRESSABLE ACCESS 1 byte(s) Elapsed time = 0:00:00.781 in thread 4368 system call NtContinue

Error #4: UNINITIALIZED READ Elapsed time = 0:00:00.797 in thread 4368 0x00401186 test.exe!MyThread::ThreadBody+0x6 z:\dr-sandbox\test.cc:25+0x3 0x7c80b729 KERNEL32.dll!GetModuleFileNameA+0x1ba ??:0

Error #5: UNINITIALIZED READ Elapsed time = 0:00:00.797 in thread 4368 0x004011a3 test.exe!MyThread::ThreadBody+0x23 z:\dr-sandbox\test.cc:28+0x3 0x7c80b729 KERNEL32.dll!GetModuleFileNameA+0x1ba ??:0

Original issue: http://code.google.com/p/dynamorio/issues/detail?id=286

该提问来源于开源项目:DynamoRIO/dynamorio

  • 写回答

14条回答 默认 最新

  • weixin_39817347 2020-11-29 13:27
    关注

    From derek.br....com on April 05, 2010 08:03:21

    note to me: this is PR 534421

    Status: Accepted

    评论

报告相同问题?