如何调查启动应用程序时发生的访问冲突的根源?

发布于 2024-09-30 10:52:02 字数 1493 浏览 0 评论 0原文

我是 C++ 编程新手。我正在编译一个 Windows 应用程序,该应用程序编译正常,仅出现一些警告,但当我启动它时,它甚至似乎没有启动,并在运行 3 秒后返回访问冲突。当我尝试调试时,它甚至似乎没有进入代码,所以我不知道从哪里开始寻找问题。

这是我能够从调试器检索到的信息:

Building to ensure sources are up-to-date
Build succeeded
Selecting target: 
Debug
Adding source dir: C:\Documents and Settings\Christian Ekiza\Mis documentos\My Dropbox\Private Files\coding\juego_pruebas_01\juego_pruebas_01\
Adding source dir: C:\Documents and Settings\Christian Ekiza\Mis documentos\My Dropbox\Private Files\coding\juego_pruebas_01\juego_pruebas_01\
Adding file: bin\Debug\juego_pruebas_01.exe
Starting debugger: 
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.8
Child process PID: 3328
Program received signal SIGSEGV, Segmentation fault.
In ?? () ()

这是来自调用堆栈

#0 00000000 0x000154e4 in ??() (??:??)
#1 00409198 __cmshared_create_or_grab() (../../../../gcc-4.4.1/libgcc/../gcc/config/i386/cygming-shared-data.c:140)
#2 00000000 0x0040131b in __gcc_register_frame() (??:??)
#3 00000000 0x0040a09b in register_frame_ctor() (??:??)
#4 00000000 0x00408f42 in __do_global_ctors() (??:??)
#5 00000000 0x00401095 in __mingw_CRTStartup() (??:??)
#6 00000000 0x00401148 in mainCRTStartup() (??:??)

和 CPU 寄存器以 a 结尾的

'gs' register with a hex value '0x0'

我真的不知道从哪里开始寻找问题。任何人都可以帮助我或指出我正确的方向吗?

注意:我正在使用 Code::Blocks

I´m new to C++ programing. I am compiling a Windows Application which compiles ok with just a few warnings, but when I launch it, it doesn´t even seem to start and returns an Access Violation 3 seconds into the run. When I try to debug it doesn´t even seem to get into the code, so I don´t know where to start looking for the problem.

Here is the info I have been able to retrieve from the debugger:

Building to ensure sources are up-to-date
Build succeeded
Selecting target: 
Debug
Adding source dir: C:\Documents and Settings\Christian Ekiza\Mis documentos\My Dropbox\Private Files\coding\juego_pruebas_01\juego_pruebas_01\
Adding source dir: C:\Documents and Settings\Christian Ekiza\Mis documentos\My Dropbox\Private Files\coding\juego_pruebas_01\juego_pruebas_01\
Adding file: bin\Debug\juego_pruebas_01.exe
Starting debugger: 
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.8
Child process PID: 3328
Program received signal SIGSEGV, Segmentation fault.
In ?? () ()

and this is from the Call Stack

#0 00000000 0x000154e4 in ??() (??:??)
#1 00409198 __cmshared_create_or_grab() (../../../../gcc-4.4.1/libgcc/../gcc/config/i386/cygming-shared-data.c:140)
#2 00000000 0x0040131b in __gcc_register_frame() (??:??)
#3 00000000 0x0040a09b in register_frame_ctor() (??:??)
#4 00000000 0x00408f42 in __do_global_ctors() (??:??)
#5 00000000 0x00401095 in __mingw_CRTStartup() (??:??)
#6 00000000 0x00401148 in mainCRTStartup() (??:??)

And the CPU Registers end with a

'gs' register with a hex value '0x0'

I don't really know where to start looking for the problem. Anyone can help me out or point me in the right direction?

Note: I am using Code::Blocks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

表情可笑 2024-10-07 10:52:03

在我看来,您的 DLL 依赖项之一无法正确加载或实例化。

Sounds to me like one of your DLL dependencies can't be loaded or instantiated correctly.

飘落散花 2024-10-07 10:52:03

您是否在启用调试模式(-g)的情况下进行编译?

还要认真考虑实际修复警告。大多数时候,它们是代码中应该解决的实际问题。

您还应该尝试看看在几乎空的 main 中是否会发生这种情况(注释掉 main 中的大部分/全部代码)。

Did you you compile with debug mode (-g) enabled?

Also seriously consider actually fixing the warnings. Most of the time they are actual problems in the code that should be resolved.

You should also try to see if this happens with a nearly empty main (comment out most/all of your code in main).

瞄了个咪的 2024-10-07 10:52:02

正如你所说,它是一个 Windows 应用程序。然后,对于启动方面的任何问题,我发现 ADPlus 非常有用。

编辑2:

您还可以检查 用户模式进程转储器(如果 ADPlus 不适用)

As you say it is a Windows application. Then, any issues with startup, I have found ADPlus very useful.

EDIT 2:

You may also check User Mode Process Dumper if ADPlus does not apply

零度° 2024-10-07 10:52:02

看,如果你有一些带有构造函数的类的全局实例 - 如果在构造函数中引发错误并且全局声明了类(顺便说一句,这是一件坏事) - 你甚至会在 main() 之前得到 sigsegv 。
如果您有这样的类 - 尝试重构您的代码以将它们放在 main (或其他函数)中 - 调试起来会更容易。

See, if you have some global instance(s) of class with constructor - if error is raised in constructor and class is declared globally (bad thing to do btw) - you'll get sigsegv even before main().
If you have such classes - try to refactor your code to have them inside main (or other function) - it will be easier to debug.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文