RFR: 8361712: Improve ShenandoahAsserts printing
Thomas Stuefe
stuefe at openjdk.org
Sat Jul 12 06:43:33 UTC 2025
Small changes to ShenandoahAsserts and friends to improve fault-tolerance and usefulnes:
- In assert_correct, we now check the forwarding pointer first before extracting the narrowKlass from it. The forwarding pointer may be invalid. To do this, the forwarding-pointer-checking-block was moved up to before Klass* checks. We also use SafeFetch-based checks for some added safety.
- In assert_correct, we test the narrowKlass before decoding it. Otherwise, if its 0, we'd assert, if garbage, the resulting Klass* would be garbage.
- In print_failure, we now check pointers for readability before handing them to print_obj
- In print_obj, we now print the extracted narrowKlass, too (useful on Lilliput with its terse ids)
- In print_obj, we print a small hex dump of the header (32bytes). With little cost we get a glance at the raw header and the first members.
- In print_obj, we print to a single stringStream now and use auto indentation. Avoids having to deal with indentation and newlines manually and having to pay for four stringStreams.
- In assert_correct, I raised the print level for some of the klass-related assertions to safe_oop since the oop, since the hardened version of print_obj now avoids tripping over invalid Klass*
Tests: I manually tested the patch with a number of manually broken oops of various flavours.
Example output, invalid forwardee:
Referenced from:
no interior location recorded (probably a plain heap scan, or detached oop)
Object:
0x00000007cd800000 - nk 1798104 klass 0x00000000921b6fd8 [Ljava.lang.Object;
allocated after mark start
after update watermark
marked strong
marked weak
not in collection set
mark: marked(0xdeaddeaddeaddeaf)
region: | 3812|R |Y|BTE 7cd800000, 7cd920bf8, 7cdc00000|TAMS 7cd800000|UWM 7cd800000|U 1154K|T 0B|G 0B|S 1154K|L 0B|CP 0
0x00000007cd800000: deaddeaddeaddeaf 00000a96001b6fd8 f9b005cff9b0054d f9b006d3f9b00651 .........o......M.......Q.......
0x00000007cd800020: f9b00797f9b00755 f9b00992f9b0087d f9b009a0f9b00999 f9b009a7f9b0098e U.......}.......................
Forwardee:
0xdeaddeaddeaddeac - safe print, no details
-------------
Commit messages:
- small revert
- cosmetics
- wip
- wip
- wip
- wip
- assert_correct
Changes: https://git.openjdk.org/jdk/pull/26237/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26237&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8361712
Stats: 164 lines in 9 files changed: 122 ins; 12 del; 30 mod
Patch: https://git.openjdk.org/jdk/pull/26237.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/26237/head:pull/26237
PR: https://git.openjdk.org/jdk/pull/26237
More information about the shenandoah-dev
mailing list