RFR: 8367298: ZGC: Enhance zaddress type system's assert messages
Stefan Karlsson
stefank at openjdk.org
Wed Sep 10 09:34:29 UTC 2025
On Wed, 10 Sep 2025 05:55:42 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
> 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.
Marked as reviewed by stefank (Reviewer).
src/hotspot/share/gc/z/zAddress.inline.hpp line 290:
> 288: inline zbacking_index to_zbacking_index(zbacking_offset offset) {
> 289: const uintptr_t value = untype(offset);
> 290: assert(is_aligned(value, ZGranuleSize), "Must be granule aligned (" PTR_FORMAT ")", value);
Maybe change to this to be consistent with the changes below
Suggestion:
assert(is_aligned(value, ZGranuleSize), "Must be granule aligned: " PTR_FORMAT, value);
-------------
PR Review: https://git.openjdk.org/jdk/pull/27184#pullrequestreview-3205308038
PR Review Comment: https://git.openjdk.org/jdk/pull/27184#discussion_r2336161585
More information about the hotspot-gc-dev
mailing list