This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
idea for StackOverflowException
- From: Adam Megacz <gcj at lists dot megacz dot com>
- To: java at gcc dot gnu dot org
- Date: 27 Dec 2001 22:56:08 -0800
- Subject: idea for StackOverflowException
- Organization: Myself
As I recall, the major impediment to implementing
StackOverflowException is having to call new from within the
stack-overflow signal handler -- at that point, you have no stack
left with which to call StackOverflow's constructor.
How about this: in Thread.start(), scan the stack area by writing to
each location, in progressively increasing until you get a stack
overflow signal (for speed, consider an exponentially increasing
search, followed by a binary search). Then, write-protect the top page
of the stack. When a write to the top page is detected, throw a
StackOverflowException and allow writes to the top page until the
exception is caught.
That way, you never have to attempt to throw an exception or call new
from inside the stack overflow signal handler.
Would this work?
- a