JDK-8319883 : Zero: Use atomic built-ins for 64-bit accesses
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17,21,22
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-11-10
  • Updated: 2024-01-08
  • Resolved: 2023-11-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21 JDK 22
21.0.3Fixed 22 b24Fixed
Related Reports
Blocks :  
Relates :  
Description
There is a bug in current Zero on 32-bit platforms around 64-bit accesses. Access to `volatile long` goes all the way down to `Atomic::PlatformLoad<8>` / `Atomic::PlatformStore<8>` -> `Atomic::atomic_copy64`, which is implemented only for few architectures, and falls back to non-atomic read-write sequence:
 https://github.com/openjdk/jdk/blob/9cce9fe06780aa095b3aabdfa421f376ca7bfd08/src/hotspot/os_cpu/linux_zero/atomic_linux_zero.hpp#L174

This is easily reproducible with Linux Zero x86_32 and jcstress like:

```
$ build/linux-x86-zero-release/images/jdk/bin/java -jar jcstress-tests-all-20230612.jar -t accessAtomic.fields.volatiles.LongTest -tb 1m

...... [FAILED] o.o.j.t.accessAtomic.fields.volatiles.LongTest

  Results across all configurations:

       RESULT      SAMPLES     FREQ      EXPECT  DESCRIPTION
           -1   39,131,094   15.14%  Acceptable  The value set by the actor thread. Observer sees the comp...
  -4294967296           88   <0.01%   Forbidden  Other values are forbidden: atomicity violation.
            0  219,340,811   84.86%  Acceptable  Default value for the field. Allowed to see this: data race.
```

Nominally, one would do the addition for x86_32 that uses FPU for atomic load/stores. But the same file already uses the atomic built-ins for other atomic needs, so we can just rewrite 64-bit atomic accesses using built-ins. This would give us compatibility across all platforms at once.

It currently blocks testing for JDK-8319777.
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/127 Date: 2024-01-04 11:08:23 +0000
05-01-2024

[jdk21u-fix-request] Approval Request from Aleksey Shipilëv Clean backport to fix 32-bit Zero concurrency bug. Applies cleanly. Tests pass.
05-01-2024

This change makes GCC 13.2.0 generate a/the stringop-overflow warning for linux-x64-zero (fastdebug) as well. Previously only spotted with linux-aarch64 (fastdebug), and for that specific combination the warning was disabled in JDK-8319818. Filed JDK-8320212.
15-11-2023

Changeset: 25f9af99 Author: Aleksey Shipilev <shade@openjdk.org> Date: 2023-11-14 12:52:49 +0000 URL: https://git.openjdk.org/jdk/commit/25f9af99be1c906fc85b8192df8fa50cced3474f
14-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16600 Date: 2023-11-10 10:24:28 +0000
10-11-2023