-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert struct-padding workaround once upstream bug is fixed in JNA #334
Comments
The current version of JNA appears to have a bug when passing small structs as arguments by value, on arm64 platforms, when the function call has too many arguments to pass the struct in registers. It turnsout that our generated code does this a lot thanks to the way we pass around `RustBuffer` structs. This commit adds a temporary workaround for the issue, by padding our structs to be larger than 16 bytes, which causes them to be passed as pointers rather than by value. See mozilla/application-services#3646 for investigation of the JNA issue, and #334 to track the work of removing this workaround once a fix is released in upstream JNA.
The current version of JNA appears to have a bug when passing small structs as arguments by value, on arm64 platforms, when the function call has too many arguments to pass the struct in registers. It turns out that our generated code does this a lot thanks to the way we pass around `RustBuffer` structs. This commit adds a temporary workaround for the issue, by padding our structs to be larger than 16 bytes, which causes them to be passed as pointers rather than by value. See mozilla/application-services#3646 for investigation of the JNA issue, and #334 to track the work of removing this workaround once a fix is released in upstream JNA.
The latest release of JNA (5.8) has an updated version of |
I believe this bug is now actionable, and could make a good first issue. Basically, we need to:
We'll also have to keep a careful eye out for any increase in crashes on Android once the new version rolls out to consumers. |
I will take a shot at this. |
sounds good - especially getting your head around the docker image and tests will be valuable as well |
This (partially) reverts commit 937f9b7 The upstream JNA bug[1] has been resolved. JNA 5.7 includes the fix. We're upgrading our Docker test image to 5.8 already. Fixes mozilla#334 [1]: java-native-access/jna#1259
This (partially) reverts commit 937f9b7 The upstream JNA bug[1] has been resolved. JNA 5.7 includes the fix. We're upgrading our Docker test image to 5.8 already. Fixes mozilla#334 [1]: java-native-access/jna#1259
This (partially) reverts commit 937f9b7 The upstream JNA bug[1] has been resolved. JNA 5.7 includes the fix. We're upgrading our Docker test image to 5.8 already. Fixes mozilla#334 [1]: java-native-access/jna#1259
This (partially) reverts commit 937f9b7 The upstream JNA bug[1] has been resolved. JNA 5.7 includes the fix. We're upgrading our Docker test image to 5.8 already. Fixes #334 [1]: java-native-access/jna#1259
The code generated by uniffi makes heavy use of passing structs by value, and this seems to have uncovered an argument-passing bug in JNA. We landed a workaround for this bug in #335 but it works by artificially padding our structs, so it seems likely to have some runtime performance costs.
(Briefly: it pads our structs to be more than 16 bytes in size, so that they will always be passed as a pointer, which works around the bug).
Once the underlying issue has been resolved in a JNA release, we should revert the above workaround.
┆Issue is synchronized with this Jira Task
┆Issue Number: UNIFFI-33
The text was updated successfully, but these errors were encountered: