Someone please see my code at this link for input taken from this file( 2.2 mb file). This produces seg fault. By gdb, it shows seg fault in _vfprintf_r(). But when I comment line 41 and uncomment 38 (a null statement), there is no segmentation fault. line no 41 is just print statement. Someone please help. I am frustated and wasted a day in debugging. The output is written into result.txt file.
+4
A:
You have a stack overflow. That's right, a Stack Overflow. I was able to reproduce by doing ulimit -s 1024. You need to not recurse so deeply, or you need to increase your stack size.
Matt
2009-11-06 02:55:08
How to increase the stack size? But you did not get the error, u wrote in comment.
avd
2009-11-06 02:57:56
Its a simple dfs on around 200000 vertices. The file specifies the graph. I have to submit it to online judge. How to do it?
avd
2009-11-06 02:59:10
I didn't initially get the error. I lowered the stack size available and was able to reproduce the error. You can try ulimit -s <value> (my system defaults to 8192) to try and solve the issue, but I'm not sure if cygwin supports setting the stack size. A stack size of 2048 did not generate the error.
Matt
2009-11-06 03:00:04
So if I run on linux system, then I wont get error?
avd
2009-11-06 03:01:06
Most likely yes.
Matt
2009-11-06 03:08:40
Thank you Matt and all others for looking at this problem. I will try on linux and then update.
avd
2009-11-06 03:10:24
"That's right, a Stack Overflow." -- I tried searching to find what was so funny about that, but I got a Stack Overflow.
Windows programmer
2009-11-06 03:18:08
Ya it runs on linux perfectly.
avd
2009-11-06 05:30:20
A:
As Matt answered, you're running out of stack. Add /STACK:amount to reserve in bytes,amount to initially commit in bytes to your link.exe command line.
Make sure both numbers are multiples of 4096, which is the default page size on windows IIRC.
JimR
2010-10-31 10:41:31