# HG changeset patch # User coleenp # Date 1550236868 18000 # Node ID 7c17199fa37daaf756863311ac6504605721809f # Parent 5d20b085d893dfece0870fada46d0e3b8ac918cf 8218851: JVM crash in custom classloader stress test, JDK 12 & 13 Summary: 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 diff -r 5d20b085d893 -r 7c17199fa37d src/hotspot/share/classfile/loaderConstraints.cpp --- a/src/hotspot/share/classfile/loaderConstraints.cpp Fri Feb 15 14:15:10 2019 +0100 +++ b/src/hotspot/share/classfile/loaderConstraints.cpp Fri Feb 15 08:21:08 2019 -0500 @@ -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 @@ 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; } } diff -r 5d20b085d893 -r 7c17199fa37d src/hotspot/share/classfile/systemDictionary.cpp --- a/src/hotspot/share/classfile/systemDictionary.cpp Fri Feb 15 14:15:10 2019 +0100 +++ b/src/hotspot/share/classfile/systemDictionary.cpp Fri Feb 15 08:21:08 2019 -0500 @@ -2114,7 +2114,7 @@ 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(),