8000 Honor pointer offsets in getByteBuffer views by RicheyWorks · Pull Request #50 · jcuda/jcuda · GitHub
[go: up one dir, main page]

Skip to content

Honor pointer offsets in getByteBuffer views - #50

Draft
RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/byte-buffer-pointer-offset
Draft

RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/byte-buffer-pointer-offset

Conversation

@RicheyWorks
Copy link
Copy Markdown

Pointer.getByteBuffer ignores the pointer's stored byte offset. For example, Pointer.to(new byte[] {0, 1, 2, 3}).withByteOffset(2).getByteBuffer() returns all four bytes starting at zero, rather than the two bytes beginning at the shifted pointer. The ranged overload similarly reads from the unshifted base and may accept ranges that extend past the shifted pointer's remaining memory.

Honor the stored offset in both overloads, check range arithmetic for overflow, and document pointer-relative behavior. Keep zero-offset behavior, shared backing memory, native byte order and null results for unsupported pointers. Explicitly retain rejection of negative relative offsets and sizes.

Add 12 no-CUDA regression cases covering shifted and composed offsets, direct sliced memory, shared writes, caller buffer state, end boundaries, invalid ranges, arithmetic overflow, unsupported pointers and unchanged zero-offset behavior. Eight cases fail on unchanged upstream; all 12 pass after the fix.

Validation:

  • mvn -B -ntp -o -f JCudaJava/pom.xml -Dmaven.repo.local=<task-local-cache> -Dtest=PointerByteBufferOffsetTest test: BUILD SUCCESS, 12 tests, zero failures/errors/skips, declared JUnit 4.13.1.
  • The installed JDK 22 rejects upstream's Java 7 source/target configuration. The test uses a separate jcuda-parent POM installed into an isolated cache with Java 8 source/target, as for Preserve direct buffer marks in Pointer.toBuffer #49. No POM adjustment is included in this PR.
  • No CUDA/native calls or GPU workloads were run. GPU ingestion remains undisturbed.
  • This branch starts directly from upstream master and is independent of Preserve direct buffer marks in Pointer.toBuffer #49; the buffer-mark fix is not included.

This intentionally changes buffer views of offset pointers to match their pointer-relative meaning. Callers that relied on the previous ignored-offset behavior will see different data and buffer sizes.

@jcuda
jcuda commented Nov 4, 2026
Copy link
Copy Markdown
Owner

Great. 22 pull requests in a few hours.

To be clear: I'm not going to review these.

If someone wants me to review and integrate them, and create a new release, send me a mail. My rate per hour is about one tenth of the profit that NVIDIA makes per second. Pretty cheap, right?

@RicheyWorks
Copy link
Copy Markdown
Author

I am disabled and only make 450 bucks a month. I understand your bandwidth is low and im sure you already have plenty of money in respect to me; have a nice life

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.

2 participants

0