locked
Leaked Handles in CTime contructor? RRS feed

  • Question

  • Using AppVerifier I always get 14 leaked CRITSEC-Handles in my App. I now made a complete new MFC project using WM6 SDK. The only thing I add is the CTime test(2000,1,1,1,1,1,-1); at the OnInitDialog function.
    If I now run the app beeing watched by AppVerifier, resulting log shows 14 leaked handles (if I remove the CTime-line the leaked handles are gone).

    Leaked 14 handles that were allocated at this stack
    (nk.exe:88037914) Leaked handle values:
    (nk.exe:88037914) CRITSEC Handle = 0x000a4960 ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a4974 ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a4988 ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a499c ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a49b0 ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a49c4 ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a49d8 ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a49ec ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a4a00 ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a4a14 ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a4a28 ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a4a3c ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a4a50 ''
    (nk.exe:88037914) CRITSEC Handle = 0x000a4a64 ''
    (nk.exe:88037914) CALL STACK
    (nk.exe:88037914) PC=0x15815970 shim_hleak.dll!(null) + 5970h
    (nk.exe:88037914) PC=0x15815880 shim_hleak.dll!(null) + 5880h
    (nk.exe:88037914) PC=0x15815ee0 shim_hleak.dll!(null) + 5ee0h
    (nk.exe:88037914) PC=0x1407db30 ??????!(null) + 7db30h
    (nk.exe:88037914) PC=0x1407db70 ??????!(null) + 7db70h
    (nk.exe:88037914) PC=0x1407d90c ??????!(null) + 7d90ch
    (nk.exe:88037914) PC=0x1407daa0 ??????!(null) + 7daa0h
    (nk.exe:88037914) PC=0x1407becc ??????!(null) + 7becch
    (nk.exe:88037914) PC=0x14079254 ??????!(null) + 79254h
    (nk.exe:88037914) PC=0x140793c0 ??????!(null) + 793c0h
    (nk.exe:88037914) PC=0x14015418 ??????!(null) + 15418h
    (nk.exe:88037914) PC=0x140154a8 ??????!(null) + 154a8h
    (nk.exe:88037914) PC=0x1401fa70 ??????!(null) + 1fa70h
    (nk.exe:88037914) PC=0x1405d408 ??????!(null) + 5d408h
    (nk.exe:88037914) PC=0x1407dc14 ??????!(null) + 7dc14h
    (nk.exe:88037914) PC=0x140785ac ??????!(null) + 785ach
    (nk.exe:88037914) PC=0x03f67760 coredll.dll!(null) + 1d760h
    


    As many times the mapping of the function names didn't work in this simple project. On my real app I on the other hand was able to get the real function names. Here is the interesting part:


    Leaked 14 handles that were allocated at this stack
    (nk.exe:88037914) Leaked handle values:
    ...
    (nk.exe:88037914) CALL STACK
    (nk.exe:88037914) PC=0x1d815970 shim_hleak.dll!(null) + 5970h
    (nk.exe:88037914) PC=0x1d815880 shim_hleak.dll!(null) + 5880h
    (nk.exe:88037914) PC=0x1d815ee0 shim_hleak.dll!(null) + 5ee0h
    (nk.exe:88037914) PC=0x1c080534 MyApp.exe!__crtInitCritSecNoSpinCount + ch
    (nk.exe:88037914) PC=0x1c080574 MyApp.exe!__crtInitCritSecAndSpinCount + 24h
    (nk.exe:88037914) PC=0x1c080310 MyApp.exe!_mtinitlocks + 38h
    (nk.exe:88037914) PC=0x1c0804a4 MyApp.exe!_lock + 20h
    (nk.exe:88037914) PC=0x1c07e8d0 MyApp.exe!__tzset + 28h
    (nk.exe:88037914) PC=0x1c07bc58 MyApp.exe!_make__time64_t + 314h
    (nk.exe:88037914) PC=0x1c07bdc4 MyApp.exe!_mktime64 + 10h
    (nk.exe:88037914) PC=0x1c015418 MyApp.exe!??0CTime@ATL@@QAA@HHHHHHH@Z + d0h
    (nk.exe:88037914) PC=0x1c0154a8 MyApp.exe!??0CTime@ATL@@QAA@ABU_SYSTEMTIME@@H@Z + 5ch
    ...

    Could anyone explain to me why this is happening? How should we be able to provide a app for the marketplace certification that passes AppVerifier if I get leaked handles by such a small and correct line of code - or how else should I create/destroy a CTime object?

    Any comment would be highly apreciated!
     Maik
    • Edited by MSWiege Thursday, July 2, 2009 10:59 AM
    Thursday, July 2, 2009 10:56 AM

Answers

  • Hi MSWiege,

    As far as I know, this is normal behavior. I have tried the sample like you said, I also got these handle leak. If we enclose code with braces. Like the code below, we won't get these handles leak:
    {
    CTime test(2000,1,1,1,1,1,-1);
    }

    The two braces means that once it run out of it, it will dispose all the resources.


    AppVerifier compare two snapshots to detect leak. I am not aware of when it record the snapshot. But we know  if we dispose test object, it will not get these handle leak.



    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    • Marked as answer by MSWiege Tuesday, July 7, 2009 6:11 PM
    Tuesday, July 7, 2009 9:57 AM

All replies

  • Hi MSWiege,

    As far as I know, this is normal behavior. I have tried the sample like you said, I also got these handle leak. If we enclose code with braces. Like the code below, we won't get these handles leak:
    {
    CTime test(2000,1,1,1,1,1,-1);
    }

    The two braces means that once it run out of it, it will dispose all the resources.


    AppVerifier compare two snapshots to detect leak. I am not aware of when it record the snapshot. But we know  if we dispose test object, it will not get these handle leak.



    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    • Marked as answer by MSWiege Tuesday, July 7, 2009 6:11 PM
    Tuesday, July 7, 2009 9:57 AM
  • Thank you to confirming this behavior. I will test it with the braces to finally get rid of the last leaks in my app. I also still have a similar problem with a CString. I will check if it is likewise correctable.
    Tuesday, July 7, 2009 6:11 PM