RFR: 8341020: Metaspace::contains crashes when Metaspace is not fully initialized
Johan Sjölen
jsjolen at openjdk.org
Thu Oct 3 09:32:36 UTC 2024
On Mon, 30 Sep 2024 08:35:37 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
>> src/hotspot/share/memory/metaspace.cpp line 996:
>>
>>> 994: bool Metaspace::is_in_nonclass_metaspace(const void* ptr) {
>>> 995: VirtualSpaceList* list = VirtualSpaceList::vslist_nonclass();
>>> 996: return (list != nullptr) && list->contains((MetaWord*) ptr);
>>
>> I'm not sure about this. This, and a number of other related functions nearby,
>> all seem like they should have Metaspace::initialized() as a precondition. And
>> the call to Metaspace::contains in os::print_location should be conditional on
>> Metaspace::initialized(). (There may be other "is initialized" checks that
>> should be made by (and offered to) os::print_location, but that's beyond the
>> scope of this change.)
>
> FWIW, we had a similar discussion in #19435.
All of these methods are public. I think that it seems sane to assume that they are the boundary for checking whether Metaspace is initialized before doing something.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21206#discussion_r1785918008
More information about the hotspot-runtime-dev
mailing list