diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index 08ef7a8213..d3c95a456d 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -230,7 +230,8 @@ only faster.") (sha256 (base32 "0i99wf9xd3hw1sj2sazychb9prx8nadxh2clgvk3zlmb28v0jbfz")) - (patches (search-patches "classpath-aarch64-support.patch")))) + (patches (search-patches "classpath-aarch64-support.patch" + "classpath-miscompilation.patch")))) (build-system gnu-build-system) (arguments `(#:configure-flags @@ -247,17 +248,6 @@ only faster.") "--disable-gjdoc") #:phases (modify-phases %standard-phases - ;; XXX: This introduces a memory leak as we remove a call to free up - ;; memory for the file name string. This was necessary because of a - ;; runtime error that would have prevented us from building - ;; ant-bootstrap later. See https://issues.guix.gnu.org/issue/36685 - ;; for the gnarly details. - (add-after 'unpack 'remove-call-to-free - (lambda _ - (substitute* "native/jni/java-io/java_io_VMFile.c" - (("result = cpio_isFileExists.*" m) - (string-append m "\n//"))) - #t)) (add-after 'install 'install-data (lambda _ (invoke "make" "install-data")))))) (native-inputs diff --git a/gnu/packages/patches/classpath-miscompilation.patch b/gnu/packages/patches/classpath-miscompilation.patch new file mode 100644 index 0000000000..835113df71 --- /dev/null +++ b/gnu/packages/patches/classpath-miscompilation.patch @@ -0,0 +1,31 @@ +For some reason, the original code gets miscompiled on x86_64, leading +'Java_java_io_VMFile_isFile' to return true when the return value of +'cpio_checkType' is ENOENT (= 2). + +See +and . + +diff --git a/native/jni/java-io/java_io_VMFile.c b/native/jni/java-io/java_io_VMFile.c +index de1320b..9a5d375 100644 +--- a/native/jni/java-io/java_io_VMFile.c ++++ b/native/jni/java-io/java_io_VMFile.c +@@ -278,6 +278,7 @@ Java_java_io_VMFile_isFile (JNIEnv * env, + const char *filename; + int result; + jint entryType; ++ jboolean isfile; + + /* Don't use the JCL convert function because it throws an exception + on failure */ +@@ -288,9 +289,10 @@ Java_java_io_VMFile_isFile (JNIEnv * env, + } + + result = cpio_checkType (filename, &entryType); ++ isfile = (result == CPNATIVE_OK && entryType == CPFILE_FILE ? 1 : 0); + (*env)->ReleaseStringUTFChars (env, name, filename); + +- return result == CPNATIVE_OK && entryType == CPFILE_FILE ? 1 : 0; ++ return isfile; + #else /* not WITHOUT_FILESYSTEM */ + return 0; + #endif /* not WITHOUT_FILESYSTEM */