From 5627ff2d9165ee1f7354c1ff1626f4949ef7fa3f Mon Sep 17 00:00:00 2001 From: Dean Long Date: Tue, 2 Dec 2025 18:18:56 +0000 Subject: [PATCH] 8370766: JVM crashes when running compiler/exceptions/TestAccessErrorInCatch.java fails with -XX:+VerifyStack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Manuel Hässig Reviewed-by: mhaessig, chagedorn --- src/hotspot/share/opto/doCall.cpp | 17 +++++++++++------ .../exceptions/TestAccessErrorInCatch.java | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/hotspot/share/opto/doCall.cpp b/src/hotspot/share/opto/doCall.cpp index 91bb743618b..5533b19897b 100644 --- a/src/hotspot/share/opto/doCall.cpp +++ b/src/hotspot/share/opto/doCall.cpp @@ -1059,14 +1059,19 @@ void Parse::catch_inline_exceptions(SafePointNode* ex_map) { assert(!stopped(), "you should return if you finish the chain"); // Oops, need to call into the VM to resolve the klasses at runtime. - // Note: This call must not deoptimize, since it is not a real at this bci! kill_dead_locals(); - make_runtime_call(RC_NO_LEAF | RC_MUST_THROW, - OptoRuntime::rethrow_Type(), - OptoRuntime::rethrow_stub(), - nullptr, nullptr, - ex_node); + { PreserveReexecuteState preexecs(this); + // When throwing an exception, set the reexecute flag for deoptimization. + // This is mostly needed to pass -XX:+VerifyStack sanity checks. + jvms()->set_should_reexecute(true); + + make_runtime_call(RC_NO_LEAF | RC_MUST_THROW, + OptoRuntime::rethrow_Type(), + OptoRuntime::rethrow_stub(), + nullptr, nullptr, + ex_node); + } // Rethrow is a pure call, no side effects, only a result. // The result cannot be allocated, so we use I_O diff --git a/test/hotspot/jtreg/compiler/exceptions/TestAccessErrorInCatch.java b/test/hotspot/jtreg/compiler/exceptions/TestAccessErrorInCatch.java index 46541d76016..44cfd60cf38 100644 --- a/test/hotspot/jtreg/compiler/exceptions/TestAccessErrorInCatch.java +++ b/test/hotspot/jtreg/compiler/exceptions/TestAccessErrorInCatch.java @@ -23,16 +23,18 @@ /* * @test - * @bug 8367002 + * @bug 8367002 8370766 * @summary Compilers might not generate handlers for recursive exceptions * * @compile IllegalAccessInCatch.jasm * @run main/othervm -Xbatch * -XX:CompileCommand=compileonly,IllegalAccessInCatch*::test + * -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyStack * -XX:-TieredCompilation * TestAccessErrorInCatch * @run main/othervm -Xbatch * -XX:CompileCommand=compileonly,IllegalAccessInCatch*::test + * -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyStack * -XX:TieredStopAtLevel=3 * TestAccessErrorInCatch */