Issue 13468: Python 2.7.1 SegmentationFaults when given high recursion limit (original) (raw)
Issue13468
Created on 2011-11-24 03:49 by tdignan, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (2) | ||
---|---|---|
msg148226 - (view) | Author: Tom Dignan (tdignan) | Date: 2011-11-24 03:49 |
On my system, the magic number to make this segfault seems to be 26200: tom@tralfamadore ~/Downloads $ python recur1.py 26199 160164968 tom@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 " % 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) | ||
msg148229 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2011-11-24 05:22 |
Of course; that's what the recursion limit protects against. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:24 | admin | set | github: 57677 |
2011-11-24 05:22:45 | benjamin.peterson | set | status: open -> closednosy: + benjamin.petersonmessages: + resolution: not a bug |
2011-11-24 03:49:54 | tdignan | create |