Application segmentation fault, only when compiling on Windows with MinGW(应用程序分段错误,仅在使用 MinGW 在 Windows 上编译时)
问题描述
我正在尝试在 Windows 上编译 我的一个游戏,但不幸的是,无论如何,每次运行程序时都会遇到此分段错误.
I'm trying to compile one of my games on Windows, but unfortunately, no matter what, I'm getting this segmentation fault every time I run the program.
编译成功,没有任何警告.
Compilation is successful, and without any warning.
程序收到信号SIGSEGV,分段错误.
Program received signal SIGSEGV, Segmentation fault.
__chkstk_ms () at ../../../../../src/gcc-4.8.1/libgcc/config/i386/cygwin.S:172
__chkstk_ms () at ../../../../../src/gcc-4.8.1/libgcc/config/i386/cygwin.S:172
172 ../../../../../src/gcc-4.8.1/libgcc/config/i386/cygwin.S:没有这样的文件或目录.
172 ../../../../../src/gcc-4.8.1/libgcc/config/i386/cygwin.S: No such file or directory.
我试过了:
- 在 Windows x86 机器上编译
- 在 Windows x64 机器上编译
- nuwen.net 的 MinGW 发行版
- TDM MinGW 4.8.1 SJLJ
- MinGW 构建 x86 SJLJ
- MinGW 构建 x64 SJLJ
- MinGW 构建 x86 DW2
我已经多次从源代码构建所有依赖项,尝试静态和动态链接.
I've built all dependencies from source multiple times, tried linking both statically and dynamically.
调试也无济于事 - GDB 在输入 main()
时就给我该错误消息.我使用了 -g3
和 -O0
标志.
Debugging doesn't help either - GDB gives me that error message just upon entering main()
. I've used -g3
and -O0
flags.
我怎样才能知道发生了什么?
How can I figure out what's happening?
推荐答案
在 Windows 上,默认堆栈大小小于 Linux.__chkstk_ms 似乎是一个在堆栈溢出时崩溃的函数.
On Windows, the default stack size is smaller than Linux. __chkstk_ms appears to be a function that crashes if you overflow your stack.
您可能会尝试找出您在代码中的哪个位置创建了巨大的堆栈变量或进行了非常深的递归,然后修复它.
You may try to figure out where in your code you are creating huge stack variables or doing very deep recursion, and fix that.
或者,您可以添加一个编译标志来增加堆栈大小.请参阅 http://trac.sagemath.org/ticket/13960.
Alternately, you may be able to add a compile flag to increase the stack size. See http://trac.sagemath.org/ticket/13960.
这篇关于应用程序分段错误,仅在使用 MinGW 在 Windows 上编译时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:应用程序分段错误,仅在使用 MinGW 在 Windows 上编译时


基础教程推荐
- 从 std::cin 读取密码 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01