c ++调试器在崩溃时停止在错误的位置,VS10 win7

c++ debugger stops in wrong place on crash, VS10 win7

这是我编写的一个小程序,用于重现我得到的错误:

#include <assert.h>
int main(int argc, char **argv)
{
    int* nPtr = 0;
    *nPtr = 5;

    //assert(0 && "testing");

    //static int nZero = 0;
    //static float x = 5 / nZero;

    return 0;
}

调用堆栈错误,现在可以追溯错误。 我在 32 位中没有优化编译。 pdb 与 exe 匹配。

这是我得到的调用栈:

ntdll.dll!76f615de()    
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
ntdll.dll!76f615de()    
ntdll.dll!76f5014e()    
msvcr100d.dll!_unlock(int locknum)  Line 375    C
003df930()  
cccccccc()  

非常感谢, 叶夫根

您的代码已损坏。 当您写入时,您的指针未指向有效的 int 。这是未定义的行为,您的编译器可能会生成它想要的任何内容。 调试器中的堆栈跟踪没有意义是无关紧要的,因为没有办法知道会发生什么 - 这就是 undefined 行为的本质。

整数*p=0 ,表示p指向0x00000000,不可访问。所以你改*p,会导致pession denied

我在 here

中找到了我想要的答案

简而言之,AVX在异常后导致调用栈出错

您可以通过以下方式关闭 AVX:

bcdedit /set xsavedisable 1

重新启动计算机