-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Loading jnidispatch on Android 15 with 16 KB page size leads to crash #1618
Comments
Yes, this one is critical. Would be great if you could fix it in the upcoming release |
Looks like there are page size assumptions in the native code that are used when compiling: jna/native/libffi/src/dlmalloc.c Lines 1215 to 1258 in c9e3895
I assume the native library version with the distribution was likely compiled on a smaller page size. Can you compile the native library on the system with the higher page size and does it resolve the problem? |
Based on Googles recommendations the code should be updated; Check for code instances that reference specific page sizes
|
@pgarba could you please test if this helps: matthias@enterprise:~/src/jnalib$ git diff
diff --git a/native/Makefile b/native/Makefile
index 9bafc4c032..3dafe4bdb1 100644
--- a/native/Makefile
+++ b/native/Makefile
@@ -175,7 +175,7 @@ CPP=$(PREFIX)cpp
LD=$(CC)
RANLIB=$(PREFIX)ranlib
STRIP=$(PREFIX)strip -x
-CDEFINES=-DFFI_STATIC_BUILD -DNO_JAWT -DNO_WEAK_GLOBALS -DFFI_MMAP_EXEC_WRIT=1 -DFFI_MMAP_EXEC_SELINUX=0
+CDEFINES=-DFFI_STATIC_BUILD -DNO_JAWT -DNO_WEAK_GLOBALS -DFFI_MMAP_EXEC_WRIT=1 -DFFI_MMAP_EXEC_SELINUX=0 -Dmalloc_getpagesize='getpagesize()'
COPT+=-fpic -ffunction-sections -funwind-tables -fno-short-enums
JAVA_INCLUDES=
CINCLUDES+=-I"$(NDK_PLATFORM)/arch-$(AARCH)/usr/include" # -I/usr/include
matthias@enterprise:~/src/jnalib$ The idea follows @dbwiddis observation where the hardcoded pagesize is used. |
Hi, I'm facing the same problem and tried to fix JNA by making the changes suggested by @matthiasblaesing, but unfortunately, it didn’t help. After making the changes, I built Could it be that I built the library incorrectly? I followed the Build Environment wiki and created artifacts by simply invoking |
5.14.0@aar
ART, Android 15
System.getProperty("java.vm.version") = "2.1.0"
Android 15 with 16 KB page size
arm64-v8a
Loading jnidispatch using
System.loadLibrary("jnidispatch")
is OK on Android 15 or less with 4 KB page size, but is not OK (leads to SIGSEGV crash) on Android 15 with 16 KB page size (support of this page size in Android 15 is described in docs).System.loadLibrary("jnidispatch")
is called on Android platform inloadNativeDispatchLibrary
function that is called in static block of JNA classNative
, so you cannot properly use, for example,Native.load
function on Android 15 with 16 KB page size.To test this behaviour, corresponding Android Studio emulators were used. Info about emulator:
Emulator version: 35.1.13-11943732 (HVF 14.5.0)
Host machine: macOS 14.5
Api level: 35
Type: Google APIs PlayStore Page Size 16 KB
You can find minimal sample here. Launching this app on Android 15, 16-KB-based emulator will lead to SIGSEGV crash, full log with dump.
The text was updated successfully, but these errors were encountered: