开发者

How can I reproduce EXCEPTION_STACK_OVERFLOW error in Java

开发者 https://www.devze.com 2023-03-18 18:21 出处:网络
How can I reproduce EXCEPTION_STACK_OVERFLOW error in Java. PS: I am not talking of StackOverflowError Error 开发者_StackOverflow中文版in Java which gracefully shuts the JVM. I am talking of EXCEPTIO

How can I reproduce EXCEPTION_STACK_OVERFLOW error in Java.

PS: I am not talking of StackOverflowError Error 开发者_StackOverflow中文版in Java which gracefully shuts the JVM. I am talking of EXCEPTION_STACK_OVERFLOW in error.log which cause JVM to crash.


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 ;) )


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

Call it, and enjoy :D


Blow stack:

public static void main(String[] args) {
    main(null);
}

Blow heap:

public static void main(String[] args) {
    List<String> list = new ArrayList<String>();
    while(true) list.add(new String("boom"));
}
0

精彩评论

暂无评论...
验证码 换一张
取 消