4
votes

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.

Program received signal SIGSEGV, Segmentation fault.

__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: No such file or directory.

I've tried:

  • Compiling on a Windows x86 machine
  • Compiling on a Windows x64 machine
  • nuwen.net's MinGW distro
  • TDM MinGW 4.8.1 SJLJ
  • MinGW builds x86 SJLJ
  • MinGW builds x64 SJLJ
  • MinGW builds x86 DW2

I've built all dependencies from source multiple times, tried linking both statically and dynamically.

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?

2
Choose one type of build and stick with it when diagnosing the problem. Doing multiple builds to attempt to fix an error that you aren't sure about is not the way to go about this. All that will do is confuse the issue. Having said that, I am surprised that gdb doesn't have a way to debug code before main() is executed. How would you debug a constructor of a globally declared object if you can't debug before main() is executed? - PaulMcKenzie
-fstack-usage might help you figure what's using a lot of stack. - Michael Burr

2 Answers

3
votes

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.

Alternately, you may be able to add a compile flag to increase the stack size. See http://trac.sagemath.org/ticket/13960.

1
votes

Try to increase stack size. Don't ask me how, I don't know.

The failing call (__chkstk_ms) looks like internal routine which checks if there is enough stack space for the function about to be executed.