How does the JVM recover from a java.lang.StackOverflowError?

As far as I know that whenever a java.lang.OutOfMemoryError is thrown, the application is in an unknown state and only a restart of the JVM can fix this. How about java.lang.StackOverflowError? If uncaught, the calling thread is terminated for sure, but the other threads? Are there side-effects?

[303 byte] By [mhstava] at [2007-11-27 7:01:14]
# 1
In windows OS that thread will die and thats all. I think that in some unix systems the whole process is likely to fail.
david327a at 2007-7-12 18:52:02 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
> In windows OS that thread will die and thats all.> I think that in some unix systems the whole process> is likely to fail.Well, if stack overflow is caused by JNI calls the process will always crash.
david327a at 2007-7-12 18:52:02 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
Oh, looks like I forgot to configure on "Emails My Watches Updates". But anyway:Thanks for your reply!
mhstava at 2007-7-12 18:52:02 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4

> In windows OS that thread will die and thats all.

> I think that in some unix systems the whole process

> is likely to fail.

Not exactly. It's not nearly as dependent on the operating system as it is on the quality of the JVM implementation. StackOverflowErrors are tricky to handle correctly in all cases, but most JVMs (including Sun's) now properly handle the vast majority of them. FWIW, most unix-based or unix-like operating systems make it somewhat easier to deal with StackOverflowError than Windows, particularly Windows versions prior to Win2K.

A thread that triggers a StackOverflowError can actually catch it and recover; the important thing to note is that if you want to keep executing code on that thread, you have to allow many or most of the activations (i.e., function calls) on the stack to be unwound. Otherwise, you'll quickly provoke another StackOverflowError since you will still be close to the end of the stack.

jxca at 2007-7-12 18:52:02 > top of Java-index,Java HotSpot Virtual Machine,Specifications...