Lib/test/crashers/trace_at_recursion_limit.py
raw| 1 | """ |
| 2 | From http://bugs.python.org/issue6717 |
| 3 | |
| 4 | A misbehaving trace hook can trigger a segfault by exceeding the recursion |
| 5 | limit. |
| 6 | """ |
| 7 | import sys |
| 8 | |
| 9 | |
| 10 | def x(): |
| 11 | pass |
| 12 | |
| 13 | def g(*args): |
| 14 | if True: # change to True to crash interpreter |
| 15 | try: |
| 16 | x() |
| 17 | except: |
| 18 | pass |
| 19 | return g |
| 20 | |
| 21 | def f(): |
| 22 | print(sys.getrecursionlimit()) |
| 23 | f() |
| 24 | |
| 25 | sys.settrace(g) |
| 26 | |
| 27 | f() |