gpt4 book ai didi

c++ - 第一次异常 (ntdll.dll)

转载 作者:行者123 更新时间:2023-11-28 03:14:21 30 4
gpt4 key购买 nike

知道我为什么会收到此错误吗?

这是完整的错误:

First-chance exception at 0x77202282 (ntdll.dll) in Test.exe 0xC0000005: Access violation writing location 0x0000004

Unhandle exception at 0x77202282 (ntdll.dll) in Test.exe 0xC0000005: Access violation writing location 0x0000004

  • 调试在 Grid::Grid() 行中断。
  • Root.hpp 包含一个私有(private)成员static Grid grid;
  • Root.cpp 初始化这个 Grid Root::Grid;

我有 SFML 静态链接,这给我带来了一些麻烦。

这是一个显示此错误的小示例:

#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();
}

构造函数如下:

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

调用堆栈:

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

最佳答案

即使没有您的完整源代码、您得到的异常以及您显示的堆栈,看起来也与另一个已解决的 Stack Overflow 帖子非常相似:

"Unhandled exception at 0x777122D2 (ntdll.dll) in ArticxEngine.exe: 0xC0000005: Access violation writing location 0x00000004 "

您的堆栈显示 Grid() 派生自 SFML 的 Texture(),后者又派生自 GlResource()。问题是您的网格是一个静态变量,它是在 GlResource() 的内部互斥量之前构建的。

解决方案与其他 Stack Overflow 帖子相同:确保您的 Grid 对象是非静态的,并且是在 main() 开始运行后构造的。

关于c++ - 第一次异常 (ntdll.dll),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17419146/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com