-
Notifications
You must be signed in to change notification settings - Fork 2
/
analyzingHotSpotCrashes.xhtml
1672 lines (1415 loc) · 72.8 KB
/
analyzingHotSpotCrashes.xhtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Analyzing HotSpot Crashes</title>
<meta name="description" content="Describe how to detect and analyze different classes of HotSpot crashes." />
<meta name="author" content="Volker H. Simonis" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />
<link rel="stylesheet" href="reveal.js/css/reveal.css" />
<link rel="stylesheet" href="reveal.js/css/theme/jbreak2016.css" id="theme" />
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="reveal.js/lib/css/monokai_sublime.css" />
<style type="text/css">
.scrollable {
bottom: 0px;
overflow-y: auto !important;
overflow-x: hidden !important;
}
.reveal .slides > section.demo,
.reveal .slides > section > section.demo {
padding: 0;
height: 100%;
}
.reveal .big {
font-size: .8em;
line-height: 1.3em;
}
.reveal pre.console {
background-color: black;
color: #00ff00;
}
code.terminal .hljs-title {
color: #00ff00;
}
.reveal pre.noshadow {
border-radius: 0;
box-shadow: unset;
}
.reveal pre code {
max-height: 100%;
}
.bold {
font-weight: bold;
}
.reveal .outline_white {
color: white;
text-shadow:
-2px -2px 0 #000,
2px -2px 0 #000,
-2px 2px 0 #000,
2px 2px 0 #000;
min-height: 1.1em;
text-align: center;
}
.reveal .outline_black {
color: black;
text-shadow:
-2px -2px 0 #fff,
2px -2px 0 #fff,
-2px 2px 0 #fff,
2px 2px 0 #fff;
min-height: 1.1em;
text-align: center;
}
.reveal .slide-number {
position: fixed;
display: block;
left: 15px;
bottom: 15px;
opacity: 0.9;
z-index: 31;
font-size: 14px;
}
.reveal h1, .reveal h2, .reveal h3, .reveal h4, .reveal h5, .reveal h6 {
text-transform: none;
}
.hljs-class .hljs-title {
/* fix "public static class Y extends X {" such that 'Y' will be formatted the same like 'X' */
color: #A6E22E;
font-style: italic;
}
mark {
color: black;
background-color: yellow;
border-radius: 10px;
}
mark.orange {
color: black;
background-color: orange;
border-radius: 10px;
}
mark.border {
color: inherit;
background-color: inherit;
border: 5px solid #1B91FF;
border-radius: 10px;
}
.reveal .slides section .fragment.highlight-border, .reveal .slides section .fragment.highlight-current-border {
opacity: 1;
visibility: visible;
}
.reveal .slides section .fragment.highlight-border.visible {
border: 5px solid #1B91FF;
border-radius: 10px;
}
.reveal .slides section .fragment.highlight-current-border.current-fragment {
border: 5px solid #1B91FF;
border-radius: 10px;
}
table.calling_hirarchy {
/* font-family: monospace, arial, helvetica, sans-serif; */
/* background-color: #ffffff; */
font-size: smaller;
border-collapse: collapse;
margin: 0px auto;
padding: 2px;
width: auto;
overflow: auto;
border: none;
}
table.calling_hirarchy tr {
border: none;
}
table.calling_hirarchy td {
padding: 4px;
/* font-family: monospace; */
}
td.indent_level_0 {
border-style: solid;
border-width: 2px;
background-color: #a0a0a0;
}
td.indent_level_1 {
border-style: solid;
border-width: 2px;
background-color: #a8a8a8;
}
td.indent_level_2 {
border-style: solid;
border-width: 2px;
background-color: #b0b0b0;
}
td.indent_level_3 {
border-style: solid;
border-width: 2px;
background-color: #b8b8b8;
}
td.indent_level_4 {
border-style: solid;
border-width: 2px;
background-color: #c0c0c0;
}
td.indent_level_5 {
border-style: solid;
border-width: 2px;
background-color: #c8c8c8;
}
td.indent_level_6 {
border-style: solid;
border-width: 2px;
background-color: #d0d0d0;
}
td.indent_level_7 {
border-style: solid;
border-width: 2px;
background-color: #d8d8d8;
}
td.indent_level_8 {
border-style: solid;
border-width: 2px;
background-color: #e0e0e0;
}
td.indent_level_9 {
border-style: solid;
border-width: 2px;
background-color: #e8e8e8;
}
td.indent_level_10 {
border-style: solid;
border-width: 2px;
background-color: #f0f0f0;
}
td.indent_level_11 {
border-style: solid;
border-width: 2px;
background-color: #f8f8f8;
}
td.indent_level_12 {
border-style: solid;
border-width: 2px;
background-color: #ffffff;
}
td.functionCall {
/* font-weight: bold; */
color: darkblue;
}
td.javaCall {
font-weight: bold;
color: darkgreen;
}
td.comment {
font-style: italic;
color: maroon;
}
td.highlight {
border-style: solid;
border-width: 2px;
background-color: #a0ffa0;
}
table.calling_hirarchy td[rowspan] {
border-style: none;
border-width: 0;
border-left: dotted;
border-left-width: 2px;
}
</style>
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'reveal.js/css/print/pdf.css' : 'reveal.js/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="reveal.js/lib/js/html5shiv.js"></script>
<![endif]-->
<!--
Issue #1105: Keyboard shortcut to skip forward/back over fragments #1173
https://github.com/hakimel/reveal.js/pull/1173
-->
</head>
<!--
;; select this code and do 'M-x eval-region'
(defun make-fragment (p1 p2)
"Wraps the selection into 'fragment' <span>s."
(interactive "r")
(setq inputStr (buffer-substring-no-properties p1 p2))
(setq inputStr (replace-regexp-in-string "&" "&" inputStr))
(setq inputStr (replace-regexp-in-string "<" "<" inputStr))
(setq inputStr (replace-regexp-in-string ">" ">" inputStr))
(setq resultStr (concat "<span class=\"fragment\">" (concat inputStr "</span>")))
(delete-region p1 p2)
(insert resultStr)
)
(global-set-key (kbd "C-f") 'make-fragment)
;; revert key-binding
;; (global-set-key (kbd "C-f") 'forward-char)
;; (vhs) The following is required to make 'C-c C-t' insert <code> tags without
;; newlines. 'sgml-tag-alist' is the "file-local" version of 'html-tag-alist'
(add-to-list 'html-tag-alist '("code"))
(add-to-list 'sgml-tag-alist '("code"))
-->
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>Analyzing HotSpot Crashes<br/></h1>
<p>
<small>Volker Simonis [Фолкер Симонис], SAP / <a href="mailto:[email protected]">[email protected]</a></small>
</p>
</section>
<!--
State of /share/OpenJDK/jdk9-dev before we started with JBreak2017:
simonis@simonis:/share/OpenJDK/jdk9-dev$ bash common/bin/hgforest.sh id
# Repositories: . corba jaxp jaxws langtools jdk hotspot nashorn
.: cd . && hg id
corba: cd corba && hg id
jaxp: cd jaxp && hg id
jaxws: cd jaxws && hg id
langtools: cd langtools && hg id
jdk: cd jdk && hg id
hotspot: cd hotspot && hg id
nashorn: cd nashorn && hg id
.: 688a3863c00e tip
hotspot: f3b3d77a1751 tip
corba: a545f54babfa tip
nashorn: 6f5bf136f6c9 tip
jaxp: 48fa77af1532 tip
jaxws: 9b9918656c97 tip
langtools: 37c0e34e835c tip
jdk: ee8923e260c7 tip
/share/output-jdk8u-dbg/images/j2sdk-image/bin/java -XX:MaxMetaspaceSize=6m -XX:+CrashOnOutOfMemoryError -cp /media/sf_C_DRIVE/Users/D046063/public_html/hotspot/JBreak2017/git/examples/bin org.simonis.Crash3 1000
/share/output-jdk8u-dbg/images/j2sdk-image/bin/java -cp /share/output-jdk8u-dbg/images/j2sdk-image/lib/sa-jdi.jar sun.jvm.hotspot.HSDB /share/output-jdk8u-dbg/images/j2sdk-image/bin/java core.4262
Tools -> Class Browser -> Search for "org.simonis" -> two versions of org.simonis.Crash3
/share/output-jdk9-dev-dbg/images/jdk/bin/java -Dsun.jvm.hotspot.runtime.VM.disableVersionCheck -m jdk.hotspot.agent/sun.jvm.hotspot.HSDB
/share/output-jdk9-dev-dbg/images/jdk/bin/java -XX:MaxMetaspaceSize=6m -XX:+CrashOnOutOfMemoryError -cp /media/sf_C_DRIVE/Users/D046063/public_html/hotspot/JBreak2017/git/examples/bin org.simonis.Crash3 1000
/share/output-jdk9-dev-dbg/images/jdk/bin/jhsdb hsdb - -exe /share/output-jdk9-dev-dbg/images/jdk/bin/java - -core core.6780
/share/output-jdk9-dev-dbg/images/jdk/bin/javac - -add-modules jdk.hotspot.agent - -add-exports jdk.hotspot.agent/sun.jvm.hotspot.classfile=ALL-UNNAMED - -add-exports jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED - -add-exports jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED - -add-exports jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED -d /media/sf_C_DRIVE/Users/D046063/public_html/hotspot/JBreak2017/git/examples/bin /media/sf_C_DRIVE/Users/D046063/public_html/hotspot/JBreak2017/git/examples/src/org/simonis/ClassStatistics.java
/share/output-jdk9-dev-dbg/images/jdk/bin/java - -add-modules jdk.hotspot.agent - -add-exports jdk.hotspot.agent/sun.jvm.hotspot.classfile=ALL-UNNAMED - -add-exports jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED - -add-exports jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED - -add-exports jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED -cp /media/sf_C_DRIVE/Users/D046063/public_html/hotspot/JBreak2017/git/examples/bin org.simonis.ClassStatistics /share/output-jdk9-dev-dbg/images/jdk/bin/java core.6780
org.simonis.Crash5
Breakpoint 2, PhaseMacroExpand::generate_arraycopy (this=0x7fff3c6beaf0, ac=0x7fff20181600, alloc=0x0, ctrl=0x7fff3c6be838, mem=0x7fff20185810, io=0x7fff3c6be840, adr_type=0x7fff140032c0, basic_elem_type=T_CONFLICT, src=0x7fff2017e928, src_offset=0x7fff2017c840, dest=0x7fff2017dd90, dest_offset=0x7fff2017c840, copy_length=0x7fff2017c528, disjoint_bases=false, length_never_negative=false, slow_region=0x0)
at /share/OpenJDK/jdk9-dev/hotspot/src/share/vm/opto/macroArrayCopy.cpp:282
(gdb) p _igvn.type(ac->in(13))->is_klassptr()->klass()->as_array_klass()->base_element_type()->print()
<ciInstanceKlass name=org/simonis/Crash5$X loader=0x00007fff46ffd250 loaded=true initialized=true finalized=false subklass=false size=24 flags=public,super ident=1088 address=0x00007fff201495f0>$14 = void
ac->in(ArrayCopyNode::DestKlass)
org.simonis.Crash6
/share/output-jdk9-dev-dbg/images/jdk/bin/java -cp /c/Users/D046063/public_html/hotspot/JBreak2017/git/examples/bin -Xbatch -XX:SuppressErrorAt=/arraycopynode.cpp:228 org.simonis.Crash6
# SIGSEGV (0xb) at pc=0x00007f6b9575b3ad, pid=854, tid=871
#
# JRE version: OpenJDK Runtime Environment (9.0) (slowdebug build 9-internal+0-adhoc.simonis.jdk9-dev)
# Java VM: OpenJDK 64-Bit Server VM (slowdebug 9-internal+0-adhoc.simonis.jdk9-dev, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0xeca3ad] PhaseMacroExpand::generate_arraycopy(ArrayCopyNode*, AllocateArrayNode*, Node**, MergeMemNode*, Node**, TypePtr const*, BasicType, Node*, Node*, Node*, Node*, Node*, bool, bool, RegionNode*)+0x65b
#
# Core dump will be written. Default location: /tmp/core.854
#
# An error report file with more information is saved as:
# /tmp/hs_err_pid854.log
#
# Compiler replay data is saved as:
# /tmp/replay_pid854.log
<section style="height:100%" data-background="images/crash.jpg">
</section>
-->
<section>
<h3 style="text-transform: none;"><a href="https://github.com/simonis/AnalyzingHotSpotCrashes">https://github.com/simonis/AnalyzingHotSpotCrashes</a></h3>
<h3 style="text-transform: none;"><a href="https://rawgit.com/simonis/AnalyzingHotSpotCrashes/master/analyzingHotSpotCrashes.xhtml#/">https://rawgit.com/simonis/AnalyzingHotSpotCrashes/master/analyzingHotSpotCrashes.xhtml</a></h3>
</section>
<section style="height:100%" data-background="images/2015_Nepal_depremi_8.jpg">
<!-- https://commons.wikimedia.org/wiki/File:2015_Nepal_depremi_(8).jpg -->
<div style="height:95%"></div>
<div style="height:5%">
<p><small><a href="https://commons.wikimedia.org/wiki/File:2015_Nepal_depremi_(8).jpg">
https://commons.wikimedia.org/wiki/File:2015_Nepal_depremi_(8).jpg</a></small>
</p>
</div>
</section>
<section class="demo">
<h2>HotSpot VM Overview</h2>
<object data="images/adjusted/VM_Overview.svg" type="image/svg+xml"
style="width: 90%;"> </object>
</section>
<section class="demo">
<!-- the following data is from data/slide1/hs_err_pid4631.log -->
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
$ java -Xmx20m org.simonis.Crash
<span class="fragment"># A fatal error has been detected by the Java Runtime Environment:
#
# <span class="fragment highlight-border">SIGSEGV (0xb) at pc=0x00007fd0c774a17a</span>, pid=4631, tid=4632
#
# JRE version: OpenJDK Runtime Environment (9.0) (slowdebug build 9-internal+0-adhoc.simonis.jdk9-dev)
# Java VM: OpenJDK 64-Bit Server VM (slowdebug 9-internal+0-adhoc.simonis.jdk9-dev, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x127917a] void <span class="fragment highlight-border">MemoryAccess::put<int>(int)+0x62</span>
#
# Core dump will be written. Default location: <span class="fragment highlight-border">/tmp/core.4631</span>
#
# An error report file with more information is saved as:
# <span class="fragment highlight-border">/tmp/JBreak2017_crash/hs_err_pid4631.log</span>
$</span><span class="fragment"> ulimit -c
0 // No core file will be written
$</span><span class="fragment"> cat /proc/sys/kernel/core_pattern
|/usr/share/apport/apport %p %s %c %P // core file will be piped to apport
$ </span>
</code>
</pre>
</section>
<section class="demo">
<section>
<h2>The <code style="text-transform: none;">Crash</code> Example</h2>
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="java" data-trim="true" data-noescape="true" style="height:100%">
public class Crash {
final static Unsafe UNSAFE = getUnsafe();
public static void crash(int x) {
UNSAFE.putInt(0x99, x);
}
public static void main(String[] args) {
crash(0x42);
}
}
</code>
</pre>
</section>
<section>
<h2><code style="text-transform: none;">hs_err_pid4631.log</code> - Summary</h2>
<!-- the following data is from data/slide1/hs_err_pid4631.log -->
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
--------------- S U M M A R Y ------------
Command Line: <span class="fragment highlight-border">-Xmx20m org.simonis.Crash</span>
Host: simonis, Intel(R) <span class="fragment highlight-border">Core(TM) i5-4300U CPU</span> @ 1.90GHz, 4 cores, 7G, \
Ubuntu 14.04.1 LTS
Time: Tue Mar 14 16:48:36 2017 CET <span class="fragment highlight-border">elapsed time: 1 seconds</span> (0d 0h 0m 1s)
--------------- T H R E A D ---------------
Current thread (0x00007fd0c0019800): JavaThread "main" \
[_thread_in_vm, id=4632, stack(0x00007fd0c8fa0000,0x00007fd0c90a0000)]
</code>
</pre>
</section>
<section>
<h2><code style="text-transform: none;">hs_err_pid4631.log</code> - Java Stack Trace</h2>
<!-- the following data is from data/slide1/hs_err_pid4631.log -->
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j <mark class="border">jdk.internal.misc.Unsafe.putInt(Ljava/lang/Object;JI)</mark>V+0 java.base@9-internal
j jdk.internal.misc.Unsafe.putInt(JI)V+4 java.base@9-internal
j sun.misc.Unsafe.putInt(JI)V+5 jdk.unsupported@9-internal
j <mark class="border">org.simonis.Crash.crash(I)</mark>V+7
j org.simonis.Crash.main([Ljava/lang/String;)V+2
v ~StubRoutines::call_stub
</code>
</pre>
</section>
<section>
<h2><code style="text-transform: none;">hs_err_pid4631.log</code> - Native/Mixed Stack Trace</h2>
<!-- the following data is from data/slide1/hs_err_pid4631.log -->
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
Stack: [0x00007fd0c8fa0000,0x00007fd0c90a0000], sp=0x00007fd0c909e500, free space=1017k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x127917a] void <span class="fragment highlight-border" data-fragment-index="5">MemoryAccess::put<int>(int)</span>+0x62
V [libjvm.so+0x1270574] Unsafe_PutInt+0x174
j jdk.internal.misc.Unsafe.putInt(Ljava/lang/Object;JI)V+0 java.base@9-internal
j jdk.internal.misc.Unsafe.putInt(JI)V+4 java.base@9-internal
j <span class="fragment highlight-border" data-fragment-index="5">sun.misc.Unsafe.putInt(JI)</span>V+5 jdk.unsupported@9-internal
j org.simonis.Crash.crash(I)V+7
j <span class="fragment highlight-border" data-fragment-index="3">org.simonis.Crash.main([Ljava/lang/String;)</span>V+2
v ~StubRoutines::call_stub
V [libjvm.so+0xc6abd5] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x6ad
V [libjvm.so+0x10524b1] os::os_exception_wrapper(void (*)(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*), JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x41
V [libjvm.so+0xc6a512] JavaCalls::call(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0xaa
V [libjvm.so+0xc887dc] jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)+0x1e3
V [libjvm.so+0xc9f1f5] <span class="fragment highlight-border" data-fragment-index="2">jni_CallStaticVoidMethod</span>+0x33b
C [libjli.so+0x49f8] JavaMain+0xac0
C [libpthread.so.0+0x8182] <span class="fragment highlight-border" data-fragment-index="1">start_thread</span>+0xc2
</code>
</pre>
</section>
<section>
<h2>Crash in the Runtime</h2>
<div width="100%" style="position: relative; margin: 0 0 0 0px;">
<div class="" style="position: static;">
<object data="images/adjusted/VM_Overview.svg" type="image/svg+xml"
style="width: 90%;"> </object>
</div>
<div class="fragment" data-fragment-index="1" style="position: absolute; left: 0; top: 0; width: 100%">
<object data="images/adjusted/CrashRuntime_1.svg" type="image/svg+xml"
style="width: 90%;"> </object>
</div>
<div class="fragment" data-fragment-index="2" style="position: absolute; left: 0; top: 0; width: 100%">
<object data="images/adjusted/CrashRuntime_2.svg" type="image/svg+xml"
style="width: 90%;"> </object>
</div>
</div>
</section>
<section>
<h2><code style="text-transform: none;">hs_err_pid4631.log</code> - Register Mapping</h2>
<!-- the following data is from data/slide1/hs_err_pid4631.log -->
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000000000099
Register to memory mapping:
RAX=0x00000000000000<span class="fragment highlight-border" data-fragment-index="1">42</span> is an unknown value
RBX={method} {0x00007fd0798abc98} <span class="fragment highlight-border" data-fragment-index="2">jdk/internal/misc/Unsafe.putInt</span>
RCX=0x00007fd0c0019800 is a thread
RDX=0x00000000000000<span class="fragment highlight-border" data-fragment-index="1">99</span> is an unknown value
RSP=0x00007fd0c909e500 is pointing into the stack for thread: 0x00007fd0c0019800
RBP=0x00007fd0c909e540 is pointing into the stack for thread: 0x00007fd0c0019800
RSI=0x0000000000000042 is an unknown value
RDI=0x00007fd0c909e5c0 is pointing into the stack for thread: 0x00007fd0c0019800
R8 =0x0000000000000042 is an unknown value
R9 =
<span class="fragment highlight-border">[error occurred during error reporting (printing register info), id 0xb]</span>
</code>
</pre>
</section>
<section>
<h2><code style="text-transform: none;">hs_err_pid4631.log</code> - Registers</h2>
<!-- the following data is from data/slide1/hs_err_pid4631.log -->
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
Registers:
RAX=0x00000000000000<mark class="border">42</mark>, RBX=0x00007fd0798abc98, RCX=0x00007fd0c0019800,
RDX=0x00000000000000<mark class="border">99</mark>, RSP=0x00007fd0c909e500, RBP=0x00007fd0c909e540,
RSI=0x0000000000000042, RDI=0x00007fd0c909e5c0, R8 =0x0000000000000042,
R9 =<mark class="border">0x00000000ffffffe0</mark>, R10=0x00007fd0a872da3c, R11=0x0000000000000008
R12=0x0000000000000000, R13=0x00007fd0798abc90, R14=0x00007fd0c909e6c8,
R15=0x00007fd0c0019800, RIP=0x00007fd0c774a17a, EFLAGS=0x0000000000010246,
CSGSFS=0x8cd7000000000033, ERR=0x0000000000000006, TRAPNO=0x000000000000000e
</code>
</pre>
</section>
<section>
<h2><code style="text-transform: none;">hs_err_pid4631.log</code> - Stack/Instructions</h2>
<!-- the following data is from data/slide1/hs_err_pid4631.log -->
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
Top of Stack: (sp=0x00007fd0c909e500)
0x00007fd0c909e500: 00000042c909e540 00007fd0c909e5c0
0x00007fd0c909e510: 0000000000000099 0000000000000099
0x00007fd0c909e520: 00007fd0c0019800 00007fd0c909e501
0x00007fd0c909e530: 00007fd0c909e580 8cd73cc3b5998700
Instructions: (<span class="fragment highlight-border" data-fragment-index="1">pc=0x00007fd0c774a17a</span>)
0x00007fd0c774a15a: 89 c7 e8 ef f5 ff ff 48 89 45 d8 8b 55 c4 48 8b
0x00007fd0c774a16a: 45 c8 89 d6 48 89 c7 e8 60 13 00 00 48 8b 55 d8
<span class="fragment highlight-border" data-fragment-index="1">0x00007fd0c774a17a</span>: 89 02 48 8d 45 e0 48 89 c7 e8 1e f7 ff ff 48 8b
0x00007fd0c774a18a: 45 f8 64 48 33 04 25 28 00 00 00 74 05 e8 14 01
</code>
</pre>
<div style="display:inline-block; text-align: left; width: 85%;">
<p class="fragment" data-fragment-index="2">Using <code>gdb</code>, <code>objdump</code> or <code>https://onlinedisassembler.com</code></p>
</div>
<pre class="big noshadow fragment" data-fragment-index="2" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
<mark class="border">0x00007fd0c774a17a</mark>: mov %eax,(%rdx) // %eax=0x42, %rdx=0x99
...
</code>
</pre>
</section>
</section>
<section class="demo">
<section class="demo">
<h2>Generating <code style="text-transform: none;">hs_err.log</code> Files</h2>
<table class="calling_hirarchy">
<tr>
<td colspan="6" class="functionCall indent_level_3">
<code><signal handler></code>
</td>
</tr>
<tr>
<td rowspan="11"> </td>
<td colspan="5" class="functionCall indent_level_4">
<code>signalHandler(sig=11, info=0x7ffff7fda070, uc=0x7ffff7fd9f40)</code>
</td>
</tr>
<tr>
<td rowspan="10"> </td>
<td colspan="4" class="functionCall indent_level_5">
<code>JVM_handle_linux_signal(sig=11, info=0x7ffff7fda070, <span class="fragment highlight-border">abort_if_unrecognized=1)</span></code>
</td>
</tr>
<tr>
<td rowspan="9"> </td>
<td colspan="3" class="functionCall indent_level_6">
<code>VMError::report_and_die(sig=11, pc=0x7ffff668a17a <MemoryAccess::put>)</code>
</td>
</tr>
<tr>
<td rowspan="8"> </td>
<td colspan="2" class="functionCall indent_level_7">
<code><span class="fragment highlight-border">VMError::report</span>(stream=0x7ffff71aa9e0 <VMError::log>, _verbose=true)</code>
</td>
</tr>
<tr>
<td rowspan="7"> </td>
<td colspan="1" class="functionCall indent_level_8">
<code>print_native_stack(...)</code>
</td>
</tr>
<tr>
<td colspan="1" class="functionCall indent_level_8">
<code>print_stack_trace(...)</code>
</td>
</tr>
<tr>
<td colspan="1" class="functionCall indent_level_8">
<code>os::print_register_info(...)</code>
</td>
</tr>
<!--
<tr>
<td colspan="1" class="functionCall indent_level_8">
<code>Universe::heap()->print_on_error(...)</code>
</td>
</tr>
<tr>
<td colspan="1" class="functionCall indent_level_8">
<code>os::print_dll_info(...)</code>
</td>
</tr>
<tr>
<td colspan="1" class="functionCall indent_level_8">
<code>Arguments::print_on(...)</code>
</td>
</tr>
-->
<tr>
<td colspan="1" class="functionCall indent_level_8">
<code>...</code>
</td>
</tr>
</table>
<div style="display:inline-block; text-align: left;">
<p>Whenever the HotSpot VM encounters an irrevocable error like:</p>
<ul>
<li>an <em style="text-decoration: underline;">unexpected</em> signal</li>
<li>a guarantee or assertion</li>
<li>a native "out of memory" situation</li>
</ul>
<p>it calls <code>VMError::report()</code> which does the job!</p>
</div>
</section>
<section class="demo">
<h2>Generating <code style="text-transform: none;">hs_err</code> Files</h2>
<div style="display:inline-block; width:90%; text-align: left;">
<p>Creating the <code>hs_err</code> file is not trivial:</p>
<ul>
<li>the VM is in an inconsistent state</li>
<li>the VM may run out of native memory / stack space</li>
<li>the internal data structures may be corrupted</li>
<li>have to gracefully handle subsequent signals/assertions/guarantees and timeouts!</li>
</ul>
</div>
<!-- the following data is from data/slide1/hs_err_pid4631.log -->
<!-- see data/slide1/hs_err_pid6275.log for the same example running with -XX:-UseCompressedOops which doesn't produce an error during error reporting -->
<pre class="fragment big noshadow" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true">
Register to memory mapping:
RAX=0x0000000000000042 is an unknown value
RBX={method} {0x00007fd0798abc98} jdk/internal/misc/Unsafe.putInt()
RCX=0x00007fd0c0019800 is a thread
RDX=0x0000000000000099 is an unknown value
R9 =
<span class="fragment highlight-border">[error occurred during error reporting (printing register info), id 0xb]</span>
</code>
</pre>
<div style="display:inline-block; width:90%; text-align: left;">
<ul>
<span class="fragment"><li>use <a href="https://rawgit.com/simonis/hotspot_internals/master/hotspot_internals.xhtml#/1/8"><code>SafeFetch</code></a>
(see <a href="https://rawgit.com/simonis/hotspot_internals/master/hotspot_internals.xhtml">"HotSpot Internals"</a> from
<a href="http://2016.jokerconf.com/">Joker 2016</a>)</li></span>
</ul>
</div>
</section>
</section>
<section>
<h2>Triggering <code style="text-transform: none;">hs_err.log</code> from <code style="text-transform: none;">jcmd</code></h2>
<div style="display:inline-block; width:95%; text-align: left;">
Prints VM information without crash and thread details:
</div>
<pre class="big noshadow" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true">
$ jcmd 27211 VM.info
<span class="fragment"># JRE version: OpenJDK Runtime Environment (9.0) (slowdebug build 9.jdk9-dev)
# Java VM: OpenJDK 64-Bit Server VM (slowdebug 9-internal.simonis.jdk9-dev, \
mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
--------------- S U M M A R Y ------------
Command Line: -Xmx128m HelloAWT
Host: simonis, Intel(R) Core i5-4300U CPU @ 1.90GHz, 4 cores, 7G, Ubuntu 14.04
Time: Fri Mar 24 14:17:50 2017 CET elapsed time: 38 seconds (0d 0h 0m 38s)
--------------- P R O C E S S ---------------
Heap address: 0x00000000f8000000, size: 128 MB, Compressed Oops mode: 32-bit
Narrow klass base: 0x0000000000000000, Narrow klass shift: 3
Compressed class space size: 1073741824 Address: 0x0000000100000000</span>
</code>
</pre>
</section>
<section class="demo">
<section>
<h2>Where did we crash?</h2>
<!-- the following data is from data/slide2/hs_err_pid10985.log -->
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
# SIGSEGV (0xb) at <span class="fragment highlight-current-border" data-fragment-index="2">pc=0x00007f755074ec61</span>, pid=10985, tid=10986
# ...
# Problematic frame:
# <span class="fragment highlight-current-border" data-fragment-index="1">j</span> org.simonis.CrashInt.crash(Lorg/simonis/CrashInt;)I+0
si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), <span class="fragment highlight-current-border" data-fragment-index="4">si_addr: 0x000000000badbaca</span>
...
<span class="fragment highlight-current-border" data-fragment-index="4">RAX=0x000000000badbabe</span> is an unknown value
...
<span class="fragment highlight-current-border" data-fragment-index="3">arraylength</span> 190 [0x00007f755074ec60, 0x00007f755074ec80] 32 bytes
[Disassembling for mach='i386:x86-64']
0x00007f755074ec60: pop %rax // pop array from stack
<span class="fragment highlight-current-border" data-fragment-index="2">0x00007f755074ec61</span>: <span class="fragment highlight-current-border" data-fragment-index="4">mov 0xc(%rax),%eax</span> // load length field
0x00007f755074ec64: movzbl 0x1(%r13),%ebx // load next bytecode
0x00007f755074ec69: inc %r13 // increment bytecode pointer
0x00007f755074ec6c: movabs $0x7f756fd00980,%r10 // load template table
0x00007f755074ec76: jmpq *(%r10,%rbx,8) // jump to next bytecode
</code>
</pre>
</section>
<section>
<h2>Crash in the Interpreter</h2>
<div style="width: 100%">
<div style="float: left; width: 58%">
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="java" data-trim="true" data-noescape="true" style="height:100%">
public class CrashInt {
int[] ia = new int[1];
final static Unsafe UNSAFE = getUnsafe();
public int crash() {
return ia.length;
}
public static void main(String[] args) {
CrashInt ci = <span class="fragment highlight-current-border" data-fragment-index="1">new CrashInt()</span>;
<span class="fragment highlight-border" data-fragment-index="2">UNSAFE.putLong(ci, 12L, 0xbadbabe)</span>;
ci.crash();
}
}
</code>
</pre>
</div>
<div style="position:relative; float: right; width: 42%">
<div class="fragment" data-fragment-index="1" width="100%" style="position: relative; margin: 0 0 0 15px;">
<div class="" style="position: static;">
<object data="images/CrashInt_1.svg" type="image/svg+xml"
style="width: 100%;"> </object>
</div>
<div class="fragment" data-fragment-index="2" style="position: absolute; left: 0; top: 0; width: 100%">
<object data="images/CrashInt_2.svg" type="image/svg+xml"
style="width: 100%;"> </object>
</div>
</div>
<pre class="big noshadow fragment" data-fragment-index="3" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
$ javap -c org.simonis.CrashInt
...
int crash()
Code:
0: aload_0 // load 'this'
1: getfield #23 // int[] this.ia
4: <mark class="border">arraylength</mark>
5: ireturn
</code>
</pre>
</div>
</div>
</section>
<section>
<h2>Crash in the Interpreter</h2>
<div width="100%" style="position: relative; margin: 0 0 0 0px;">
<div class="" style="position: static;">
<object data="images/adjusted/VM_Overview.svg" type="image/svg+xml"
style="width: 90%;"> </object>
</div>
<div class="fragment" data-fragment-index="1" style="position: absolute; left: 0; top: 0; width: 100%">
<object data="images/adjusted/CrashInterpreter_1.svg" type="image/svg+xml"
style="width: 90%;"> </object>
</div>
<div class="fragment" data-fragment-index="2" style="position: absolute; left: 0; top: 0; width: 100%">
<object data="images/adjusted/CrashInterpreter_2.svg" type="image/svg+xml"
style="width: 90%;"> </object>
</div>
<div class="fragment" data-fragment-index="3" style="position: absolute; left: 0; top: 0; width: 100%">
<object data="images/adjusted/CrashInterpreter_3.svg" type="image/svg+xml"
style="width: 90%;"> </object>
</div>
</div>
</section>
<section>
<h2><a href="https://wiki.openjdk.java.net/display/HotSpot/PrintAssembly">The HotSpot Disassembler</a></h2>
<ul>
<li>based on the <a href="https://www.gnu.org/software/binutils/">GNU Binutils Disassembler</a></li>
<li>used for: <code>-XX:+PrintAssembly</code>, <code>-XX:+PrintAssembly</code>, ... </li>
<li>located under <code>hotspot/src/share/tools/hsdis</code></li>
</ul>
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
$ cd /tmp/
$ wget http:∕∕ftp.gnu.org/gnu/binutils/binutils-2.28.tar.gz
$ tar -xzf binutils-2.28.tar.gz
$ cd /OpenJDK/jdk9-dev/hotspot/src/share/tools/hsdis
$ BINUTILS=/tmp/binutils-2.28 make all64
...
$ ll build/linux-amd64/hsdis-amd64.so
-rwxrwxr-x 1 ojdk ojdk 2371436 Apr 3 18:30 build/linux-amd64/<mark class="border">hsdis-amd64.so</mark>
$ export LD_LIBRARY_PATH=`pwd`/build/linux-amd64
$ java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly
Loaded disassembler from <mark class="border">hsdis-amd64.so</mark>
[Disassembling for mach='i386:x86-64']
...
</code>
</pre>
</section>
</section>
<section class="demo">
<section>
<h2>Out of Memory</h2>
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
$ java -Xmx20m -XX:MaxMetaspaceSize=6m org.simonis.CrashOOM
<span class="fragment">Exception in thread "main" java.lang.OutOfMemoryError: Metaspace
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:986)
at org.simonis.CrashOOM$MyClassLoader.myDefineClass(CrashOOM.java:10)
at org.simonis.CrashOOM.crash(CrashOOM.java:30)
at org.simonis.CrashOOM.main(CrashOOM.java:40)</span>
</code>
</pre>
</section>
<section>
<h2>Out of Memory - Let it Crash!</h2>
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
$ java -Xmx20m -XX:MaxMetaspaceSize=6m <span class="fragment highlight-border">-XX:+CrashOnOutOfMemoryError</span> \
org.simonis.CrashOOM
Aborting due to java.lang.OutOfMemoryError: Metaspace
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=/debug.cpp:340
#
# A fatal error has been detected by the Java Runtime Environment:
#
# fatal error: OutOfMemory encountered: Metaspace
#
# Core dump will be written. Default location: <span class="fragment highlight-border">/tmp/JBreak2017_crash_oom/core</span>
#
# An error report file with more information is saved as:
# <span class="fragment highlight-border">/tmp/JBreak2017_crash_oom/hs_err_pid23919.log</span>
</code>
</pre>
</section>
<section>
<h2>Out of Memory - <code style="text-transform: none;">hs_err_pid23919.log</code></h2>
<!-- the following data is from data/slide3/hs_err_pid23919.log -->
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="height:100%">
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0xfa6346] Metaspace::report_metadata_oome()+0x1aa
V [libjvm.so+0xfa60a8] Metaspace::allocate()+0x308
V [libjvm.so+0x5bee05] MetaspaceObj::operator new()+0x4f
V [libjvm.so+0x97bc93] <span class="fragment highlight-current-border" data-fragment-index="5">ConstantPool::allocate()</span>+0x8f
V [libjvm.so+0x851b21] ClassFileParser::parse_stream()+0x42f
V [libjvm.so+0x85128c] <span class="fragment highlight-current-border" data-fragment-index="4">ClassFileParser::ClassFileParser()</span>+0x61c
V [libjvm.so+0xe2ee3f] KlassFactory::create_from_stream()+0x259
V [libjvm.so+0x11fc770] SystemDictionary::resolve_from_stream()+0x238
V [libjvm.so+0xcec45c] jvm_define_class_common()+0x37f
V [libjvm.so+0xcec983] JVM_DefineClassWithSource+0x207
C [libjava.so+0xe6b1] <span class="fragment highlight-current-border" data-fragment-index="3">Java_java_lang_ClassLoader_defineClass1</span>+0x231
j java.lang.ClassLoader.defineClass1()Ljava/lang/Class;+0 java.base@9-internal
j <span class="fragment highlight-current-border" data-fragment-index="2">java.lang.ClassLoader.defineClass()</span>Ljava/lang/Class;+27 java.base@9-internal
j org.simonis.CrashOOM$MyClassLoader.myDefineClass()Ljava/lang/Class;+7
j <span class="fragment highlight-current-border" data-fragment-index="1">org.simonis.CrashOOM.crash(I)</span>V+27
</code>
</pre>
</section>
<section class="demo">
<h2>Out of Memory - <code style="text-transform: none;">hs_err_pid23919.log</code></h2>
<!-- the following data is from data/slide3/hs_err_pid23919.log -->
<pre class="big noshadow" style="height:100%; margin: 0;" data-trim="true">
<code class="terminal" data-trim="true" data-noescape="true" style="">