RFR: 8179887 - Build failure with glibc >= 2.24: error: 'int readdir_r(DIR*, dirent*, dirent**)' is deprecated (original) (raw)
B. Blaser bsrbnd at gmail.com
Thu May 3 17:52:27 UTC 2018
- Previous message: RFR (JDK11/java.xml) 8201138: Defect in XMLEventReader.getElementText() may cause data to be skipped, duplicated or otherwise result in a ClassCastException
- Next message: RFR: 8179887 - Build failure with glibc >= 2.24: error: 'int readdir_r(DIR*, dirent*, dirent**)' is deprecated
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
On 2 May 2018 at 22:40, Kim Barrett <kim.barrett at oracle.com> wrote:
On May 2, 2018, at 5:10 AM, Michal Vala <mvala at redhat.com> wrote:
On 05/01/2018 07:59 PM, Kim Barrett wrote: On Apr 27, 2018, at 4:26 PM, Michal Vala <mvala at redhat.com> wrote: Someone to sponsor this please? Do you have a sponsor yet? If not, I’ll do it. No, I don't. I'd really appreciate if you sponsor it. Will do. I should be able to take care of it in the next day or so.
I've noted some similar issues at several other places which makes the JDK build fail on Linux with glibc = 2.26, see comments here: https://bugs.openjdk.java.net/browse/JDK-8202353
Here is a patch for that, does this look reasonable (tier1 seems OK)?
Thanks, Bernard
diff -r 1871c5d07caf src/java.base/unix/native/libjava/TimeZone_md.c --- a/src/java.base/unix/native/libjava/TimeZone_md.c Fri Apr 27 15:55:29 2018 -0700 +++ b/src/java.base/unix/native/libjava/TimeZone_md.c Thu May 03 17:59:31 2018 +0200 @@ -122,7 +122,9 @@ DIR *dirp = NULL; struct stat statbuf; struct dirent64 *dp = NULL; +#ifndef linux struct dirent64 *entry = NULL; +#endif char *pathname = NULL; int fd = -1; char *dbuf = NULL; @@ -140,7 +142,7 @@ if (name_max < 1024) { name_max = 1024; }
+#ifndef linux entry = (struct dirent64 *)malloc(offsetof(struct dirent64, d_name) + name_max + 1); if (entry == NULL) { (void) closedir(dirp); @@ -148,6 +150,9 @@ }
while (readdir64_r(dirp, entry, &dp) == 0 && dp != NULL) {
+#else + while ((dp = readdir64(dirp)) != NULL) { +#endif /* * Skip '.' and '..' (and possibly other .* files) */ @@ -213,10 +218,11 @@ free((void *) pathname); pathname = NULL; }
+#ifndef linux if (entry != NULL) { free((void *) entry); } +#endif if (dirp != NULL) { (void) closedir(dirp); } diff -r 1871c5d07caf src/java.base/unix/native/libjava/UnixFileSystem_md.c --- a/src/java.base/unix/native/libjava/UnixFileSystem_md.c Fri Apr 27 15:55:29 2018 -0700 +++ b/src/java.base/unix/native/libjava/UnixFileSystem_md.c Thu May 03 17:59:31 2018 +0200 @@ -312,7 +312,9 @@ { DIR *dir = NULL; struct dirent64 *ptr; +#ifndef linux struct dirent64 *result; +#endif int len, maxlen; jobjectArray rv, old; jclass str_class; @@ -324,14 +326,14 @@ dir = opendir(path); } END_PLATFORM_STRING(env, path); if (dir == NULL) return NULL;
+#ifndef linux ptr = malloc(sizeof(struct dirent64) + (PATH_MAX + 1)); if (ptr == NULL) { JNU_ThrowOutOfMemoryError(env, "heap allocation failed"); closedir(dir); return NULL; }
+#endif /* Allocate an initial String array */ len = 0; maxlen = 16; @@ -339,7 +341,11 @@ if (rv == NULL) goto error;
/* Scan the directory */
+#ifndef linux while ((readdir64_r(dir, ptr, &result) == 0) && (result != NULL)) { +#else
- while ((ptr = readdir64(dir)) != NULL) {
+#endif jstring name; if (!strcmp(ptr->d_name, ".") || !strcmp(ptr->d_name, "..")) continue; @@ -360,7 +366,9 @@ (*env)->DeleteLocalRef(env, name); } closedir(dir); +#ifndef linux free(ptr); +#endif
/* Copy the final results into an appropriately-sized array */
old = rv;
@@ -375,7 +383,9 @@
error: closedir(dir); +#ifndef linux free(ptr); +#endif return NULL; }
diff -r 1871c5d07caf src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c --- a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c Fri Apr 27 15:55:29 2018 -0700 +++ b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c Thu May 03 17:59:31 2018 +0200 @@ -726,12 +726,18 @@ char name_extra[PATH_MAX + 1 - sizeof result->d_name]; } entry; struct dirent64* ptr = &entry.buf; +#ifndef linux int res; +#endif DIR* dirp = jlong_to_ptr(value);
/* EINTR not listed as a possible error */
/* TDB: reentrant version probably not required here */
+#ifndef linux res = readdir64_r(dirp, ptr, &result); +#else
- ptr = result = readdir64(dirp);
+#endif
#ifdef _AIX /* On AIX, readdir_r() returns EBADF (i.e. '9') and sets 'result' to NULL for the */ @@ -741,10 +747,12 @@ } #endif
+#ifndef linux if (res != 0) { throwUnixException(env, res); return NULL; } else { +#endif if (result == NULL) { return NULL; } else { @@ -755,7 +763,9 @@ } return bytes; } +#ifndef linux } +#endif }
JNIEXPORT void JNICALL diff -r 1871c5d07caf src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c --- a/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c Fri Apr 27 15:55:29 2018 -0700 +++ b/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c Thu May 03 17:59:31 2018 +0200 @@ -75,10 +75,10 @@ #endif /* _ALLBSD_SOURCE */
static struct dirent* read_dir(DIR* dirp, struct dirent* entry) { -#ifdef solaris +#if defined(solaris) || defined(linux) struct dirent* dbuf = readdir(dirp); return dbuf; -#else /* linux || _ALLBSD_SOURCE / +#else / _ALLBSD_SOURCE / struct dirent p; if (readdir_r(dirp, entry, &p) == 0) { return p;
- Previous message: RFR (JDK11/java.xml) 8201138: Defect in XMLEventReader.getElementText() may cause data to be skipped, duplicated or otherwise result in a ClassCastException
- Next message: RFR: 8179887 - Build failure with glibc >= 2.24: error: 'int readdir_r(DIR*, dirent*, dirent**)' is deprecated
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]