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

Emanuel Peter epeter at openjdk.org
Wed Jan 21 09:17:41 UTC 2026


On Sat, 17 Jan 2026 13:31:43 GMT, Guanqiang Han <ghan at openjdk.org> wrote:

>> Please review this change. Thanks!
>> 
>> Description:
>> 
>> This change fixes a crash in Deoptimization::uncommon_trap_inner when running with -XX:+TraceDeoptimization -XX:-ProfileTraps -XX:-TieredCompilation -Xcomp.
>> 
>> With -XX:-ProfileTraps, create_if_missing is set to false.
>> https://github.com/openjdk/jdk/blob/74faf033127ab3a5e28be75b91e662c589f81084/src/hotspot/share/runtime/deoptimization.cpp#L2121-L2122
>> 
>> When create_if_missing is false, new mdo can not be created when m()->method_data() return null, so get_method_data() may return null .
>> https://github.com/openjdk/jdk/blob/74faf033127ab3a5e28be75b91e662c589f81084/src/hotspot/share/runtime/deoptimization.cpp#L1911-L1912
>> 
>> and trap_mdo can be null as a result
>> https://github.com/openjdk/jdk/blob/74faf033127ab3a5e28be75b91e662c589f81084/src/hotspot/share/runtime/deoptimization.cpp#L2134-L2136
>> 
>> The crash happens here because trap_mdo is null
>> https://github.com/openjdk/jdk/blob/74faf033127ab3a5e28be75b91e662c589f81084/src/hotspot/share/runtime/deoptimization.cpp#L2157
>> 
>> Fix:
>> 
>> The fix makes acquisition of extra_data_lock conditional on trap_mdo being non-null, preserving the required lock ordering (extra_data_lock before ttyLocker) when an MDO exists.
>> 
>> Test:
>> 
>> GHA
>
> Guanqiang Han has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
> 
>  - revert
>  - Merge remote-tracking branch 'upstream/master' into 8374807
>  - narrow lock scope
>  - Merge remote-tracking branch 'upstream/master' into 8374807
>  - split long line
>  - Merge remote-tracking branch 'upstream/master' into 8374807
>  - fix 8374807

@hgqxjj Thanks for working on this!

We generally require 2 reviews for hotspot changes, unless both the author and single reviewer say it is "trivial". This here is not trivial, I think ;)

I have some comments in the test, otherwise the fix looks reasonable.

test/hotspot/jtreg/compiler/uncommontrap/TestPrintDiagnosticsWithoutProfileTraps.java line 32:

> 30:  * @run main/othervm -XX:+TraceDeoptimization -XX:-ProfileTraps
> 31:  *                   -XX:-TieredCompilation -Xcomp
> 32:  *                   compiler.uncommontrap.TestPrintDiagnosticsWithoutProfileTraps

`TraceDeoptimization` is a diagnostic flag. This test will cause issues without `-XX:+UnlockDiagnosticVMOptions`, right? And `ProfileTraps` is debug. So won't this need `-XX:+IgnoreUnrecognizedVMOptions`?

@iwanowww Did you already run testing on this patch or should I run some?

-------------

Changes requested by epeter (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29147#pullrequestreview-3686113323
PR Review Comment: https://git.openjdk.org/jdk/pull/29147#discussion_r2711636953


More information about the hotspot-compiler-dev mailing list