[Python-Dev] stack check on Unix: any suggestions? (original) (raw)
Charles G Waldman cgw@fnal.gov
Tue, 29 Aug 2000 16:05:21 -0500 (CDT)
- Previous message: [Python-Dev] stack check on Unix: any suggestions?
- Next message: [Python-Dev] stack check on Unix: any suggestions?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jeremy Hylton writes:
Does anyone have suggestions for how to detect unbounded recursion in the Python core on Unix platforms?
Hey, check this out! - it's not portable in general, but it works for Linux, which certainly covers a large number of the systems out there in the world.
#!/usr/bin/env python
def getstack(): for l in open("/proc/self/status").readlines(): if l.startswith('VmStk'): t = l.split() return 1024 * int(t[1])
def f(): print getstack() f()
f()
I'm working up a version of this in C; you can do a "getrlimit" to find the maximum stack size, then read /proc/self/status to get current stack usage, and compare these values.
As far as people using systems that have a broken getrusage and also no /proc niftiness, well... get yourself a real operating system ;-)
- Previous message: [Python-Dev] stack check on Unix: any suggestions?
- Next message: [Python-Dev] stack check on Unix: any suggestions?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]