Closed Bug 1637611 Opened 6 years ago Closed 6 years ago

Application Services' `RustBuffer` does not work with JNA Union

Categories

(Data Platform and Tools :: Glean: SDK, enhancement, P2)

enhancement

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: Dexter, Unassigned)

Details

When using RustBuffer as part of a structure to be passed across the FFI boundary using JNA Structure and Union, JNA throws an exception because it is unable to compute the structure size.

This is for investigating the problem to understand if we can make it work. See the original comment.

Priority: -- → P3
Whiteboard: [telemetry:glean-rs:m?]
Priority: P3 → P2
Whiteboard: [telemetry:glean-rs:m?]

The linked comment indicates you were using RustBuffer.ByValue. I believe this is incorrect -- You should be using RustBuffer; the ByValue type is only for use inside function arguments and function return values.

That said, maybe this still doesn't work... I don't see a huge problem with the way you've done it if nested structures don't work with JNA.

(In reply to Thom Chiovoloni [:tcsc] (please ni?) from comment #1)

The linked comment indicates you were using RustBuffer.ByValue. I believe this is incorrect -- You should be using RustBuffer; the ByValue type is only for use inside function arguments and function return values.

Yup, RustBuffer (without ByValue) was the first thing we tried!

That said, maybe this still doesn't work... I don't see a huge problem with the way you've done it if nested structures don't work with JNA.

Right :-) Not a big deal, but we'd really like to re-use your stuff as much as possible ;-)

Hmm... maybe we should file a bug in JNA, then.

Indeed. I mainly wanted this bug filed so we can take another look on whether this was us misusing the JNA parts or it's a bug we can report. I'm happy to take this on.

By pure accident I stumbled upon another bug today, that led me down a path of different alignment and padding bytes.
After some adjustements (len: i64 -> len: i32) to fix our issue I was also able to bring back a RustBuffer class, see https://github.com/mozilla/glean/pull/898

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.