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/008964.html below:

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

[Python-Dev] stack check on Unix: any suggestions?Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Wed, 30 Aug 2000 20:32:30 +0200
> So the check would look something like this:
> 
> if (tstate->recursion_depth >= 50 &&
>     tstate->recursion_depth%10 == 0 &&
>     PyOS_CheckStack()) {
>                 PyErr_SetString(PyExc_MemoryError, "Stack overflow");
>                 return NULL;
>         }

That sounds like a good solution to me. A recursion depth of 50 should
be guaranteed on most systems supported by Python.

> I'm not exactly sure how large the safety margin is with
> Martin's patch, but this seems a good idea.

I chose 3% of the rlimit, which must accomodate the space above the
known start of stack plus a single page. That number was chosen
arbitarily; on my Linux system, the stack limit is 8MB, so 3% give
200k. Given the maximum limitation of environment pages and argv
pages, I felt that this is safe enough. OTOH, if you've used more than
7MB of stack, it is likely that the last 200k won't help, either.

Regards,
Martin




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