0

My goal is to increase the default stack size of a process.

I found out that it can be easily achieved on a thread by setting dwStackSize on the CreateThread function, but it seems like there is no documented way to do similar things on a process' main thread.

cat
  • 36
  • 1
  • 6
  • 1
    It's a compiler option as the 1st thread has already been created when you wish to change it. See https://msdn.microsoft.com/en-us/library/tdkhxaks.aspx . Note there is no way to change the stack size of an already running thread. – Richard Critten May 08 '16 at 19:09
  • Yeah, i know, i have already seen that in other posts. The problem is that i use mingw. – cat May 08 '16 at 19:11
  • You might check the manual, but I believe the GCC equivalent of Visual C++'s `/F` is `--stack` – MrEricSir May 08 '16 at 19:15
  • Try `-Wl,--stack,0x100000000` See the 2nd answer http://stackoverflow.com/questions/2275550/change-stack-size-for-a-c-application-in-linux-during-compilation-with-gnu-com – Richard Critten May 08 '16 at 19:15
  • Sorry but as I noticed, there is no such option under Windows platform. – cat May 08 '16 at 20:36
  • Ok, I am actually dumb. Ignore my last comment, I managed to pass the arguments correctly (wow), yet the solution doesn't seem to work :(. I wrote a simple infinite recursion to my test program in which i print the continuously incrementing parameter as debug. The stack overflow happens at about 64 kb either if I pass those arguments or not. I appreciate your answer though, it would be the most ideal solution for me. There is probably something wrong with me, not with the compiler. Anyway, apologies for my stupidity and thank you for the reply. – cat May 08 '16 at 21:34
  • Are you sure the parameter is passed correctly? What does the build log show (I'm mostly interested in the command lines listed there)? It needs to be passed either to the Compiler as `-Wl,--stack,0x100000000` or to the linker as `--stack 0x100000000`, not to the linker in the former format. – CherryDT May 09 '16 at 10:03
  • So far I tried to pass to the compiler in the first form (`-Wl,--stack,0x00300000`), but it had no effect. Passing to the linker in the form mentioned by you, without comma, gives error (I guess the compiler reads the number as a separated string, thus handling it as a file name - based on the logs). However, if I pass the same stuff to the linker, it works perfectly. – cat May 09 '16 at 11:25

0 Answers0