8218851: JVM crash in custom classloader stress test, JDK 12 & 13

Handle NULL and unloaded constraint class in loader constraint table, also cope with unloaded but not cleaned out klass in loader constraint entries.

Reviewed-by: hseigel, huntch, stuefe
This commit is contained in:
Coleen Phillimore 2019-02-15 08:21:08 -05:00
parent bec8431683
commit d869d9287f
2 changed files with 6 additions and 3 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2019, 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
@ -77,7 +77,10 @@ LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint(
if (p->hash() == hash) {
if (p->name() == name) {
for (int i = p->num_loaders() - 1; i >= 0; i--) {
if (p->loader_data(i) == loader_data) {
if (p->loader_data(i) == loader_data &&
// skip unloaded klasses
(p->klass() == NULL ||
p->klass()->is_loader_alive())) {
return pp;
}
}

View file

@ -2114,7 +2114,7 @@ void SystemDictionary::check_constraints(unsigned int d_hash,
ss.print(" wants to load %s %s.",
k->external_kind(), k->external_name());
Klass *existing_klass = constraints()->find_constrained_klass(name, class_loader);
if (existing_klass->class_loader() != class_loader()) {
if (existing_klass != NULL && existing_klass->class_loader() != class_loader()) {
ss.print(" A different %s with the same name was previously loaded by %s. (%s)",
existing_klass->external_kind(),
existing_klass->class_loader_data()->loader_name_and_id(),