8291830: jvmti/RedefineClasses/StressRedefine failed: assert(!is_null(v)) failed: narrow klass value can never be zero

Reviewed-by: sspitsyn, eosterlund, kbarrett
This commit is contained in:
Coleen Phillimore 2022-12-02 19:09:05 +00:00
parent 1b924659c8
commit fb6fd03233
5 changed files with 14 additions and 12 deletions

View File

@ -824,6 +824,7 @@ void ClassLoaderData::add_to_deallocate_list(Metadata* m) {
_deallocate_list = new (mtClass) GrowableArray<Metadata*>(100, mtClass);
}
_deallocate_list->append_if_missing(m);
ResourceMark rm;
log_debug(class, loader, data)("deallocate added for %s", m->print_value_string());
ClassLoaderDataGraph::set_should_clean_deallocate_lists();
}

View File

@ -27,7 +27,7 @@
#include "cds/heapShared.hpp"
#include "classfile/classLoaderData.inline.hpp"
#include "classfile/classLoaderDataGraph.inline.hpp"
#include "classfile/javaClasses.hpp"
#include "classfile/javaClasses.inline.hpp"
#include "classfile/moduleEntry.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/systemDictionaryShared.hpp"
@ -65,10 +65,6 @@ oop Klass::java_mirror_no_keepalive() const {
return _java_mirror.peek();
}
void Klass::replace_java_mirror(oop mirror) {
_java_mirror.replace(mirror);
}
bool Klass::is_cloneable() const {
return _access_flags.is_cloneable_fast() ||
is_subtype_of(vmClasses::Cloneable_klass());
@ -788,7 +784,7 @@ void Klass::verify_on(outputStream* st) {
}
if (java_mirror_no_keepalive() != NULL) {
guarantee(oopDesc::is_oop(java_mirror_no_keepalive()), "should be instance");
guarantee(java_lang_Class::is_instance(java_mirror_no_keepalive()), "should be instance");
}
}

View File

@ -269,7 +269,8 @@ protected:
void set_archived_java_mirror(oop m) NOT_CDS_JAVA_HEAP_RETURN;
// Temporary mirror switch used by RedefineClasses
void replace_java_mirror(oop mirror);
OopHandle java_mirror_handle() const { return _java_mirror; }
void swap_java_mirror_handle(OopHandle& mirror) { _java_mirror.swap(mirror); }
// Set java mirror OopHandle to NULL for CDS
// This leaves the OopHandle in the CLD, but that's ok, you can't release them.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -55,6 +55,10 @@ public:
return *this;
}
void swap(OopHandle& copy) {
::swap(_obj, copy._obj);
}
inline oop resolve() const;
inline oop peek() const;

View File

@ -1324,7 +1324,7 @@ class RedefineVerifyMark : public StackObj {
private:
JvmtiThreadState* _state;
Klass* _scratch_class;
Handle _scratch_mirror;
OopHandle _scratch_mirror;
public:
@ -1332,14 +1332,14 @@ class RedefineVerifyMark : public StackObj {
JvmtiThreadState* state) : _state(state), _scratch_class(scratch_class)
{
_state->set_class_versions_map(the_class, scratch_class);
_scratch_mirror = Handle(_state->get_thread(), _scratch_class->java_mirror());
_scratch_class->replace_java_mirror(the_class->java_mirror());
_scratch_mirror = the_class->java_mirror_handle(); // this is a copy that is swapped
_scratch_class->swap_java_mirror_handle(_scratch_mirror);
}
~RedefineVerifyMark() {
// Restore the scratch class's mirror, so when scratch_class is removed
// the correct mirror pointing to it can be cleared.
_scratch_class->replace_java_mirror(_scratch_mirror());
_scratch_class->swap_java_mirror_handle(_scratch_mirror);
_state->clear_class_versions_map();
}
};