Rob Mayoff wrote:
Note that each time you create a stack from (or otherwise dynamically extend the stack), you need to compare the SP to a thread-specific limit, which means using TLS. I'm not sure how long Linux (for example) has supported TLS, and I'm pretty sure that its support has changed over time, so checking SP is not necessarily trivial.
Thanks Rob, I am trying to understand where the thread-specific limit is involved but I can't. If as a thread, I ask for a new thread to be created and hence a new stack, I would guess (but I don't know) that the base for all stack pointers are stored in some global, locked, table, along perhaps with the limits of the stack which are either stored in that table, or local to the stack itself. I mean, clearly the memory allocater knows where it allocated the stacks...? Then if I as a compiler, need to push a new stack frame on the stack, I would think the stack limits are easily accessible in either the global stack table, or the local to the specific stack area. My first thoughts are that the amount to push onto the stack is known by the compiler and are thread invariant. So I am sure my guesses are off the mark, but where? pleh? Jerry P.S. Again, I'll ignore extending the stack. I am sorry I brought that up in the first place since I think the most important thing is to just protect the stacks and detect overflow. I suspect stack extension is treatable, once stack overflow can be reliably detected, but the argument confuse me and make by brain hurt.
