8000 Honor requested critical-array release mode by RicheyWorks · Pull Request #4 · jcuda/jcuda-common · GitHub
[go: up one dir, main page]

Skip to content

Honor requested critical-array release mode - #4

Draft
RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/critical-array-release-mode
Draft

RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/critical-array-release-mode

Conversation

@RicheyWorks
@RicheyWorks RicheyWorks commented Nov 4, 2026 •
Copy link
Copy Markdown

ArrayBufferPointerData.releasePointer forces JNI_ABORT whenever GetPrimitiveArrayCritical reports isCopy == false, overriding callers that request copy-back with mode 0. Under HotSpot's -Xcheck:jni, the checker wraps even a pinned array in guarded storage without changing that underlying isCopy result. Forcing JNI_ABORT discards native output from the diagnostic buffer.

Always pass the caller's requested release mode to ReleasePrimitiveArrayCritical. This retains JNI_ABORT for read-only input call sites while allowing native writes to be copied back where mode 0 was requested. It does not change JNI signatures or broaden array lifetime.

Evidence:

Companion regression PR: jcuda/jcuda#53

  • Added a companion core-JCuda regression matrix: positioned heap/direct slices for byte, short, int, long, float and double, transferred host→device→heap. Each case allocates at most 24 device bytes, uses a private thread/context, and frees resources in finally; no kernels or resets.
  • With the published 12.6.0 driver DLL, all 12 cases pass normally but all 12 return zero-filled output and fail with -Xcheck:jni.
  • Rebuilt the complete JCudaDriver DLL against this shared utility change. All 12 pass with -Xcheck:jni; JVM logging confirms the newly built DLL path.
  • Windows x86_64, RTX4090, driver617.42, Temurin22, Maven/JUnit4.13.1. Native build uses existing MSVC19.44/CMake and checksum-verified CUDA12.6 headers/import library in the workspace. Java compilation uses the disclosed isolated parent source/target8 adaptation; no build configuration change is part of this patch.
  • This validates the driver transfer paths only; other libraries that embed the shared utility were not rebuilt/tested. No claim of a full CUDA suite or Linux/JDK8 verification.

Primary implementation reference: HotSpot's checked_jni_GetPrimitiveArrayCritical wraps the acquired array with check_jni_wrap_copy_array; release honors the supplied mode: https://github.com/openjdk/jdk22u/blob/master/src/hotspot/share/prims/jniCheck.cpp#L1712-L1740

JNI release-mode contract: https://docs.oracle.com/en/java/javase/22/docs/specs/jni/functions.html#releaseprimitivetypearrayelements

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.

1 participant

0