Skip to content

Publish the Java binary atomically across JVMs (#329) - #353

Open
css521 wants to merge 2 commits into
VibiumDev:mainfrom
css521:fix/329-atomic-java-extract
Open

Publish the Java binary atomically across JVMs (#329)#353
css521 wants to merge 2 commits into
VibiumDev:mainfrom
css521:fix/329-atomic-java-extract

Conversation

@css521

@css521 css521 commented Aug 12, 2026

Copy link
Copy Markdown

Fixes #329.

BinaryResolver previously copied directly to the shared cache path and only set the executable bit afterwards. Parallel JVMs could therefore resolve and execute a partial or non-executable file, while an interrupted copy left a truncated cache entry that later runs trusted permanently.

This serializes extraction across JVMs with a file lock, copies to an owner-specific staging file in the cache directory, validates its length and permissions, and publishes it with an atomic rename. Cache hits are accepted only when they are regular, complete, and executable. Lock acquisition is bounded and also handles overlapping locks from independent classloaders in one JVM.

Verified locally:

  • BinaryResolverExtractionTest passes with real child JVM contention at javaParallel=4
  • The focused suite covers cold-cache contention, stale entries, interrupted extraction, fail-closed publication, and concurrent classloaders
  • ./gradlew --offline build -x test --rerun-tasks
  • git diff --check

The synthetic executable used by the regression suite is a POSIX shell payload, so that suite explicitly skips on Windows; Windows publication is not claimed as locally verified.

css521 and others added 2 commits August 12, 2026 13:43
Serialize extraction with a cross-process file lock, stage and validate the bundled binary before an atomic rename, and recover stale cache entries without exposing a partial target. Add real multi-JVM and multi-classloader regressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java client: BinaryResolver.extractFromJar() is not concurrency-safe — parallel JVMs exec a half-written binary

1 participant