aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2020-08-17 16:43:50 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2020-08-18 07:19:22 +0000
commitf10a27abc4a038853c5b0f74655a1ca75356c93a (patch)
treeb3af3ea33834609cc1e398ca508132d664533731
parent7533f727ac9ccff749781a30bbb431da1c480484 (diff)
downloadaports-f10a27abc4a038853c5b0f74655a1ca75356c93a.tar.gz
aports-f10a27abc4a038853c5b0f74655a1ca75356c93a.tar.bz2
aports-f10a27abc4a038853c5b0f74655a1ca75356c93a.tar.xz
community/openjdk8: fix deadlock
avoid malloc after fork fixes #11861
-rw-r--r--community/openjdk8/APKBUILD4
-rw-r--r--community/openjdk8/icedtea-jdk-close-fds.patch115
2 files changed, 118 insertions, 1 deletions
diff --git a/community/openjdk8/APKBUILD b/community/openjdk8/APKBUILD
index 8ad162a502..ff1485544a 100644
--- a/community/openjdk8/APKBUILD
+++ b/community/openjdk8/APKBUILD
@@ -6,7 +6,7 @@ _icedteaver=3.16.0
# pkgver is <JDK version>.<JDK update>.<JDK build>
# Check https://icedtea.classpath.org/wiki/Main_Page when updating!
pkgver=8.252.09
-pkgrel=0
+pkgrel=1
pkgdesc="OpenJDK 8 provided by IcedTea"
url="https://icedtea.classpath.org/"
# no bootstrap JDK on mips
@@ -93,6 +93,7 @@ source="https://icedtea.classpath.org/download/source/icedtea-$_icedteaver.tar.x
icedtea-jdk-fix-libjvm-load.patch
icedtea-jdk-musl.patch
icedtea-jdk-includes.patch
+ icedtea-jdk-close-fds.patch
icedtea-autoconf-config.patch
"
builddir="$srcdir/icedtea-$_icedteaver"
@@ -367,4 +368,5 @@ f6365cfafafa008bd6c1bf0ccec01a63f8a39bd1a8bc87baa492a27234d47793ba02d455e5667a87
b135991c76b0db8fa7c363e0903624668e11eda7b54a943035c214aa4d7fc8c3e8110ed200edcec82792f3c9393150a9bd628625ddf7f3e55720ff163fbbb471 icedtea-jdk-fix-libjvm-load.patch
3b01de971f64f082d3e289cf337e635ef001381e8ca427a77baa9c52c7ba423889f57665779ca5b3c8bcefb8feacbea31dfaac580c969a4f061439069ee34aae icedtea-jdk-musl.patch
974fb54532b7e7d738f4278187fc6bd9f9b2d99866b94f68a617ee4911c89a3b8cc41ecfdcaefecf9157492d006b1844b6b0b41ac4209d84f9e8d13c9e485dd3 icedtea-jdk-includes.patch
+26d33ea5c55f89beebb0c05cc520e839439285f80d8ffca66ee9ef833ba65332dd7848de0b1a7e040d2eed494410d446729db72b09d8a23b6eea55749b8f6f54 icedtea-jdk-close-fds.patch
662d662d0a7a84be2978e921317589f212f3ba3b7629527ba0f1140b5ac4c1024893e0ed176211688ed1a4505968c4befc841ed57ffcdbb9d355c2cb0571b167 icedtea-autoconf-config.patch"
diff --git a/community/openjdk8/icedtea-jdk-close-fds.patch b/community/openjdk8/icedtea-jdk-close-fds.patch
new file mode 100644
index 0000000000..5a6d56d4ed
--- /dev/null
+++ b/community/openjdk8/icedtea-jdk-close-fds.patch
@@ -0,0 +1,115 @@
+Avoid use opendir after fork as its not async safe and may lead to deadlock
+
+https://gitlab.alpinelinux.org/alpine/aports/-/issues/11861
+
+diff --git a/openjdk/jdk/src/solaris/native/java/lang/childproc.c b/openjdk/jdk/src/solaris/native/java/lang/childproc.c
+index 1d183cf..05aa6cb 100644
+--- openjdk/jdk/src/solaris/native/java/lang/childproc.c
++++ openjdk/jdk/src/solaris/native/java/lang/childproc.c
+@@ -23,13 +23,13 @@
+ * questions.
+ */
+
+-#include <dirent.h>
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
+ #include <limits.h>
++#include <poll.h>
+
+ #include "childproc.h"
+
+@@ -56,61 +56,47 @@ closeSafely(int fd)
+ return (fd == -1) ? 0 : close(fd);
+ }
+
+-int
+-isAsciiDigit(char c)
+-{
+- return c >= '0' && c <= '9';
+-}
+-
+-#ifdef _ALLBSD_SOURCE
+-#define FD_DIR "/dev/fd"
+-#define dirent64 dirent
+-#define readdir64 readdir
+-#elif defined(_AIX)
+-/* AIX does not understand '/proc/self' - it requires the real process ID */
+-#define FD_DIR aix_fd_dir
+-#else
+-#define FD_DIR "/proc/self/fd"
+-#endif
+-
+ int
+ closeDescriptors(void)
+ {
+- DIR *dp;
+- struct dirent64 *dirp;
+ int from_fd = FAIL_FILENO + 1;
++ struct pollfd pfds[1024];
++ int i, total, nclosed = 0;
++ int max_fd = sysconf(_SC_OPEN_MAX);
+
+- /* We're trying to close all file descriptors, but opendir() might
+- * itself be implemented using a file descriptor, and we certainly
+- * don't want to close that while it's in use. We assume that if
+- * opendir() is implemented using a file descriptor, then it uses
+- * the lowest numbered file descriptor, just like open(). So we
+- * close a couple explicitly. */
++ if (max_fd < 0)
++ return 0;
+
+- close(from_fd); /* for possible use by opendir() */
+- close(from_fd + 1); /* another one for good luck */
++ /* init events */
++ total = max_fd - from_fd;
++ for (i = 0; i < (total < 1024 ? total : 1024); i++) {
++ pfds[i].events = 0;
++ }
+
+-#if defined(_AIX)
+- /* AIX does not understand '/proc/self' - it requires the real process ID */
+- char aix_fd_dir[32]; /* the pid has at most 19 digits */
+- snprintf(aix_fd_dir, 32, "/proc/%d/fd", getpid());
+-#endif
++ while (from_fd < max_fd) {
++ int nfds, r = 0;
+
+- if ((dp = opendir(FD_DIR)) == NULL)
+- return 0;
++ total = max_fd - from_fd;
++ nfds = total < 1024 ? total : 1024;
+
+- /* We use readdir64 instead of readdir to work around Solaris bug
+- * 6395699: /proc/self/fd fails to report file descriptors >= 1024 on Solaris 9
+- */
+- while ((dirp = readdir64(dp)) != NULL) {
+- int fd;
+- if (isAsciiDigit(dirp->d_name[0]) &&
+- (fd = strtol(dirp->d_name, NULL, 10)) >= from_fd + 2)
+- close(fd);
+- }
++ for (i = 0; i < nfds; i++)
++ pfds[i].fd = from_fd + i;
+
+- closedir(dp);
++ do {
++ r = poll(pfds, nfds, 0);
++ } while (r == -1 && errno == EINTR);
+
++ if (r < 0)
++ return 0;
++
++
++ for (i = 0; i < nfds; i++)
++ if (pfds[i].revents != POLLNVAL) {
++ nclosed++;
++ close(pfds[i].fd);
++ }
++ from_fd += nfds;
++ }
+ return 1;
+ }
+