Skip to content

fix(core): avoid ARM64 Java 8 native atomic crashes - #120

Open
kafka1991 wants to merge 4 commits into
mainfrom
fix/local-durable-ack-publication
Open

kafka1991 wants to merge 4 commits into
mainfrom
fix/local-durable-ack-publication

Conversation

@kafka1991

@kafka1991 kafka1991 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Fix JVM crashes in native-memory accounting on Java 8 ARM64 HotSpot. Its C1 compiler can truncate a constant native address passed to Unsafe.getAndAddLong, causing SIGSEGV during allocation accounting.

  • Use a CAS fallback only on the affected Java 8 ARM64 HotSpot path, covering RSS/non-RSS accounting and malloc/free/realloc counters.
  • Keep the intrinsic directly at unaffected call sites. The Java 11+ shim disables the workaround with a compile-time constant; there are no new per-update locks or allocations.
  • Add fixed-input accounting and concurrency tests, a forced-C1 ARM64 CI step, and packaging checks that retain the modern fast path.
  • Keep the ACK change test-only: wait for a follow-up OK before asserting local progress and no trim. No production ACK locks or counter-order changes remain.

Validation

  • The new regression tests crash on the unmodified implementation and pass with the workaround under default JIT and forced C1 on Zulu 8 ARM64.
  • Temurin 8u504 Linux ARM64: full mvn -P javadoc clean install passed, including 3753 core tests, packaging tests and the Azure module.
  • JDK 25: 44 related tests and both packaging checks passed.
  • Modern-build counter methods have identical bytecode to the original direct-intrinsic implementation. Java 8 x64 and the Java 8 MRJAR on JDK 25 retain the intrinsic under forced C1; the x64 check ran under emulation and is not a native-throughput benchmark.

@kafka1991

Copy link
Copy Markdown
Contributor Author

Review report — level 3

Verdict: approve

Reviewed 03568574 against 0e3b0588.

Findings: 0 Critical, 0 Moderate, 0 Minor; no admitted in-diff or out-of-diff breakage.

Validation

  • 40 focused tests pass on JDK 25 and JDK 8 (-Xint).
  • The new regression passes on head and fails against base with expected:<0> but was:<1>.
  • No submodule pointer changes.
  • At review time, Windows CI remained in progress; completed build checks passed.

Coverage

Test gate: pass — 0 admitted coverage gaps.

No matching Enterprise tandem was found. Its absence is non-blocking here: the change concerns in-JVM progress publication, with deterministic regression and loopback coverage; wire, persistence, and trim-selection semantics remain unchanged.

@kafka1991 kafka1991 added the READY label Nov 4, 2026
Run the Java 8 build and full test suite on a native Linux ARM64
runner alongside x64, without disabling JIT compilation.

Select matching JDKs and native resource paths per architecture.
Preserve the x64 smoke-test artifact and upload JVM crash reports
and Maven test diagnostics when either test job fails.
Wait for a follow-up OK before checking the preceding local ACK
watermark and trim state. Preserve the assertions and release the
replicated ACK in finally for cleanup.

Remove the production locking and counter-publication changes,
along with the test that required the new publication contract.
The production sources now match the PR baseline.
@kafka1991 kafka1991 changed the title fix(qwp): publish local durable ack progress before counting it test(qwp): synchronize durable ACK assertions Nov 5, 2026
Use a CAS fallback for native counter updates on Java 8 ARM64
HotSpot. Keep the original intrinsic directly at unaffected call
sites, with a constant-false Java 11+ shim to avoid wrapper costs.

Cover allocation, reallocation, signed accounting adjustments and
concurrent counter updates. Check the packaged modern fast path
and run the counter regression under C1 on ARM64 CI.
@kafka1991 kafka1991 changed the title test(qwp): synchronize durable ACK assertions fix(core): avoid ARM64 Java 8 native atomic crashes Nov 5, 2026
@mtopolnik

Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 7 / 8 (87.50%)

file detail

path covered line new line coverage
🔵 io/questdb/client/std/NativeAtomicLong.java 0 1 00.00%
🔵 io/questdb/client/std/Unsafe.java 7 7 100.00%

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants