[New-bugs-announce] [issue13468] Python 2.7.1 SegmentationFaults when given high recursion limit

Tom Dignan report at bugs.python.org
Thu Nov 24 04:49:55 CET 2011


New submission from Tom Dignan <tom at adeptdev.com>:

On my system, the magic number to make this segfault seems to be 26200:

tom at tralfamadore ~/Downloads $ python recur1.py  26199
160164968

tom at tralfamadore ~/Downloads $ python recur1.py  26200
Segmentation fault

Here's the source:

#!/usr/bin/python
import sys

if len(sys.argv) < 2:
    print "usage %r <number>" % sys.argv[0]
    sys.exit(1)

number = int(sys.argv[1])

sys.setrecursionlimit(number + 2)

f = (lambda n: (f(n - 1) if n > 0 else 0) + 
    (n if n % 3 == 0 or n % 5 == 0 else 0))

print f(number)

sys.exit(0)

----------
components: None
messages: 148226
nosy: tdignan
priority: normal
severity: normal
status: open
title: Python 2.7.1 SegmentationFaults when given high recursion limit
type: crash
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13468>
_______________________________________


More information about the New-bugs-announce mailing list