Re: Acceptable Seg Faults?
| From: | Unknown W. Brackets | Date: | Wed, 13 Sep 2006 03:01:31 +0000 |
| Subject: | Re: Acceptable Seg Faults? | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-25646@lists.php.net to get a copy of this message | ||
Is it at all possible to determine in a cross-platform way:
1. The current stack position (e.g. SP, except on all architectures.)
2. The maximum stack size.
I realize this is a naive question, but given the above - worst-case, an option (like memory_limit) could be added which tracks recursion depth or stack usage and triggers an error within an acceptable limit.
Example: if you know each recursive PHP function call uses approximately X bytes of stack with its local variable table etc., and you know you have 2 megabytes of stack in your thread/process, you know you can only use a recursion depth of 2097152 / X, and you also know you won't have all of that.
Thus you could prevent segfaults even on shared servers. Still, the solution is to have correct code. The above would either have false negatives and/or introduce a performance loss (check or at least inc per user-space function call) when compiled on.
-[Unknown]
-------- Original Message --------
I assume this is b/c its recursively diving into Class function/method calls and we are filling memory.. Is this detectable? Should I file a bug report or is this known? Ideally it would be nice to see a fatal error thrown, if this is indeed detectable.So far nobody had proposed a solution for endless loop problem that would satisfy these conditions: 1. No false positives (i.e. good code always works) 2. No slowdown for execution 3. Works with any stack size Thus, this problem remains unsloved.