[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3b34b85cc88: Fix crashes runninging android-emacs with bad LD_LIB
From: |
Po Lu |
Subject: |
master 3b34b85cc88: Fix crashes runninging android-emacs with bad LD_LIBRARY_PATH |
Date: |
Wed, 9 Aug 2023 02:23:45 -0400 (EDT) |
branch: master
commit 3b34b85cc88667a7d1f13e6c82cf478a5009fb3f
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Fix crashes runninging android-emacs with bad LD_LIBRARY_PATH
* doc/emacs/input.texi (Touchscreens, On-Screen Keyboards): Fix
section titles.
* src/android-emacs.c (main): If EMACS_LD_LIBRARY_PATH is set,
make it LD_LIBRARY_PATH.
* src/android.c (JNICALL): Set LD_LIBRARY_PATH as well as
EMACS_LD_LIBRARY_PATH.
---
doc/emacs/input.texi | 4 ++--
src/android-emacs.c | 25 +++++++++++++++++--------
src/android.c | 6 ++++++
3 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/doc/emacs/input.texi b/doc/emacs/input.texi
index 671901fea88..4f49ca3cece 100644
--- a/doc/emacs/input.texi
+++ b/doc/emacs/input.texi
@@ -20,7 +20,7 @@ which is detailed here.
@end menu
@node Touchscreens
-@section Using Emacs on touchscreens
+@section Using Emacs on Touchscreens
@cindex touchscreen input
Touchscreen input works by pressing and moving tools (which include
@@ -97,7 +97,7 @@ this can be changed by customizing the variable
@code{touch-screen-delay}.
@node On-Screen Keyboards
-@section Using Emacs with virtual keyboards
+@section Using Emacs with Virtual Keyboards
@cindex virtual keyboards
@cindex on-screen keyboards
diff --git a/src/android-emacs.c b/src/android-emacs.c
index e64caf9a9d4..2c405795860 100644
--- a/src/android-emacs.c
+++ b/src/android-emacs.c
@@ -37,7 +37,7 @@ main (int argc, char **argv)
{
char **args;
int i;
- char *bootclasspath, *emacs_class_path;
+ char *bootclasspath, *emacs_class_path, *ld_library_path;
/* Allocate enough to hold the arguments to app_process. */
args = alloca ((10 + argc) * sizeof *args);
@@ -46,11 +46,11 @@ main (int argc, char **argv)
memset (args, 0, (10 + argc) * sizeof *args);
/* First, figure out what program to start. */
-#if defined __x86_64__ || defined __aarch64__
+#if defined __x86_64__ || defined __aarch64__ || defined __mips64
args[0] = (char *) "/system/bin/app_process64";
-#else
+#else /* i386 || regular mips || arm */
args[0] = (char *) "/system/bin/app_process";
-#endif
+#endif /* __x86_64__ || __aarch64__ || __mips64 */
/* Machines with ART require the boot classpath to be manually
specified. Machines with Dalvik however refuse to do so, as they
@@ -72,13 +72,13 @@ main (int argc, char **argv)
bootclasspath = NULL;
goto skip_setup;
}
-#else
+#else /* !HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL */
if (__ANDROID_API__ < 21)
{
bootclasspath = NULL;
goto skip_setup;
}
-#endif
+#endif /* HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL */
/* Next, obtain the boot class path. */
bootclasspath = getenv ("BOOTCLASSPATH");
@@ -106,6 +106,15 @@ main (int argc, char **argv)
return 1;
}
+ /* Restore LD_LIBRARY_PATH to its original value, the app library
+ directory, to guarantee that it is possible for Java to find the
+ Emacs C code later. */
+
+ ld_library_path = getenv ("EMACS_LD_LIBRARY_PATH");
+
+ if (ld_library_path)
+ setenv ("LD_LIBRARY_PATH", ld_library_path, 1);
+
if (bootclasspath)
{
if (asprintf (&bootclasspath, "-Djava.class.path=%s:%s",
@@ -146,7 +155,7 @@ main (int argc, char **argv)
}
else
{
-#endif
+#endif /* HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL */
args[3] = (char *) "org.gnu.emacs.EmacsNoninteractive";
/* Arguments from here on are passed to main in
@@ -158,7 +167,7 @@ main (int argc, char **argv)
args[4 + i] = argv[i];
#if HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL
}
-#endif
+#endif /* HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL */
/* Finally, try to start the app_process. */
execvp (args[0], args);
diff --git a/src/android.c b/src/android.c
index 705ef227df3..b5b4359dcd3 100644
--- a/src/android.c
+++ b/src/android.c
@@ -1424,6 +1424,12 @@ NATIVE_NAME (setEmacsParams) (JNIEnv *env, jobject
object,
/* Set LD_LIBRARY_PATH to an appropriate value. */
setenv ("LD_LIBRARY_PATH", android_lib_dir, 1);
+ /* EMACS_LD_LIBRARY_PATH records the location of the app library
+ directory. android-emacs refers to this, since users have valid
+ reasons for changing LD_LIBRARY_PATH to a value that precludes
+ the possibility of Java locating libemacs later. */
+ setenv ("EMACS_LD_LIBRARY_PATH", android_lib_dir, 1);
+
/* Make a reference to the Emacs service. */
if (emacs_service_object)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 3b34b85cc88: Fix crashes runninging android-emacs with bad LD_LIBRARY_PATH,
Po Lu <=