8374807: Crash in MethodData::extra_data_lock()+0x0 when running -XX:+TraceDeoptimization -XX:-ProfileTraps -XX:-TieredCompilation -Xcomp -version

Reviewed-by: vlivanov, epeter
This commit is contained in:
Guanqiang Han 2026-02-25 13:13:51 +00:00 committed by Emanuel Peter
parent 93fe49abef
commit 194be8180f
2 changed files with 62 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2026, 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
@ -2155,7 +2155,9 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr
// Lock to read ProfileData, and ensure lock is not broken by a safepoint
// We must do this already now, since we cannot acquire this lock while
// holding the tty lock (lock ordering by rank).
MutexLocker ml(trap_mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag);
ConditionalMutexLocker ml((trap_mdo != nullptr) ? trap_mdo->extra_data_lock() : nullptr,
(trap_mdo != nullptr),
Mutex::_no_safepoint_check_flag);
ttyLocker ttyl;

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2026, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8374807
* @summary Regression test for -XX:+TraceDeoptimization -XX:-ProfileTraps
* -XX:-TieredCompilation -Xcomp crash
* @modules java.base/jdk.internal.misc
* @requires vm.debug
* @run main/othervm -XX:+TraceDeoptimization -XX:-ProfileTraps
* -XX:-TieredCompilation -Xcomp -Xbatch
* -XX:CompileCommand=compileonly,compiler.uncommontrap.TestPrintDiagnosticsWithoutProfileTraps::test
* compiler.uncommontrap.TestPrintDiagnosticsWithoutProfileTraps
*/
package compiler.uncommontrap;
import jdk.internal.misc.Unsafe;
public class TestPrintDiagnosticsWithoutProfileTraps {
static final Unsafe UNSAFE=Unsafe.getUnsafe();
static volatile long sink;
static class TestSubClass {
int f;
}
static void test(){
// Trigger a deopt/uncommon-trap path while resolving the field offset.
sink = UNSAFE.objectFieldOffset(TestSubClass.class,"f");
}
public static void main(String[] args) {
test();
System.out.println("passed");
}
}