RFR: 8367298: ZGC: Enhance zaddress type system's assert messages

Axel Boldt-Christmas aboldtch at openjdk.org
Wed Sep 10 06:05:47 UTC 2025


ZGC uses a family of strongly type integral types to test and verify invariants for addresses, offset, indices and colored pointers within the heap. It is usually the first place we hit an assert if something goes wrong, and looking at the actual value is often enough to identify if it is memory corruption, a broken color invariant or a mistake in the use of the type system.

Unfortunately not all asserts print the value in the assert message, requiring more extensive investigation to even identify the nature of the problem.

I propose we enhance all our zaddress assert printing to always include the invariant breaking value.

_While I chose to print the max values in the assert message of the offset and indices checks, I did not print the colors in the zpointer checks. Both colors and the max values are easily available in the error report, so it would only really be a problem if a hs_err file is missing._ 

We should probably also see if we can enhance all the rest of our asserts in ZGC similarly. I do not think I have ever seen a failed invariant check and thought "Why are we printing the invariant breaking value", but often feel that it is unfortunate that we did not print the actual value.

-------------

Commit messages:
 - 8367298: ZGC: Enhance zaddress type system's assert messages

Changes: https://git.openjdk.org/jdk/pull/27184/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27184&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8367298
  Stats: 19 lines in 1 file changed: 0 ins; 0 del; 19 mod
  Patch: https://git.openjdk.org/jdk/pull/27184.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27184/head:pull/27184

PR: https://git.openjdk.org/jdk/pull/27184


More information about the hotspot-gc-dev mailing list