Commit d300ad95 authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

Fixed forking under linux in IcedTea6

parent 13bfb9db
diff -uNr icedtea6-1.13.13/Makefile.am icedtea6-1.13.13-freetypecheck_fix/Makefile.am
diff -uNr icedtea6-1.13.13/Makefile.am icedtea6-1.13.13-fixed/Makefile.am
--- icedtea6-1.13.13/Makefile.am 2017-01-05 06:52:49.112782727 +1030
+++ icedtea6-1.13.13-freetypecheck_fix/Makefile.am 2020-01-04 13:39:56.308372789 +1030
+++ icedtea6-1.13.13-fixed/Makefile.am 2020-06-15 10:11:57.746344995 +0930
@@ -345,6 +345,7 @@
patches/nomotif-6706121.patch \
patches/nomotif.patch \
......@@ -9,9 +9,19 @@ diff -uNr icedtea6-1.13.13/Makefile.am icedtea6-1.13.13-freetypecheck_fix/Makefi
patches/alt-jar.patch \
patches/jdk-use-ssize_t.patch \
patches/arch.patch \
diff -uNr icedtea6-1.13.13/Makefile.in icedtea6-1.13.13-freetypecheck_fix/Makefile.in
@@ -621,7 +622,8 @@
patches/openjdk/6260348-pr3068.patch \
patches/openjdk/6961123-pr2975.patch \
patches/pr2800-missing_resources.patch \
- patches/pr3213-conditional_arm32jit.patch
+ patches/pr3213-conditional_arm32jit.patch \
+ patches/linux_fork_fix.patch
if WITH_RHINO
ICEDTEA_PATCHES += \
diff -uNr icedtea6-1.13.13/Makefile.in icedtea6-1.13.13-fixed/Makefile.in
--- icedtea6-1.13.13/Makefile.in 2017-01-05 06:53:00.576597287 +1030
+++ icedtea6-1.13.13-freetypecheck_fix/Makefile.in 2020-01-04 13:40:16.013407821 +1030
+++ icedtea6-1.13.13-fixed/Makefile.in 2020-06-15 10:12:40.606483604 +0930
@@ -793,6 +793,7 @@
patches/gcc-suffix.patch patches/libraries-splashscreen.patch \
patches/uname.patch patches/nomotif-6706121.patch \
......@@ -20,9 +30,19 @@ diff -uNr icedtea6-1.13.13/Makefile.in icedtea6-1.13.13-freetypecheck_fix/Makefi
patches/alt-jar.patch patches/jdk-use-ssize_t.patch \
patches/arch.patch patches/lc_ctype.patch patches/xjc.patch \
patches/linker-libs-order.patch patches/testenv.patch \
diff -uNr icedtea6-1.13.13/patches/freetypecheck_fix.patch icedtea6-1.13.13-freetypecheck_fix/patches/freetypecheck_fix.patch
@@ -1049,7 +1050,8 @@
patches/openjdk/6260348-pr3068.patch \
patches/openjdk/6961123-pr2975.patch \
patches/pr2800-missing_resources.patch \
- patches/pr3213-conditional_arm32jit.patch $(am__append_21) \
+ patches/pr3213-conditional_arm32jit.patch \
+ patches/linux_fork_fix.patch $(am__append_21) \
$(am__append_22) $(am__append_23) $(am__append_24) \
$(am__append_25) $(am__append_26) $(am__append_27) \
$(am__append_28) $(am__append_29) $(am__append_30) \
diff -uNr icedtea6-1.13.13/patches/freetypecheck_fix.patch icedtea6-1.13.13-fixed/patches/freetypecheck_fix.patch
--- icedtea6-1.13.13/patches/freetypecheck_fix.patch 1970-01-01 09:30:00.000000000 +0930
+++ icedtea6-1.13.13-freetypecheck_fix/patches/freetypecheck_fix.patch 2020-01-04 12:49:36.800022175 +1030
+++ icedtea6-1.13.13-fixed/patches/freetypecheck_fix.patch 2020-06-15 10:09:28.347861864 +0930
@@ -0,0 +1,34 @@
+diff -uNr openjdk/jdk/make/common/shared/Sanity.gmk openjdk.fixed/jdk/make/common/shared/Sanity.gmk
+--- openjdk/jdk/make/common/shared/Sanity.gmk 2016-12-30 15:00:21.000000000 +1030
......@@ -58,3 +78,57 @@ diff -uNr icedtea6-1.13.13/patches/freetypecheck_fix.patch icedtea6-1.13.13-free
+
+ ######################################################
+ # CUPS_HEADERS_PATH must be valid
diff -uNr icedtea6-1.13.13/patches/linux_fork_fix.patch icedtea6-1.13.13-fixed/patches/linux_fork_fix.patch
--- icedtea6-1.13.13/patches/linux_fork_fix.patch 1970-01-01 09:30:00.000000000 +0930
+++ icedtea6-1.13.13-fixed/patches/linux_fork_fix.patch 2020-06-15 09:59:58.773019937 +0930
@@ -0,0 +1,50 @@
+diff -uNr openjdk/hotspot/src/os/linux/vm/os_linux.cpp openjdk-linux_fork_fix/hotspot/src/os/linux/vm/os_linux.cpp
+--- openjdk/hotspot/src/os/linux/vm/os_linux.cpp 2016-12-30 15:01:06.000000000 +1030
++++ openjdk-linux_fork_fix/hotspot/src/os/linux/vm/os_linux.cpp 2020-06-15 09:58:59.674828819 +0930
+@@ -5334,14 +5334,6 @@
+
+ extern char** environ;
+
+-#ifndef __NR_fork
+-#define __NR_fork IA32_ONLY(2) IA64_ONLY(not defined) AMD64_ONLY(57)
+-#endif
+-
+-#ifndef __NR_execve
+-#define __NR_execve IA32_ONLY(11) IA64_ONLY(1033) AMD64_ONLY(59)
+-#endif
+-
+ // Run the specified command in a separate process. Return its exit value,
+ // or -1 on failure (e.g. can't fork a new process).
+ // Unlike system(), this function can be called from signal handler. It
+@@ -5349,13 +5341,7 @@
+ int os::fork_and_exec(char* cmd) {
+ const char * argv[4] = {"sh", "-c", cmd, NULL};
+
+- // fork() in LinuxThreads/NPTL is not async-safe. It needs to run
+- // pthread_atfork handlers and reset pthread library. All we need is a
+- // separate process to execve. Make a direct syscall to fork process.
+- // On IA64 there's no fork syscall, we have to use fork() and hope for
+- // the best...
+- pid_t pid = NOT_IA64(syscall(__NR_fork);)
+- IA64_ONLY(fork();)
++ pid_t pid = fork();
+
+ if (pid < 0) {
+ // fork failed
+@@ -5364,15 +5350,7 @@
+ } else if (pid == 0) {
+ // child process
+
+- // execve() in LinuxThreads will call pthread_kill_other_threads_np()
+- // first to kill every thread on the thread list. Because this list is
+- // not reset by fork() (see notes above), execve() will instead kill
+- // every thread in the parent process. We know this is the only thread
+- // in the new process, so make a system call directly.
+- // IA64 should use normal execve() from glibc to match the glibc fork()
+- // above.
+- NOT_IA64(syscall(__NR_execve, "/bin/sh", argv, environ);)
+- IA64_ONLY(execve("/bin/sh", (char* const*)argv, environ);)
++ execve("/bin/sh", (char* const*)argv, environ);
+
+ // execve failed
+ _exit(-1);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment