RFR: 8349374: [JVMCI] concurrent use of HotSpotSpeculationLog can crash

Tom Rodriguez never at openjdk.org
Tue Feb 4 17:41:14 UTC 2025


On Tue, 4 Feb 2025 16:54:58 GMT, Doug Simon <dnsimon at openjdk.org> wrote:

>> This ensures that collectFailedSpeculations sees the initialization of the recently allocated failedSpeculationsAddress memory.
>
> src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java line 179:
> 
>> 177:         }
>> 178: 
>> 179:         if (UnsafeAccess.UNSAFE.getLong(getFailedSpeculationsAddress()) != 0) {
> 
> It's still possible for `getFailedSpeculationsAddress()` to return 0 (i.e. when `managesFailedSpeculations` is `false`). So I think this should be:
> 
> diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java
> index fd46e281c3b..a861c00d77d 100644
> --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java
> +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java
> @@ -171,8 +171,9 @@ public String toString() {
> 
>      @Override
>      public void collectFailedSpeculations() {
> -        if (failedSpeculationsAddress != 0 && UnsafeAccess.UNSAFE.getLong(failedSpeculationsAddress) != 0) {
> -            failedSpeculations = compilerToVM().getFailedSpeculations(failedSpeculationsAddress, failedSpeculations);
> +        long address = getFailedSpeculationsAddress();
> +        if (address != 0 && UnsafeAccess.UNSAFE.getLong(address) != 0) {
> +            failedSpeculations = compilerToVM().getFailedSpeculations(address, failedSpeculations);
>              assert failedSpeculations.getClass() == byte[][].class;
>          }
>      }

I'm filtering out 0 above this line and `getFailedSpeculationsAddress()` can't return 0 if `failedSpeculationsAddress` is already non-zero.

`failedSpeculationsAddress` also can't be 0 if `managesFailedSpeculations` is false since we throw `IllegalArgumentException` in that case.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23444#discussion_r1941612206


More information about the hotspot-compiler-dev mailing list