Workaround for stack limiting on windows with gnu g ++

I have built and compiled a command line program with GNU g ++ that overflows the stack for a number of reasons, mainly deep inheritance, lots of created objects, etc. So I followed this workaround on Mac OS X to resolve the linking issue:

-Wl,-stack_size,0x10000000,-stack_addr,0xc0000000

      

On Linux, I just tried it ulimit -s unlimited

; running the program this way no longer gives segmentation faults

But when trying to compile it on Windows with GNU g ++, the compiler doesn't recognize

-Wl,-stack_size,0x10000000,-stack_addr,0xc0000000

      

What other option would you use as a workaround for the problem?

Thank you in advance

+2


source to share


2 answers


- Wl, - stack, somelargesize looks like you. However, I highly recommend refactoring your code to use heap instead for large allocations. The address space is a finite resource and your "workaround" requires a fairly large chunk.



+5


source


This page suggests that you try the following command line option (search for -fno-stack-limit):

-fno-stack-limit

      



If that doesn't work on its own, then this other page suggests adding:

-fstack-check

      

+1


source







All Articles