Skip to content

Instantly share code, notes, and snippets.

@stefmoon
Created April 2, 2013 09:14
Show Gist options
  • Save stefmoon/5290977 to your computer and use it in GitHub Desktop.
Save stefmoon/5290977 to your computer and use it in GitHub Desktop.
一个简单的Java代码bug造成的crash
import java.lang.reflect.Field;
import sun.misc.Unsafe;
public class crash
{
public static void main(String args[])throws Exception
{
Field theUnsafeInstance = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafeInstance.setAccessible(true);
Unsafe UNSAFE = (Unsafe)theUnsafeInstance.get(Unsafe.class);
UNSAFE.putInt(0,0);
}
}
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00002ac099af9204, pid=22158, tid=1093695808
#
# JRE version: Java(TM) SE Runtime Environment (8.0-b67) (build 1.8.0-ea-b67)
# Java VM: OpenJDK 64-Bit Server VM (25.0-b26-internal mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x9d9204] Unsafe_SetNativeInt+0xd4
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
--------------- T H R E A D ---------------
Current thread (0x0000000015c89800): JavaThread "main" [_thread_in_vm, id=22159, stack(0x0000000041207000,0x0000000041308000)]
siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x0000000000000000
Registers:
RAX=0x0000000015c89800, RBX=0x0000000015c89800, RCX=0x0000000015c89800, RDX=0x000000347f616280
RSP=0x00000000413069e0, RBP=0x0000000041306a10, RSI=0x0000000041307a20, RDI=0x0000000000000001
R8 =0x00002aaaab3fbb10, R9 =0x0000000000000004, R10=0x00002aaaabb46486, R11=0x00002ac099a294e0
R12=0x0000000000000000, R13=0x0000000015c89800, R14=0x0000000000000000, R15=0x00002ac099fbde20
RIP=0x00002ac099af9204, EFLAGS=0x0000000000010246, CSGSFS=0x0000000000000033, ERR=0x0000000000000006
TRAPNO=0x000000000000000e
Top of Stack: (sp=0x00000000413069e0)
0x00000000413069e0: 00002aaaabb4265b 00002aaaab3fbb10
0x00000000413069f0: 0000000000000000 00002aaaab3fbb10
0x0000000041306a00: 0000000041306ac0 0000000015c89800
0x0000000041306a10: 0000000041306a88 00002aaaabb464b2
0x0000000041306a20: 00002aaaab519e60 0000000000000000
0x0000000041306a30: 00002aaaab3fbb10 0000000015c89800
0x0000000041306a40: 00002aaaab733370 0000000041306a48
0x0000000041306a50: 00002aaaab3fbb10 0000000041306ac0
0x0000000041306a60: 00002aaaab3fe870 0000000000000000
0x0000000041306a70: 00002aaaab3fbb10 0000000000000000
0x0000000041306a80: 0000000041306aa8 0000000041306b08
0x0000000041306a90: 00002aaaabb39058 0000000000000000
0x0000000041306aa0: 00002aaaabb42658 0000000000000000
0x0000000041306ab0: 0000000000000000 0000000758612218
0x0000000041306ac0: 0000000758613890 0000000041306ac8
0x0000000041306ad0: 00002aaaab73335c 0000000041306b28
0x0000000041306ae0: 00002aaaab7333e0 0000000000000000
0x0000000041306af0: 00002aaaab733370 0000000041306aa8
0x0000000041306b00: 0000000041306b28 0000000041306b90
0x0000000041306b10: 00002aaaabb3350d 0000000758613890
0x0000000041306b20: 0000000758654c50 0000000758653af8
0x0000000041306b30: 0000000000001fa0 0000000015c89800
0x0000000041306b40: 0000000041306c70 00002aaaab733370
0x0000000041306b50: 00002aaaabb3347f 0000000000000001
0x0000000041306b60: 0000000041306c30 0000000041306f78
0x0000000041306b70: 000000000000000a 00002aaaab733370
0x0000000041306b80: 00002aaaabb43e40 0000000041306dc8
0x0000000041306b90: 0000000041306d50 00002ac09971df04
0x0000000041306ba0: 00002aaa00000001 0000000015c89800
0x0000000041306bb0: 0000000041306ca0 0000000041306c30
0x0000000041306bc0: 0000000041306dc0 0000000041306f70
0x0000000041306bd0: 0000000015c89800 0000000041306f78
Instructions: (pc=0x00002ac099af9204)
0x00002ac099af91e4: 48 8b 05 25 04 49 00 41 c7 85 58 02 00 00 06 00
0x00002ac099af91f4: 00 00 8b 38 e8 0b c2 82 ff c6 80 7c 02 00 00 01
0x00002ac099af9204: 45 89 26 c6 80 7c 02 00 00 00 48 8b 5b 48 48 8b
0x00002ac099af9214: 43 10 4c 8b 63 08 48 83 38 00 74 19 48 8b 73 28
Register to memory mapping:
RAX=0x0000000015c89800 is a thread
RBX=0x0000000015c89800 is a thread
RCX=0x0000000015c89800 is a thread
RDX=0x000000347f616280: <offset 0x216280> in /lib64/libpthread.so.0 at 0x000000347f400000
RSP=0x00000000413069e0 is pointing into the stack for thread: 0x0000000015c89800
RBP=0x0000000041306a10 is pointing into the stack for thread: 0x0000000015c89800
RSI=0x0000000041307a20 is pointing into the stack for thread: 0x0000000015c89800
RDI=0x0000000000000001 is an unknown value
R8 =0x00002aaaab3fbb10 is an unknown value
R9 =0x0000000000000004 is an unknown value
R10=0x00002aaaabb46486 is at code_begin+678 in an Interpreter codelet
method entry point (kind = native) [0x00002aaaabb461e0, 0x00002aaaabb46b00] 2336 bytes
R11=0x00002ac099a294e0: <offset 0x9094e0> in /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/server/libjvm.so at 0x00002ac099120000
R12=0x0000000000000000 is an unknown value
R13=0x0000000015c89800 is a thread
R14=0x0000000000000000 is an unknown value
R15=0x00002ac099fbde20: <offset 0xe9de20> in /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/server/libjvm.so at 0x00002ac099120000
Stack: [0x0000000041207000,0x0000000041308000], sp=0x00000000413069e0, free space=1022k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x9d9204] Unsafe_SetNativeInt+0xd4
j sun.misc.Unsafe.putInt(JI)V+0
j crash.main([Ljava/lang/String;)V+28
v ~StubRoutines::call_stub
V [libjvm.so+0x5fdf04] JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*)+0x884
V [libjvm.so+0x60f02c] jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)+0x3dc
V [libjvm.so+0x63549a] jni_CallStaticVoidMethod+0x1fa
C [libjli.so+0x77e4] JavaMain+0x844
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j sun.misc.Unsafe.putInt(JI)V+0
j crash.main([Ljava/lang/String;)V+28
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x00002aaacc007800 JavaThread "Service Thread" daemon [_thread_blocked, id=22179, stack(0x0000000042c39000,0x0000000042d3a000)]
0x00002aaacc003800 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=22178, stack(0x0000000042b38000,0x0000000042c39000)]
0x00002aaacc001000 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=22177, stack(0x0000000040fd0000,0x00000000410d1000)]
0x0000000015d7c000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=22176, stack(0x00000000400de000,0x00000000401df000)]
0x0000000015d56000 JavaThread "Finalizer" daemon [_thread_blocked, id=22175, stack(0x0000000042a37000,0x0000000042b38000)]
0x0000000015d4e000 JavaThread "Reference Handler" daemon [_thread_blocked, id=22174, stack(0x0000000041b61000,0x0000000041c62000)]
=>0x0000000015c89800 JavaThread "main" [_thread_in_vm, id=22159, stack(0x0000000041207000,0x0000000041308000)]
Other Threads:
0x0000000015d48000 VMThread [stack: 0x0000000041605000,0x0000000041706000] [id=22173]
0x00002aaacc013000 WatcherThread [stack: 0x0000000042d3a000,0x0000000042e3b000] [id=22180]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
PSYoungGen total 150208K, used 2575K [0x0000000758600000, 0x0000000762da0000, 0x0000000800000000)
eden space 128768K, 2% used [0x0000000758600000,0x0000000758883d80,0x00000007603c0000)
from space 21440K, 0% used [0x00000007618b0000,0x00000007618b0000,0x0000000762da0000)
to space 21440K, 0% used [0x00000007603c0000,0x00000007603c0000,0x00000007618b0000)
ParOldGen total 343296K, used 0K [0x0000000609200000, 0x000000061e140000, 0x0000000758600000)
object space 343296K, 0% used [0x0000000609200000,0x0000000609200000,0x000000061e140000)
Metaspace total 4486K, used 2195K, reserved 110592K
data space 4100K, used 1949K, reserved 8192K
class space 386K, used 245K, reserved 102400K
Card table byte_map: [0x00002aaaaebf3000,0x00002aaaafbab000] byte_map_base: 0x00002aaaabbaa000
Polling page: 0x00002aaaaaef8000
CodeCache: size=49152Kb used=375Kb max_used=375Kb free=48776Kb max_free_chunk=48776Kb
bounds [0x00002aaaabb33000, 0x00002aaaabda3000, 0x00002aaaaeb33000]
total_blobs=159 nmethods=0 adapters=129
compilation: enabled
Compilation events (0 events):
No events
GC Heap History (0 events):
No events
Deoptimization events (0 events):
No events
Internal exceptions (3 events):
Event: 0.026 Thread 0x0000000015c89800 Threw 0x0000000758612bc8 at /home/yunda.mly/hotspot-rt/src/share/vm/prims/jni.cpp:3995
Event: 0.026 Thread 0x0000000015c89800 Threw 0x0000000758612e28 at /home/yunda.mly/hotspot-rt/src/share/vm/prims/jni.cpp:3995
Event: 0.057 Thread 0x0000000015c89800 Threw 0x000000075864e980 at /home/yunda.mly/hotspot-rt/src/share/vm/prims/jvm.cpp:1159
Events (10 events):
Event: 0.060 loading class 0x00002aaac40be240
Event: 0.061 loading class 0x00002aaac40be240 done
Event: 0.061 loading class 0x00002aaac40a5d00
Event: 0.061 loading class 0x00002aaac40a5d00 done
Event: 0.062 loading class 0x00002aaac40c0160
Event: 0.062 loading class 0x00002aaac40c0160 done
Event: 0.062 loading class 0x00002aaac40f04d0
Event: 0.062 loading class 0x00002aaac40f0820
Event: 0.062 loading class 0x00002aaac40f0820 done
Event: 0.062 loading class 0x00002aaac40f04d0 done
Dynamic libraries:
00400000-00401000 r-xp 00000000 68:09 44240974 /home/yunda.mly/install/jdk1.8.0/bin/java
00600000-00601000 rw-p 00000000 68:09 44240974 /home/yunda.mly/install/jdk1.8.0/bin/java
15c80000-15d88000 rw-p 15c80000 00:00 0 [heap]
400de000-400e1000 ---p 400de000 00:00 0
400e1000-401df000 rw-p 400e1000 00:00 0
40fd0000-40fd3000 ---p 40fd0000 00:00 0
40fd3000-410d1000 rw-p 40fd3000 00:00 0
41207000-4120a000 ---p 41207000 00:00 0
4120a000-41308000 rw-p 4120a000 00:00 0
41605000-41606000 ---p 41605000 00:00 0
41606000-41706000 rw-p 41606000 00:00 0
418d3000-418d4000 ---p 418d3000 00:00 0
418d4000-419d4000 rw-p 418d4000 00:00 0
41b61000-41b64000 ---p 41b61000 00:00 0
41b64000-41c62000 rw-p 41b64000 00:00 0
41e2b000-41e2c000 ---p 41e2b000 00:00 0
41e2c000-41f2c000 rw-p 41e2c000 00:00 0
41f2c000-41f2d000 ---p 41f2c000 00:00 0
41f2d000-4202d000 rw-p 41f2d000 00:00 0
4202d000-4202e000 ---p 4202d000 00:00 0
4202e000-4212e000 rw-p 4202e000 00:00 0
4212e000-4212f000 ---p 4212e000 00:00 0
4212f000-4222f000 rw-p 4212f000 00:00 0
4222f000-42230000 ---p 4222f000 00:00 0
42230000-42330000 rw-p 42230000 00:00 0
42330000-42331000 ---p 42330000 00:00 0
42331000-42431000 rw-p 42331000 00:00 0
42431000-42432000 ---p 42431000 00:00 0
42432000-42532000 rw-p 42432000 00:00 0
42532000-42533000 ---p 42532000 00:00 0
42533000-42633000 rw-p 42533000 00:00 0
42633000-42634000 ---p 42633000 00:00 0
42634000-42734000 rw-p 42634000 00:00 0
42734000-42735000 ---p 42734000 00:00 0
42735000-42835000 rw-p 42735000 00:00 0
42835000-42836000 ---p 42835000 00:00 0
42836000-42936000 rw-p 42836000 00:00 0
42936000-42937000 ---p 42936000 00:00 0
42937000-42a37000 rw-p 42937000 00:00 0
42a37000-42a3a000 ---p 42a37000 00:00 0
42a3a000-42b38000 rw-p 42a3a000 00:00 0
42b38000-42b3b000 ---p 42b38000 00:00 0
42b3b000-42c39000 rw-p 42b3b000 00:00 0
42c39000-42c3c000 ---p 42c39000 00:00 0
42c3c000-42d3a000 rw-p 42c3c000 00:00 0
42d3a000-42d3b000 ---p 42d3a000 00:00 0
42d3b000-42e3b000 rw-p 42d3b000 00:00 0
602e00000-602e68000 rw-p 602e00000 00:00 0
602e68000-609200000 rw-p 602e68000 00:00 0
609200000-61e140000 rw-p 609200000 00:00 0
61e140000-758600000 rw-p 61e140000 00:00 0
758600000-762da0000 rw-p 758600000 00:00 0
762da0000-800000000 rw-p 762da0000 00:00 0
347e800000-347e81c000 r-xp 00000000 68:02 929560 /lib64/ld-2.5.so
347ea1b000-347ea1c000 r--p 0001b000 68:02 929560 /lib64/ld-2.5.so
347ea1c000-347ea1d000 rw-p 0001c000 68:02 929560 /lib64/ld-2.5.so
347ec00000-347ed4d000 r-xp 00000000 68:02 929561 /lib64/libc-2.5.so
347ed4d000-347ef4d000 ---p 0014d000 68:02 929561 /lib64/libc-2.5.so
347ef4d000-347ef51000 r--p 0014d000 68:02 929561 /lib64/libc-2.5.so
347ef51000-347ef52000 rw-p 00151000 68:02 929561 /lib64/libc-2.5.so
347ef52000-347ef57000 rw-p 347ef52000 00:00 0
347f000000-347f002000 r-xp 00000000 68:02 929562 /lib64/libdl-2.5.so
347f002000-347f202000 ---p 00002000 68:02 929562 /lib64/libdl-2.5.so
347f202000-347f203000 r--p 00002000 68:02 929562 /lib64/libdl-2.5.so
347f203000-347f204000 rw-p 00003000 68:02 929562 /lib64/libdl-2.5.so
347f400000-347f416000 r-xp 00000000 68:02 929566 /lib64/libpthread-2.5.so
347f416000-347f615000 ---p 00016000 68:02 929566 /lib64/libpthread-2.5.so
347f615000-347f616000 r--p 00015000 68:02 929566 /lib64/libpthread-2.5.so
347f616000-347f617000 rw-p 00016000 68:02 929566 /lib64/libpthread-2.5.so
347f617000-347f61b000 rw-p 347f617000 00:00 0
347f800000-347f882000 r-xp 00000000 68:02 929567 /lib64/libm-2.5.so
347f882000-347fa81000 ---p 00082000 68:02 929567 /lib64/libm-2.5.so
347fa81000-347fa82000 r--p 00081000 68:02 929567 /lib64/libm-2.5.so
347fa82000-347fa83000 rw-p 00082000 68:02 929567 /lib64/libm-2.5.so
347fc00000-347fc07000 r-xp 00000000 68:02 929568 /lib64/librt-2.5.so
347fc07000-347fe07000 ---p 00007000 68:02 929568 /lib64/librt-2.5.so
347fe07000-347fe08000 r--p 00007000 68:02 929568 /lib64/librt-2.5.so
347fe08000-347fe09000 rw-p 00008000 68:02 929568 /lib64/librt-2.5.so
2aaaaaaab000-2aaaaaaac000 rw-p 2aaaaaaab000 00:00 0
2aaaaaabf000-2aaaaaacc000 r-xp 00000000 68:09 61702408 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/libverify.so
2aaaaaacc000-2aaaaaccb000 ---p 0000d000 68:09 61702408 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/libverify.so
2aaaaaccb000-2aaaaaccd000 rw-p 0000c000 68:09 61702408 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/libverify.so
2aaaaaccd000-2aaaaacf6000 r-xp 00000000 68:09 61702448 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/libjava.so
2aaaaacf6000-2aaaaaef6000 ---p 00029000 68:09 61702448 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/libjava.so
2aaaaaef6000-2aaaaaef8000 rw-p 00029000 68:09 61702448 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/libjava.so
2aaaaaef8000-2aaaaaef9000 r--p 2aaaaaef8000 00:00 0
2aaaaaef9000-2aaaaaefa000 rw-p 2aaaaaef9000 00:00 0
2aaaaaefa000-2aaaaaf02000 rw-s 00000000 68:08 832835 /tmp/hsperfdata_yunda.mly/22158
2aaaaaf0c000-2aaaaaf16000 r-xp 00000000 68:02 928955 /lib64/libnss_files-2.5.so
2aaaaaf16000-2aaaab115000 ---p 0000a000 68:02 928955 /lib64/libnss_files-2.5.so
2aaaab115000-2aaaab116000 r--p 00009000 68:02 928955 /lib64/libnss_files-2.5.so
2aaaab116000-2aaaab117000 rw-p 0000a000 68:02 928955 /lib64/libnss_files-2.5.so
2aaaab117000-2aaaab133000 r-xp 00000000 68:09 61702422 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/libzip.so
2aaaab133000-2aaaab332000 ---p 0001c000 68:09 61702422 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/libzip.so
2aaaab332000-2aaaab333000 rw-p 0001b000 68:09 61702422 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/libzip.so
2aaaab333000-2aaaab773000 rw-p 2aaaab333000 00:00 0
2aaaab773000-2aaaabb33000 rw-p 2aaaab773000 00:00 0
2aaaabb33000-2aaaabda3000 rwxp 2aaaabb33000 00:00 0
2aaaabda3000-2aaaaeb33000 rw-p 2aaaabda3000 00:00 0
2aaaaeb33000-2aaaaeb3d000 rw-p 2aaaaeb33000 00:00 0
2aaaaeb3d000-2aaaaebf3000 rw-p 2aaaaeb3d000 00:00 0
2aaaaebf3000-2aaaaec9b000 rw-p 2aaaaebf3000 00:00 0
2aaaaec9b000-2aaaaf66d000 rw-p 2aaaaec9b000 00:00 0
2aaaaf66d000-2aaaaf6c1000 rw-p 2aaaaf66d000 00:00 0
2aaaaf6c1000-2aaaafbaa000 rw-p 2aaaaf6c1000 00:00 0
2aaaafbaa000-2aaaafc53000 rw-p 2aaaafbaa000 00:00 0
2aaaafc53000-2aaab0625000 rw-p 2aaaafc53000 00:00 0
2aaab0625000-2aaac40f4000 rw-p 2aaab0625000 00:00 0
2aaac40f4000-2aaac42b1000 r--s 039da000 68:09 44241006 /home/yunda.mly/install/jdk1.8.0/jre/lib/rt.jar
2aaac42b1000-2aaac6ed7000 rw-p 2aaac42b1000 00:00 0
2aaac6ed7000-2aaaca4ad000 r--p 00000000 68:06 1720704 /usr/lib/locale/locale-archive
2aaaca4ad000-2aaaca6dc000 rw-p 2aaaca4ad000 00:00 0
2aaacc000000-2aaacc042000 rw-p 2aaacc000000 00:00 0
2aaacc042000-2aaad0000000 ---p 2aaacc042000 00:00 0
2ac098ef2000-2ac098ef4000 rw-p 2ac098ef2000 00:00 0
2ac098f06000-2ac098f1d000 r-xp 00000000 68:09 61735013 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/jli/libjli.so
2ac098f1d000-2ac09911c000 ---p 00017000 68:09 61735013 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/jli/libjli.so
2ac09911c000-2ac09911d000 rw-p 00016000 68:09 61735013 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/jli/libjli.so
2ac09911d000-2ac099120000 rw-p 2ac09911d000 00:00 0
2ac099120000-2ac099cf0000 r-xp 00000000 68:09 61767876 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/server/libjvm.so
2ac099cf0000-2ac099eef000 ---p 00bd0000 68:09 61767876 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/server/libjvm.so
2ac099eef000-2ac099fac000 rw-p 00bcf000 68:09 61767876 /home/yunda.mly/install/jdk1.8.0/jre/lib/amd64/server/libjvm.so
2ac099fac000-2ac099fe8000 rw-p 2ac099fac000 00:00 0
7fffcbb5d000-7fffcbb72000 rw-p 7ffffffea000 00:00 0 [stack]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vdso]
VM Arguments:
java_command: crash
java_class_path (initial): .
Launcher Type: SUN_STANDARD
Memory: 4k page, physical 32956236k(18747812k free), swap 0k(0k free)
vm_info: OpenJDK 64-Bit Server VM (25.0-b26-internal) for linux-amd64 JRE (1.8.0), built on Apr 1 2013 09:35:55 by "yunda.mly" with gcc 4.1.2 20080704 (Red Hat 4.1.2-46)
time: Tue Apr 2 17:09:19 2013
elapsed time: 0 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment