Wrong ffi_type for unsigned numbers causes bugs on some platforms
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- devtools, mobile-dev
Hướng nghiên cứu
Bắt đầu với ví dụ tối thiểu có thể tái hiện được được liên kết trong báo cáo, tập trung vào IntegerType của JNA và đối số UINT16 được truyền vào hàm native hello. Tái hiện sự khác biệt giữa các bản build Android được tối ưu hóa và không được tối ưu hóa, sau đó theo dõi biểu diễn FFI của unsigned short; hoàn tất khi hello trả về true với giá trị mong đợi trên các kiến trúc bị ảnh hưởng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Provide complete information about the problem
- Version of JNA and related jars
5.11.0@aar - Version and vendor of the java virtual machine
ART @ Android 11 - Operating system
Android 11 - System architecture (CPU type, bitness of the JVM)
arm64-v8a, x86_64, possibly more
Output ofclang --version:
Compiler Android (7019983 based on r365631c3) clang version 9.0.9 (https://android.googlesource.com/toolchain/llvm-project a2a1e703c0edb03ba29944e529ccbf457742737b) (based on LLVM 9.0.9svn). - Complete description of the problem
Function argument of typeunsigned shortpassed by JNA to native code does not behave correctly when the code is compiled with optimizations enabled. The is caused by the fact that LLVM is counting on the argument being stored in straight format (as it should be) instead of two's complement. - Steps to reproduce
Minimal reproducible example available here.
Thehellofunction in the following code should returntrue, but returnsfalse.
const unsigned short CONSTANT = 0x8810u;
bool hello(unsigned short argument) {
__android_log_print(ANDROID_LOG_WARN, TAG, "argument value as %%#010x=%#010x %%d=%d, as %%u=%u, as %%hu=%hu", argument, argument, argument, argument);
__android_log_print(ANDROID_LOG_WARN, TAG, "CONSTANT value as %%#010x=%#010x %%d=%d, as %%u=%u, as %%hu=%hu", CONSTANT, CONSTANT, CONSTANT, CONSTANT);
switch (argument) {
case CONSTANT:
return true;
default:
return false;
}
}
private void logValueFromJna() {
boolean on = lib.hello(new UINT16(0x8810));
Log.w("JNA-BUG", "hello returned correct value? " + on);
}
public static class UINT16 extends IntegerType {
@SuppressWarnings("unused")
public UINT16() {
this(0);
}
public UINT16(int value) {
super(2, value, true);
}
}
interface TestLibrary extends Library {
boolean hello(UINT16 argument);
}
Log output with optimizations disabled:
W/JNA-BUG-NATIVE: argument value as %#010x=0x00008810 %d=34832, as %u=34832, as %hu=34832
W/JNA-BUG-NATIVE: CONSTANT value as %#010x=0x00008810 %d=34832, as %u=34832, as %hu=34832
W/JNA-BUG: hello returned correct value? true
Log output with optimizations enabled:
W/JNA-BUG-NATIVE: argument value as %#010x=0xffff8810 %d=-30704, as %u=4294936592, as %hu=34832
W/JNA-BUG-NATIVE: CONSTANT value as %#010x=0x00008810 %d=34832, as %u=34832, as %hu=34832
W/JNA-BUG: hello returned correct value? false
- Ngôn ngữ chính
- Java
- Star
- 8.9k
- Fork
- 1.7k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của java-native-access/jna
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
java-native-access/jna#1740 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 66/100
java-native-access/jna#1738 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
java-native-access/jna#1736 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
java-native-access/jna#1717 ·
-
Windows32Exception - The parameter is incorrectCó thể làm lại được @marktech0813 đã nhận 331 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
java-native-access/jna#1700 · 11 bình luận ·
Tất cả issue của java-native-access/jna
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
waiting-for-triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
spring-cloud/spring-cloud-openfeign#1443 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
ADORSYS-GIS/keycloak-oid4vp-plugin#221 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Upgrade to Spring Pulsar 2.0.8Đang mởstatus: team-only type: dependency-upgrade
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
spring-projects/spring-boot#52099 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
tchiotludo/akhq#3307 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày