Integrated: 8361712: Improve ShenandoahAsserts printing
Thomas Stuefe
stuefe at openjdk.org
Fri Jul 25 13:37:03 UTC 2025
On Thu, 10 Jul 2025 08:02:05 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> Small changes to ShenandoahAsserts and friends to improve fault-tolerance and usefulness:
>
> - 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 it's 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 several 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
This pull request has now been integrated.
Changeset: 75ff7e15
Author: Thomas Stuefe <stuefe at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/75ff7e15fe0d22149e5b8c5ccf3b702d8dc9b3fa
Stats: 164 lines in 9 files changed: 122 ins; 12 del; 30 mod
8361712: Improve ShenandoahAsserts printing
Reviewed-by: rkennke, asmehra
-------------
PR: https://git.openjdk.org/jdk/pull/26237
More information about the shenandoah-dev
mailing list