Process finished with exit code -1073741571

49.1k views Asked by At

I'm trying to process a large graph using a recursive algorithm. Due to the deep recursion, I encountered the problem described at Python: Maximum recursion depth exceeded.

So, I tried increasing the limit on recursion depth, like so:

import sys
sys.setrecursionlimit(5000)

However, whatever value I use for the depth, I cannot get the result I want. Either I still get the exception, or else the program just halts with no output on the screen but: Process finished with exit code -1073741571.

How can I solve the problem?


See also: What is the hard recursion limit for Linux, Mac and Windows?

2

There are 2 answers

1
Juan Pablo VEGA On

You could use something like:

if __name__ == '__main__':
    sys.setrecursionlimit(100000)
    threading.stack_size(200000000)
    thread = threading.Thread(target=your_code)
    thread.start()

This solved both my recursion limitation and my heap size limitation.

1
reteptilian On

That is the signed integer representation of Microsoft's "stack overflow/stack exhaustion" error code 0xC00000FD.

You might try increasing your executable's stack size as described in the answer here: How to overcome Stack Size issue with Visual Studio (running C codes with big array)

Anytime you see strange, large negative exit codes in windows, convert them to hex and then look them up in the ntstatus error codes http://msdn.microsoft.com/en-us/library/cc704588.aspx

You may also use the MS Error Lookup Tool to find such codes locally, or even automatically. Other, similar tools exist both by Microsoft and third parties.