错误的位置我有一个简单的代码:的Visual Studio秀SEH异常
#include "stdafx.h"
#include <iostream>
void foo()
{
int* p = 0;
*p = 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "123";
foo();
std::cout << "456";
return 0;
}
默认调试Visual Studio设置。调试 - >例外 - >全部重置。
在调试配置中运行此代码后的结果 - 我得到异常在exc.exe中的0x77d315de(ntdll.dll)未处理的异常:0xC0000005:访问冲突写入位置0x00000000。 VS打开文件ostream的,指针停留在这里:
_Ostr.setstate(_State);
return (_Ostr);
} <--
堆栈跟踪:
[email protected]() + 0x12 bytes
[email protected]() + 0x12 bytes
exc.exe!std::operator<<<std::char_traits<char> >(std::basic_ostream<char,std::char_traits<char> > & _Ostr={...}, const char * _Val=0x00000000) Line 808 + 0xf bytes C++
> exc.exe!wmain(int argc=0x00000001, wchar_t * * argv=0x00164810) Line 14 C++
exc.exe!__tmainCRTStartup() Line 552 + 0x19 bytes C
exc.exe!wmainCRTStartup() Line 371 C
[email protected]@12() + 0x12 bytes
[email protected]() + 0x27 bytes
[email protected]() + 0x1b bytes
如果我设置复选框在调试 “时抛出” - > Win32异常 - > 0000005 Visual Studio中右停止地点。
我的同事有相同的Visual Studio,Windows 7 x64和相同的硬件。但是他的VS在正确的地方停留,没有改变例外设置。
我的Visual Studio的设置有什么问题?
最大的问题 - 具有.net例外的行为并不典型。此时在调试模式下VS几乎忽略了所有的异常。看起来像我有全局异常过滤器,并处理所有异常。程序可以在发布模式下运行并显示对话框Catel mvvm工具包会向我发送垃圾邮件,但有关未注册的模型和文件系统异常的例外情况。
任何想法,我怎样才能修复它没有设置“投掷”复选框。
[编辑]
好吧,我发现了一些奇怪的事情。更改调试 - >异常后,我停下来与异常。但是,如果我按继续,我要去ostream文件。看起来像VS debuger默认按“继续”。
[编辑]
First-chance exception at 0x012514cf in exc.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x773515de (ntdll.dll) in exc.exe: 0xC0000005: Access violation writing location 0x00000000.
这就是我在输出中看到。只有一个例外。看起来异常是以某种方式处理的,然后在其他地方被抛出。
很难解释。除此之外,我们没有看到真实的代码。在有16行代码的程序中没有“第17行”。 –
您的Debug版本是否在某种程度上打开了优化? –
更新了堆栈跟踪。行号现在是正确的。 – kuperspb