stack overflow interacts poorly with classloaders

Timothy Stack stack at
Mon Jun 12 10:55:15 PDT 2000


I've run into an odd problem that I don't know quite how to fix. 
Basically, a stack overflow isn't handled particularly well, especially
when there are class loaders involved.  Since we execute a good deal of
code to throw the exception it eats up even more stack and we risk going
past the red zone and overwriting the jthread structure adjacent to the
stack, or other important data.  The problem is exasperated when the
method that caused the overflow is in a class that was loaded by a class
loader.  In this case we would be asking java code to load our class, but
the java code will just complain about not having any stack!  So far the
only options i've come up with to fix this annoying little problem is to

  1. preload the StackOverflow class and any of its parents if they are
     referenced by a class.  Could be a lot of work to do for an unlikely

  2. Have the offending thread use some other thread to do most of the
     class loading work, and then the offending thread can take the final
     step and throw the exception.  I like this option the most, but
     theres bound to be some nasty problem...

Any ideas?


tim stack

More information about the kaffe mailing list