From a2cc9fdc115c5414a1b7489b8f9c5d806926f759 Mon Sep 17 00:00:00 2001 From: k-tamura Date: Mon, 13 Feb 2017 22:40:56 +0900 Subject: [PATCH] Improve JVMCrashByEAVServlet --- .../troubles/JVMCrashByEAVServlet.java | 28 ++++++++----------- src/main/resources/indexpage_en.properties | 5 ++-- src/main/resources/indexpage_ja.properties | 5 ++-- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/t246osslab/easybuggy/troubles/JVMCrashByEAVServlet.java b/src/main/java/org/t246osslab/easybuggy/troubles/JVMCrashByEAVServlet.java index e7709b90..85809a8c 100644 --- a/src/main/java/org/t246osslab/easybuggy/troubles/JVMCrashByEAVServlet.java +++ b/src/main/java/org/t246osslab/easybuggy/troubles/JVMCrashByEAVServlet.java @@ -1,8 +1,7 @@ package org.t246osslab.easybuggy.troubles; import java.io.IOException; -import java.io.PrintWriter; -import java.lang.reflect.Constructor; +import java.lang.reflect.Field; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; @@ -11,31 +10,26 @@ import javax.servlet.http.HttpServletResponse; import org.pmw.tinylog.Logger; -import org.t246osslab.easybuggy.utils.Closer; -import org.t246osslab.easybuggy.utils.HTTPResponseCreator; -import org.t246osslab.easybuggy.utils.MessageUtils; -//import sun.dc.path.PathConsumer; -//import sun.dc.pr.PathDasher; +import sun.misc.Unsafe; @SuppressWarnings("serial") @WebServlet(urlPatterns = { "/jvmcrasheav" }) public class JVMCrashByEAVServlet extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - // PathDasher dasher = new PathDasher(null); - PrintWriter writer = null; + try { - Class cl = Class.forName("sun.dc.pr.PathDasher"); - Class cl2 = Class.forName("sun.dc.path.PathConsumer"); - Constructor cunstructor = cl.getConstructor(new Class[] { cl2 }); - cunstructor.newInstance(new Object[] { null }); + getUnsafe().getByte(0); } catch (Exception e) { Logger.error(e); - HTTPResponseCreator.createSimpleResponse(res, null, - MessageUtils.getMsg("msg.info.jvm.not.crash", req.getLocale())); - } finally { - Closer.close(writer); } } + + private static Unsafe getUnsafe() + throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + Field singleoneInstanceField = Unsafe.class.getDeclaredField("theUnsafe"); + singleoneInstanceField.setAccessible(true); + return (Unsafe) singleoneInstanceField.get(null); + } } diff --git a/src/main/resources/indexpage_en.properties b/src/main/resources/indexpage_en.properties index 703fa88f..343944fd 100644 --- a/src/main/resources/indexpage_en.properties +++ b/src/main/resources/indexpage_en.properties @@ -15,9 +15,8 @@ function.name.dead.lock2=Dead Lock (SQL) function.description.dead.lock2=Dead lock (SQL) occurs after loading the page few times. function.name.endless.waiting.process=Endless Waiting Process function.description.endless.waiting.process=Endless waiting process occurs after loading the page. -function.name.jvm.crash.eav=JVM Crash (EXCEPTION_ACCESS_VIOLATION) -function.description.jvm.crash.eav=JVM crashes after clicking this link.
\ -(* JVM crash only occurs if using Oracle JDK 6 or 7) +function.name.jvm.crash.eav=JVM Crash +function.description.jvm.crash.eav=JVM crashes after clicking this link. function.name.redirect.loop=Redirect Loop function.description.redirect.loop=Redirect loop occurs after clicking this link. function.name.network.socket.leak=Network Socket Leak diff --git a/src/main/resources/indexpage_ja.properties b/src/main/resources/indexpage_ja.properties index 57bdc648..13f20d3a 100644 --- a/src/main/resources/indexpage_ja.properties +++ b/src/main/resources/indexpage_ja.properties @@ -15,9 +15,8 @@ function.name.dead.lock2=\u30c7\u30c3\u30c9\u30ed\u30c3\u30af (SQL) function.description.dead.lock2=\u30da\u30fc\u30b8\u3092\u6570\u56de\u30ed\u30fc\u30c9\u3059\u308b\u3068\u3001\u30c7\u30c3\u30c9\u30ed\u30c3\u30af(SQL)\u304c\u767a\u751f\u3057\u307e\u3059\u3002 function.name.endless.waiting.process=\u5b8c\u4e86\u3057\u306a\u3044\u30d7\u30ed\u30bb\u30b9\u306e\u5f85\u6a5f function.description.endless.waiting.process=\u30da\u30fc\u30b8\u3092\u30ed\u30fc\u30c9\u3059\u308b\u3068\u3001\u5b8c\u4e86\u3057\u306a\u3044\u30d7\u30ed\u30bb\u30b9\u306e\u5f85\u6a5f\u304c\u767a\u751f\u3057\u307e\u3059\u3002 -function.name.jvm.crash.eav=JVM\u30af\u30e9\u30c3\u30b7\u30e5 (EXCEPTION_ACCESS_VIOLATION) -function.description.jvm.crash.eav=\u3053\u306e\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068JVM\u304c\u30af\u30e9\u30c3\u30b7\u30e5\u3057\u307e\u3059\u3002
\ -(* JVM\u306e\u30af\u30e9\u30c3\u30b7\u30e5\u306f\u3001Oracle JDK 6\u307e\u305f\u306f7\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306b\u306e\u307f\u767a\u751f\u3057\u307e\u3059) +function.name.jvm.crash.eav=JVM\u30af\u30e9\u30c3\u30b7\u30e5 +function.description.jvm.crash.eav=\u3053\u306e\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068JVM\u304c\u30af\u30e9\u30c3\u30b7\u30e5\u3057\u307e\u3059\u3002 function.name.redirect.loop=\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u30eb\u30fc\u30d7 function.description.redirect.loop=\u3053\u306e\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u30eb\u30fc\u30d7\u304c\u767a\u751f\u3057\u307e\u3059\u3002 function.name.network.socket.leak=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bd\u30b1\u30c3\u30c8\u30ea\u30fc\u30af