[pypy-issue] Issue #3083: segfault in recursive code (pypy/pypy)
lesshaste
issues-reply at bitbucket.org
Wed Oct 2 07:06:41 EDT 2019
New issue 3083: segfault in recursive code
https://bitbucket.org/pypy/pypy/issues/3083/segfault-in-recursive-code
lesshaste:
Python 3.6.1 \(7.1.1\+dfsg-1~ppa1~ubuntu16.04, Aug 09 2019, 16:05:52\)
\[PyPy 7.1.1 with GCC 5.4.0 20160609
Python 2.7.13 \(7.1.1\+dfsg-1~ppa1~ubuntu16.04, Aug 09 2019, 13:41:07\)
\[PyPy 7.1.1 with GCC 5.4.0 20160609\]
The following code causes both pypy 3.6.1 and 2.7.13 to segfault.
from math import factorial
import resource, sys
resource.setrlimit\(resource.RLIMIT\_STACK, \(2**29,-1\)\)**
**sys.setrecursionlimit\(10**6\)
def c\(n, k\):
if k < 0:
return 0
k = min\(k, n\*\(n-1\)/2\)
if \(n, k\) in ct:
return ct\[\(n, k\)\]
ct\[\(n, k\)\] = c\(n, k-1\) \+ c\(n-1, k\) - c\(n-1, k-n\)
return ct\[\(n, k\)\]
n = 200
ct = \{\(0, 0\): 1\}
print\(c\(n,int\(n\*\(n-1\)/4\)\)/factorial\(n\)\)
More information about the pypy-issue
mailing list