weixin_39817347 2020-11-30 07:35
浏览 0

need to hide system reachable leaks to make -show_reachable usable on Windows

From bruen....com on September 22, 2011 14:35:29

split from issue #590 . over a hundred in a tiny Windows app. only a handful of pre-DR-control: even w/o them, still a ton of system allocs. should try to distinguish the system ones.

Original issue: http://code.google.com/p/drmemory/issues/detail?id=599

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

  • 写回答

5条回答 默认 最新

  • weixin_39817347 2020-11-30 07:35
    关注

    From bruen....com on September 06, 2013 13:26:10

    xref issue #1322 : suppress reachable leaks

    ** DONE reachable leaks on windows have far too many CRT init and pre-us leaks to be usable CLOSED: [2013-09-06 Fri 14:45] - State "DONE" from "TODO" [2013-09-06 Fri 14:45]

    On Linux, tests/leakcycle has 0 reachable allocations.

    On Windows it has 185:

    % bin/drmemory.exe -show_reachable -batch -dr d:/derek/dr/git/exports -- tests/leakcycle.exe

    ~~Dr.M~~ ERRORS IGNORED: ~~Dr.M~~ 185 still-reachable allocation(s) ~~Dr.M~~ (re-run with "-show_reachable" for details)

    REACHABLE LEAK 32 direct bytes 0x007800f8-0x00780118 + 0 indirect bytes

    0 replace_RtlAllocateHeap [d:\derek\drmemory\git\src\common\alloc_replace.c:3048]

    1 ntdll.dll!RtlRunOnceBeginInitialize +0x8d (0x77ae7ed9 )

    2 ntdll.dll!RtlInitializeCriticalSectionAndSpinCount +0x18 (0x77ae2641 )

    3 KERNELBASE.dll!InitializeCriticalSectionAndSpinCount +0x10 (0x75990ce7 )

    4 _mtinitlocks [f:\dd\vctools\crt_bld\self_x86\crt\src\mlock.c:147]

    5 KERNEL32.dll!BaseThreadInitThunk +0x11 (0x770133aa )

    6 ntdll.dll!RtlInitializeExceptionChain +0x62 (0x77ae9f72 )

    7 ntdll.dll!RtlInitializeExceptionChain +0x35 (0x77ae9f45 )

    There are a lot of these _setenvp ones:

    REACHABLE LEAK 62 direct bytes 0x00f83680-0x00f836be + 0 indirect bytes

    0 replace_calloc [d:\derek\drmemory\git\src\common\alloc_replace.c:2310]

    1 _calloc_crt [f:\dd\vctools\crt_bld\self_x86\crt\src\crtheap.c:61]

    2 _setenvp [f:\dd\vctools\crt_bld\self_x86\crt\src\stdenvp.c:127]

    3 KERNEL32.dll!BaseThreadInitThunk +0x11 (0x770133aa )

    4 ntdll.dll!RtlInitializeExceptionChain +0x62 (0x77ae9f72 )

    5 ntdll.dll!RtlInitializeExceptionChain +0x35 (0x77ae9f45 )

    REACHABLE LEAK 128 direct bytes 0x00f84d08-0x00f84d88 + 0 indirect bytes

    0 replace_calloc [d:\derek\drmemory\git\src\common\alloc_replace.c:2310]

    1 _calloc_crt [f:\dd\vctools\crt_bld\self_x86\crt\src\crtheap.c:61]

    2 __onexitinit [f:\dd\vctools\crt_bld\self_x86\crt\src\onexit.c:204]

    3 _cinit [f:\dd\vctools\crt_bld\self_x86\crt\src\crt0dat.c:278]

    4 __tmainCRTStartup [f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c:262]

    5 KERNEL32.dll!BaseThreadInitThunk +0x11 (0x770133aa )

    6 ntdll.dll!RtlInitializeExceptionChain +0x62 (0x77ae9f72 )

    7 ntdll.dll!RtlInitializeExceptionChain +0x35 (0x77ae9f45 )

    REACHABLE LEAK 4096 direct bytes 0x00f84df8-0x00f85df8 + 0 indirect bytes

    0 replace_malloc [d:\derek\drmemory\git\src\common\alloc_replace.c:2292]

    1 _malloc_crt [f:\dd\vctools\crt_bld\self_x86\crt\src\crtheap.c:44]

    2 _getbuf [f:\dd\vctools\crt_bld\self_x86\crt\src_getbuf.c:58]

    3 _flsbuf [f:\dd\vctools\crt_bld\self_x86\crt\src_flsbuf.c:153]

    4 write_char [f:\dd\vctools\crt_bld\self_x86\crt\src\output.c:2426]

    5 printf [f:\dd\vctools\crt_bld\self_x86\crt\src\printf.c:62]

    6 main [d:\derek\drmemory\git\src\tests\leakcycle.cpp:81]

    REACHABLE LEAK 104 direct bytes 0x00686b08-0x00686b70 + 0 indirect bytes

    REACHABLE LEAK 32 direct bytes 0x00686808-0x00686828 + 0 indirect bytes

    REACHABLE LEAK 16 direct bytes 0x00686d10-0x00686d20 + 0 indirect bytes

    If we moved pre-us to potential and suppressed anything allocated above these we could get all of them:

    _mtinitlocks _mtinit _ioinit _calloc_crt _malloc_crt

    _calloc_crt is only called by internal CRT code, right?

    helloMDd.exe has 196 reachable, but most are pre-us (b/c msvcrtd.dll initializes before we do) with just two non-pre-us:

    REACHABLE LEAK 38 direct bytes 0x00da00f8-0x00da011e + 0 indirect bytes

    0 replace_malloc [d:\derek\drmemory\git\src\common\alloc_replace.c:2292]

    1 MSVCR100D.dll!_setargv

    2 MSVCR100D.dll!__getmainargs

    3 pre_cpp_init [f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:298]

    4 MSVCR100D.dll!_initterm

    5 __tmainCRTStartup [f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:473]

    6 mainCRTStartup [f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c:370]

    7 KERNEL32.dll!BaseThreadInitThunk +0x11 (0x770133aa )

    8 ntdll.dll!RtlInitializeExceptionChain +0x62 (0x77ae9f72 )

    9 ntdll.dll!RtlInitializeExceptionChain +0x35 (0x77ae9f45 )

    REACHABLE LEAK 4096 direct bytes 0x00da0140-0x00da1140 + 0 indirect bytes

    0 replace_malloc [d:\derek\drmemory\git\src\common\alloc_replace.c:2292]

    1 MSVCR100D.dll!_getbuf

    2 MSVCR100D.dll!_flsbuf

    3 MSVCR100D.dll!_output_l

    4 MSVCR100D.dll!_output_l

    5 MSVCR100D.dll!printf

    6 main [d:\derek\dr\test\hello.c:11]

    It seems like issue #1310's "potential errors" should be applied here, except we also want to rule out these static CRT and the pre-us leaks.

    ** DONE treat as first-class error to get de-duplication and suppression CLOSED: [2013-09-06 Fri 14:45] - State "DONE" from "TODO" [2013-09-06 Fri 14:45]

    This by itself fixes most of issue #1322: suppress reachable leaks

    hello.exe is down from 186 entries to just 13:

    ~~Dr.M~~ 0 unique, 0 total, 0 byte(s) of leak(s) ~~Dr.M~~ 0 unique, 0 total, 0 byte(s) of possible leak(s) ~~Dr.M~~ 13 unique, 186 total, 45289 byte(s) of still-reachable allocation(s) ~~Dr.M~~ NO ERRORS IGNORED

    Error #1: REACHABLE LEAK 32 direct bytes 0x005900f8-0x00590118 + 0 indirect bytes

    0 replace_RtlAllocateHeap [d:\derek\drmemory\git\src\common\alloc_replace.

    c:3048]

    1 ntdll.dll!RtlRunOnceBeginInitialize +0x8d (0x77ae7ed9 )

    2 ntdll.dll!RtlInitializeCriticalSectionAndSpinCount +0x18 (0x77ae2641 )

    3 KERNELBASE.dll!InitializeCriticalSectionAndSpinCount +0x10 (0x75990ce7 )

    4 _mtinitlocks [f:\dd\vctools\crt_bld\self_x86\crt\src\mlock.c:

    147]

    5 KERNEL32.dll!BaseThreadInitThunk +0x11 (0x770133aa )

    6 ntdll.dll!RtlInitializeExceptionChain +0x62 (0x77ae9f72 )

    7 ntdll.dll!RtlInitializeExceptionChain +0x35 (0x77ae9f45 )

    Error #2: REACHABLE LEAK 520 direct bytes 0x00590478-0x00590680 + 0 indirect bytes

    0 replace_RtlAllocateHeap [d:\derek\drmemory\git\src\common\alloc_replace.c:3048]

    1 ntdll.dll!RtlGetNtVersionNumbers +0x118 (0x77af68ea )

    2 KERNELBASE.dll!FlsAlloc +0x11 (0x75993d78 )

    3 _mtinit [f:\dd\vctools\crt_bld\self_x86\crt\src\tidtable.c:274]

    4 KERNEL32.dll!BaseThreadInitThunk +0x11 (0x770133aa )

    5 ntdll.dll!RtlInitializeExceptionChain +0x62 (0x77ae9f72 )

    6 ntdll.dll!RtlInitializeExceptionChain +0x35 (0x77ae9f45 )

    Error #3: REACHABLE LEAK 1024 direct bytes 0x005906a0-0x00590aa0 + 0 indirect bytes

    0 replace_RtlAllocateHeap [d:\derek\drmemory\git\src\common\alloc_replace.c:3048]

    1 ntdll.dll!RtlGetNtVersionNumbers +0x193 (0x77af6965 )

    2 KERNELBASE.dll!FlsAlloc +0x11 (0x75993d78 )

    3 _mtinit [f:\dd\vctools\crt_bld\self_x86\crt\src\tidtable.c:274]

    4 KERNEL32.dll!BaseThreadInitThunk +0x11 (0x770133aa )

    5 ntdll.dll!RtlInitializeExceptionChain +0x62 (0x77ae9f72 )

    6 ntdll.dll!RtlInitializeExceptionChain +0x35 (0x77ae9f45 )

    Error #4: REACHABLE LEAK 32 direct bytes 0x00590ac0-0x00590ae0 + 0 indirect bytes

    0 replace_RtlAllocateHeap ...

    评论

报告相同问题?