Repository navigation
Fix virtual-memory allocation handle and property marshalling - #58
Draft
RicheyWorks wants to merge 1 commit into
Draft
RicheyWorks wants to merge 1 commit into
RicheyWorks wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the driver virtual-memory allocation/property workflow under JNI checking. Three related marshalling mistakes currently prevent this path from working correctly:
getCUmemAllocationPropreads the three nestedallocFlagsfields from the outer property object, causing a wrong-field-ID fatal error under-Xcheck:jni. Read them from the already obtained nested flag object and zero-initialize the native structure, including reserved bytes.cuMemCreatereturns its handle withsetPointer, which also accessesPointer.byteOffset.CUmemGenericAllocationHandleextendsNativePointerObject, notPointer; use the existing native-handle setter.setCUmemAllocationPropcreates a location object but never copies its native type/id. Populate it with the existing location helper.These are one allocation-workflow contribution, not separate counted fixes. No Java/JNI signatures change. This is independent of the access-policy-window changes in #48 and the other pending JNI fixes; no overlap was found in issue/PR searches for allocation properties.
Add three real driver regression cases, each in a fresh child JVM with
-Xcheck:jni, a 30-second timeout and captured diagnostics so a broken JNI build cannot terminate the JUnit runner. Exercise minimum/recommended granularity and allocation→property-query→release. Skip on a device explicitly reporting VMM unsupported. The allocation case verifies the location, allocation type, handle types and all three flag values; it never reserves/maps an address or launches a kernel, and caps allocation size at 16 MiB. Context and handle are released infinallyon the working path.Verification on Windows x86_64, RTX 4090/driver 617.42, Temurin JDK 22/JUnit 4.13.1:
FATAL ERROR in native method: Wrong field ID passed to JNIduring granularity queries, before allocating memory.cuMemCreate.jcuda-commoncommit9d41fb5: all three pass, zero failures/errors/skips. A direct logged run confirms the rebuilt DLL and successful 2 MiB allocation/property query/release. No JNI warnings.CUDA contract: virtual memory management.
The test itself enables JNI checking in each child process and propagates
java.library.path.