Skip to content

Fix JVM crash when accessing array-backed RecordId keys#141

Merged
emmanuel-keller merged 1 commit intomainfrom
emmanuel/fix-recordid-array-accessors
Apr 28, 2026
Merged

Fix JVM crash when accessing array-backed RecordId keys#141
emmanuel-keller merged 1 commit intomainfrom
emmanuel/fix-recordid-array-accessors

Conversation

@emmanuel-keller
Copy link
Copy Markdown
Collaborator

@emmanuel-keller emmanuel-keller commented Apr 26, 2026

Summary

Fixes #140.

This fixes a JVM crash when accessing array- or object-backed RecordId keys through RecordId.getId(). The Java native declarations for Id.getArray(...) and Id.getObject(...) expected Java objects, while the JNI implementation returns raw native pointers (jlong). The JVM could then interpret a native pointer as an object reference, causing a SIGSEGV when calling methods like len() or get(0).

Changes

  • Change Id native array/object accessors to return long native pointers.
  • Wrap those pointers as Array / Object on the Java side, matching the existing Value accessor pattern.
  • Add regression coverage for array-backed RecordId keys from query results.
  • Add direct coverage for array- and object-backed RecordId key accessors.

Testing

./gradlew test --tests com.surrealdb.ValueTypesTests.recordIdArrayKeyAccessorsFromQuery --tests com.surrealdb.TypeTests.testRecordIdWithArrayKey --tests com.surrealdb.TypeTests.testRecordIdWithObjectKey
git diff --check

@emmanuel-keller emmanuel-keller changed the title Fix RecordId array key accessors Fix JVM crash when accessing array-backed RecordId keys Apr 26, 2026
@emmanuel-keller emmanuel-keller marked this pull request as ready for review April 26, 2026 10:44
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@emmanuel-keller emmanuel-keller merged commit 599bfde into main Apr 28, 2026
48 checks passed
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.

Bug: JVM crash (SIGSEGV) when calling methods on an array-based RecordId Array

2 participants