简体   繁体   English

第一次机会异常(ntdll.dll)

[英]First-chance exception (ntdll.dll)

Any ideas why I am getting this error? 任何想法为什么我收到此错误?

This is the full error: 这是完整的错误:

First-chance exception at 0x77202282 (ntdll.dll) in Test.exe 0xC0000005: Access violation writing location 0x0000004 Test.exe 0xC0000005中0x77202282(ntdll.dll)的第一次机会异常:访问冲突写入位置0x0000004

Unhandle exception at 0x77202282 (ntdll.dll) in Test.exe 0xC0000005: Access violation writing location 0x0000004 在Test.exe 0xC0000005中的0x77202282(ntdll.dll)处取消异常处理:访问冲突写入位置0x0000004

  • Debugging breaks at the line Grid::Grid() . 调试在Grid::Grid()行中断。
  • Root.hpp contains a private member static Grid grid; Root.hpp包含一个私有成员static Grid grid; .
  • Root.cpp initializes this Grid Root::Grid; Root.cpp初始化此Grid Root::Grid;

I do have SFML linked statically, which has caused me a bit of trouble. 我确实有静态链接的SFML ,这给我带来了一些麻烦。

This is a small example which exhibits this error: 这是一个显示此错误的小示例:

#include <fstream>
#include <sstream>
#include <Windows.h>

#include "Root.hpp"

Grid Root::grid;

int main (uchar argc, char **argv) {
    Root root;
    Root::Prepare(root);
    return Root::GetStatus();
}

The constructor as follows: 构造函数如下:

Grid::Grid() {
    Width = 100;
    Height = 100;
}

The call stack: 调用堆栈:

ntdll.dll!772022b2()    Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
Test.exe!sf::priv::MutexImpl::lock(void)    Unknown
Test.exe!sf::Mutex::lock(void)  Unknown
Test.exe!sf::Lock::Lock(class sf::Mutex &)  Unknown
Test.exe!sf::GlResource::GlResource(void)   Unknown
Test.exe!sf::Texture::Texture(void) Unknown
>   Test.exe!Grid::Grid() Line 5    C++
Test.exe!`dynamic initializer for 'Root::grid''() Line 11   C++
msvcr110d.dll!_initterm(void (void) * * pfbegin, void (void) * * pfend) Line 894    C
Test.exe!__tmainCRTStartup() Line 460   C
Test.exe!mainCRTStartup() Line 377  C
kernel32.dll!767533aa() Unknown
ntdll.dll!77219ef2()    Unknown
ntdll.dll!77219ec5()    Unknown

Even without having your full source code, the exception you're getting, and the stack you show, look suspiciously similar to another solved Stack Overflow posting: 即使没有完整的源代码,您获得的异常以及您显示的堆栈看起来与另一个解决的Stack Overflow帖子看起来非常相似:

" Unhandled exception at 0x777122D2 (ntdll.dll) in ArticxEngine.exe: 0xC0000005: Access violation writing location 0x00000004 " ArticxEngine.exe中0x777122D2(ntdll.dll)的未处理异常:0xC0000005:访问冲突写入位置0x00000004

Your stack shows that Grid() is derived from SFML's Texture(), which is derived in turn from GlResource(). 你的堆栈显示Grid()派生自SFML的Texture(),它是从GlResource()依次派生的。 The problem is that your grid is a static variable which is getting constructed before GlResource()'s internal mutex is. 问题是你的网格是一个静态变量,它在GlResource()的内部互斥体之前构建。

The solution is the same as the other Stack Overflow posting: make sure your Grid object is non-static and is constructed after your main() begins running. 解决方案与其他Stack Overflow帖子相同:确保您的Grid对象是非静态的,并在main()开始运行后构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM