Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reproduce EXCEPTION_STACK_OVERFLOW error in Java

How can I reproduce EXCEPTION_STACK_OVERFLOW error in Java.

PS: I am not talking of StackOverflowError Error in Java which gracefully shuts the JVM. I am talking of EXCEPTION_STACK_OVERFLOW in error.log which cause JVM to crash.

like image 840
Sandeep Jindal Avatar asked Jul 08 '11 11:07

Sandeep Jindal


2 Answers

Most EXCEPTION_STACK_OVERFLOW errors I found so far happen in native code outside the JVM. A crash inside the JVM is worth a bug report and will be fixed. Or are you in need of an (unknown) exploit?

So the easist and most reliable way would be to write a native library with some code that causes the JVM to crash and call that with JNI.

(general answer, I actually don't know how to do it exactly. Can't be done with java code only ;) )

like image 118
Andreas Dolk Avatar answered Sep 20 '22 18:09

Andreas Dolk


public static void stackoverflow()
{
     stackoverflow();
}

Call it, and enjoy :D

like image 37
Martijn Courteaux Avatar answered Sep 19 '22 18:09

Martijn Courteaux