Wrong ffi_type for unsigned numbers causes bugs on some platforms
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Domaine
- devtools, mobile-dev
Piste de recherche
Commencez par l’exemple minimal reproductible lié dans le rapport, en vous concentrant sur IntegerType de JNA et sur l’argument UINT16 passé à la fonction native hello. Reproduisez la différence entre les builds Android optimisés et non optimisés, puis suivez la représentation FFI de unsigned short ; le travail est terminé lorsque hello renvoie true avec la valeur attendue sur les architectures concernées.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- Java
- Étoiles
- 8.9k
- Forks
- 1.7k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de java-native-access/jna
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
java-native-access/jna#1740 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 66/100
java-native-access/jna#1738 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
java-native-access/jna#1736 ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 65/100
java-native-access/jna#1717 ·
-
Windows32Exception - The parameter is incorrectPeut-être à nouveau libre @marktech0813 l’a pris il y a 331 jours, et aucune pull request n’est ouverte. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
java-native-access/jna#1700 · 11 commentaires ·
Toutes les issues de java-native-access/jna
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
NationalSecurityAgency/ghidra#9748 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
spring-mcp-tools
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
explyt/spring-plugin#591 ·
Les mainteneurs répondent en général sous 1 jour
-
waiting-for-triage
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
spring-cloud/spring-cloud-openfeign#1443 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 1-3 heures Accessibilité débutants 84/100
ADORSYS-GIS/keycloak-oid4vp-plugin#221 ·
Les mainteneurs répondent en général sous 2 jours