From 0b9e749f54f409b8ff904f6b253292012ee842b8 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Mon, 9 Dec 2024 20:35:54 +0000 Subject: [PATCH] 8345390: [ubsan] systemDictionaryShared.cpp:964: member call on null pointer Reviewed-by: mbaesken, kbarrett --- src/hotspot/share/classfile/systemDictionaryShared.cpp | 8 +++++++- .../jtreg/runtime/cds/appcds/LambdaInvokeVirtual.java | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index 84b7ea0d6b9..180ba73e681 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -957,11 +957,17 @@ InstanceKlass* SystemDictionaryShared::get_shared_lambda_proxy_class(InstanceKla Symbol* method_type, Method* member_method, Symbol* instantiated_method_type) { + assert(caller_ik != nullptr, "sanity"); + assert(invoked_name != nullptr, "sanity"); + assert(invoked_type != nullptr, "sanity"); + assert(method_type != nullptr, "sanity"); + assert(instantiated_method_type != nullptr, "sanity"); + if (!caller_ik->is_shared() || !invoked_name->is_shared() || !invoked_type->is_shared() || !method_type->is_shared() || - !member_method->is_shared() || + (member_method != nullptr && !member_method->is_shared()) || !instantiated_method_type->is_shared()) { // These can't be represented as u4 offset, but we wouldn't have archived a lambda proxy in this case anyway. return nullptr; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/LambdaInvokeVirtual.java b/test/hotspot/jtreg/runtime/cds/appcds/LambdaInvokeVirtual.java index 8d59d202bbd..f08a3031f48 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/LambdaInvokeVirtual.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/LambdaInvokeVirtual.java @@ -61,13 +61,14 @@ public class LambdaInvokeVirtual { .setArchiveName(archiveName); CDSTestUtils.createArchiveAndCheck(opts); - // run with archive + // run with archive; make sure the lambda is loaded from the archive CDSOptions runOpts = (new CDSOptions()) - .addPrefix("-cp", appJar) + .addPrefix("-cp", appJar, "-Xlog:class+load") .setArchiveName(archiveName) .setUseVersion(false) .addSuffix(mainClass); OutputAnalyzer output = CDSTestUtils.runWithArchive(runOpts); + output.shouldMatch("LambdaInvokeVirtualApp[$][$]Lambda/.*source: shared objects file"); output.shouldHaveExitValue(0); } }