Wrong ffi_type for unsigned numbers causes bugs on some platforms
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Área
- devtools, mobile-dev
Línea de trabajo
Comienza con el ejemplo mínimo reproducible enlazado en el informe, centrándote en el IntegerType de JNA y en el argumento UINT16 que se pasa a la función nativa hello. Reproduce la diferencia entre las compilaciones de Android optimizadas y no optimizadas, y luego rastrea la representación FFI de unsigned short; el trabajo estará terminado cuando hello devuelva true con el valor esperado en las arquitecturas afectadas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Java
- Estrellas
- 8.9k
- Forks
- 1.7k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de java-native-access/jna
-
Incorrect mapping of c.s.j.platform.unix.solaris.LibKstat.KstatCtlPosiblemente ocupada @dbwiddis la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
java-native-access/jna#1740 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 66/100
java-native-access/jna#1738 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
java-native-access/jna#1736 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
java-native-access/jna#1717 ·
-
Windows32Exception - The parameter is incorrectQuizá libre de nuevo @marktech0813 la tomó hace 331 días y no hay ningún pull request abierto. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
java-native-access/jna#1700 · 11 comentarios ·
Todos los issues de java-native-access/jna
Issues similares
-
backend
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
bcgov/nr-forest-client#2524 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
team:Lumberjack
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
OpenLiberty/open-liberty#35998 ·
Los mantenedores suelen responder en 1 día
-
[BUG] SQS SendMessageBatch accepts more than 10 entries instead of TooManyEntriesInBatchRequestPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
floci-io/floci#5319 · 1 comentario ·
Los mantenedores suelen responder en 1 día