Debug Assertion Failed! Expression: __acrt_first_block == header

前端 未结 5 1414
星月不相逢
星月不相逢 2020-11-30 01:01

I am trying to test the dll which I wrote with GoogleTest and when I call one of the tests It throws me this error:

5条回答
  •  佛祖请我去吃肉
    2020-11-30 01:31

    I encountered the same error and I found a way to get more information about the cause of the problem: It is possible to set with visual studio a breakpoint condition on the line that raise this error (so that the debugger breaks before the error message).

    It is necessary to open the corresponding file (debug_heap.cpp,somewhere in "C:\Program Files (x86)\Windows Kits\10\Source") and to write the following condition:

    Then we can continue debugging and when the breakpoint is hit, we can observe the address of the block that raise the error (the "block" argument of the "free_dbg_nolock" function that contains the breakpoint).

    From there you can observe the memory content of the block by copying the address into the memory window (Debug->Windows->Memory). If you are lucky it may be a string or an easily recognizable variable.

    You can then identify the variable that causes the bug and try to fix it.

    In my case it was a variable that was created in one dll and deleted in another. To correct it I replaced all my objects by pointers to these objects in one dll.

提交回复
热议问题