Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/hotspot/share/classfile/classLoaderData.cpp
Expand Up @@ -821,6 +821,7 @@ void ClassLoaderData::add_to_deallocate_list(Metadata* m) {
_deallocate_list = new (ResourceObj::C_HEAP, 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();
}
Expand Down
8 changes: 2 additions & 6 deletions src/hotspot/share/oops/klass.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -63,10 +63,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());
Expand Down Expand Up @@ -786,7 +782,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");
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/oops/klass.hpp
Expand Up @@ -268,7 +268,8 @@ class Klass : public Metadata {
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.
Expand Down
6 changes: 5 additions & 1 deletion src/hotspot/share/oops/oopHandle.hpp
@@ -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
Expand Down Expand Up @@ -55,6 +55,10 @@ class OopHandle {
return *this;
}

void swap(OopHandle& copy) {
::swap(_obj, copy._obj);
}

inline oop resolve() const;
inline oop peek() const;

Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/prims/jvmtiRedefineClasses.cpp
Expand Up @@ -1318,22 +1318,22 @@ class RedefineVerifyMark : public StackObj {
private:
JvmtiThreadState* _state;
Klass* _scratch_class;
Handle _scratch_mirror;
OopHandle _scratch_mirror;

public:

RedefineVerifyMark(Klass* the_class, Klass* scratch_class,
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();
}
};
Expand Down