简体   繁体   English

过程以 Python 中的退出代码 -1073741571 (0xC00000FD) 结束

[英]Process finished with exit code -1073741571 (0xC00000FD) in Python

I am at early stage of learning Python.我正处于学习 Python 的早期阶段。 I tried calculating Ackerman function for smaller values.我尝试计算 Ackerman function 以获得较小的值。 It worked just fine until the values are (3,7).它工作得很好,直到值为(3,7)。 Any value higher than that (say 3,8) throws this error.任何高于此的值(例如 3,8)都会引发此错误。 [Process finished with exit code -1073741571 (0xC00000FD)] [进程以退出代码 -1073741571 (0xC00000FD) 结束]

At first I checked whether recursion limit is reached, but the process stopped well below the set Recursion limit (in this case it is set to maximum)起初我检查是否达到递归限制,但进程停止在远低于设置的递归限制(在这种情况下,它设置为最大值)

import sys
sys.setrecursionlimit(999999999)
count = 0
def cf():
    global count
    count+=1
cf()
def Ack(m,n):
    if  m==0:
        x=n+1
        cf()
        return x
    elif m>0 and n==0:
        x=Ack(m-1,1)
        cf()
        return x
    elif m>0 and n>0:
        x=Ack(m-1,Ack(m,n-1))
        cf()
        return x
a,b=map(int,input("Enter values").split())
print(a,b)
result=Ack(a,b)
print(result)
print(count)

Simple as that, you are getting a stack overflow.就这么简单,你得到了堆栈溢出。

Recursion limit only dictates how deep the recursion calls can go, but it doesn't change the stack size.递归限制仅指示递归调用 go 的深度,但它不会更改堆栈大小。 Each recursive call adds frames to the stack and eventually you are reaching the limit.每个递归调用都会将帧添加到堆栈中,最终您会达到限制。

If you really want to go so deep with recursion, you have to change stack size with threading.stack_size() and create a new thread.如果你真的想要 go 这么深的递归,你必须用threading.stack_size()改变堆栈大小并创建一个新线程。

related question: Process finished with exit code -1073741571相关问题: 进程以退出代码 -1073741571 结束

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 进程以退出代码 -1073741571 (0xC00000FD) Tensorflow 结束 - Process finished with exit code -1073741571 (0xC00000FD) Tensorflow Python 大输入快速排序; 如何修复错误代码:进程已完成,退出代码为 -1073741571 (0xC00000FD)? - Quicksort in Python on big input; How do I fix error code: Process finished with exit code -1073741571 (0xC00000FD)? 进程结束,退出代码为 -107341571 (0xC00000FD) - Process finished with exit code -107341571 (0xC00000FD) 当我需要多次运行 sim 调用函数时避免退出代码 -1073741571 (0xc00000fd) - Avoiding exit code -1073741571 (0xc00000fd) when I need to run a sim calling functions many times over Python 0xC00000FD 无线程修复 - Python 0xC00000FD fix without thread 进程完成,退出代码 -1073741571 - Process finished with exit code -1073741571 进程完成,退出代码 -1073741819 (0xC0000005) Python Tkinter GUI Canvas 更新 - Process finished with exit code -1073741819 (0xC0000005) Python Tkinter GUI Canvas Update Python:进程已完成,退出代码为 -1073741819 (0xC0000005)。 如何调试? - Python: Process finished with exit code -1073741819 (0xC0000005). How to Debug? 进程结束,退出代码为 0 python - Process finished with exit code 0 python 进程完成,退出代码 -1073740791 (0xC0000409) pycharm 错误 - Process finished with exit code -1073740791 (0xC0000409) pycharm error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM