A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2000-August/008934.html below:

[Python-Dev] stack check on Unix: any suggestions?

[Python-Dev] stack check on Unix: any suggestions? [Python-Dev] stack check on Unix: any suggestions?Charles G Waldman cgw@fnal.gov
Tue, 29 Aug 2000 16:05:21 -0500 (CDT)
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 ;-)







RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4