RFR: 8369642: [ubsan] nmethod::nmethod null pointer passed as argument 2 to memcpy
Vladimir Kozlov
kvn at openjdk.org
Tue Oct 14 16:22:47 UTC 2025
On Mon, 13 Oct 2025 23:56:20 GMT, Chad Rakoczy <duke at openjdk.org> wrote:
> [JDK-8316694](https://bugs.openjdk.org/browse/JDK-8316694) introduced a counter so that the nmethod immutable data can be shared between relocated nmethods to eliminate an unnecessary copy. The counter is aligned in memory so that must be taken into account when calculating the amount of memory used by the counter
This is annoying. In all places `ImmutableDataReferencesCounterSize` is referenced we have `align_up(ImmutableDataReferencesCounterSize, oopSize)`.
May be we should `#define ImmutableDataReferencesCounterSize oopSize` with comment that we only use 4 bytes for now. We have getter/setter methods which cast to (int*) anyway.
src/hotspot/share/code/nmethod.hpp line 654:
> 652: #endif
> 653:
> 654: address immutable_data_references_counter_begin () const { return immutable_data_end() - align_up(ImmutableDataReferencesCounterSize, oopSize) ; }
I suggest to move `immutable_data_references_counter_begin()` before `#if INCLUDE_JVMCI` so you can use it instead of duplicating code in `speculations_end()` and `scopes_data_end()`.
-------------
PR Review: https://git.openjdk.org/jdk/pull/27778#pullrequestreview-3336502570
PR Review Comment: https://git.openjdk.org/jdk/pull/27778#discussion_r2429757173
More information about the hotspot-compiler-dev
mailing list