guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/04: gnu: classpath-bootstrap: Work around miscompilation.


From: guix-commits
Subject: 03/04: gnu: classpath-bootstrap: Work around miscompilation.
Date: Fri, 3 Sep 2021 06:05:07 -0400 (EDT)

civodul pushed a commit to branch core-updates-frozen
in repository guix.

commit 7f50543d55b20cd528b28d7e15f1bb81001a8da9
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Sep 3 11:36:52 2021 +0200

    gnu: classpath-bootstrap: Work around miscompilation.
    
    Fixes <https://issues.guix.gnu.org/49990>.
    
    Previously, building 'ant-bootstrap' would fail in obscure ways.
    
    * gnu/packages/patches/classpath-miscompilation.patch: New file.
    * gnu/local.mk (dist_patch_DATA): Add it.
    * gnu/packages/java.scm (classpath-bootstrap)[source]: Use it.
    [arguments]: Remove 'remove-call-to-free' phase.
---
 gnu/local.mk                                       |  1 +
 gnu/packages/java.scm                              | 14 +----
 .../patches/classpath-miscompilation.patch         | 71 ++++++++++++++++++++++
 3 files changed, 74 insertions(+), 12 deletions(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 0226440..bb22e29 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -928,6 +928,7 @@ dist_patch_DATA =                                           
\
   %D%/packages/patches/clang-runtime-3.9-libsanitizer-mode-field.patch \
   %D%/packages/patches/clang-runtime-3.8-libsanitizer-mode-field.patch \
   %D%/packages/patches/classpath-aarch64-support.patch         \
+  %D%/packages/patches/classpath-miscompilation.patch          \
   %D%/packages/patches/clucene-pkgconfig.patch                 \
   %D%/packages/patches/cmake-curl-certificates.patch           \
   %D%/packages/patches/coda-use-system-libs.patch              \
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index ed8c0c7..51fc5c6 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
@@ -246,17 +247,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 0000000..c3a569e
--- /dev/null
+++ b/gnu/packages/patches/classpath-miscompilation.patch
@@ -0,0 +1,71 @@
+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 <https://issues.guix.gnu.org/issue/36685>
+and <https://issues.guix.gnu.org/49990>.
+
+diff --git a/native/jni/java-io/java_io_VMFile.c 
b/native/jni/java-io/java_io_VMFile.c
+index de1320b..6695e1f 100644
+--- a/native/jni/java-io/java_io_VMFile.c
++++ b/native/jni/java-io/java_io_VMFile.c
+@@ -240,6 +240,7 @@ Java_java_io_VMFile_exists (JNIEnv * env,
+ #ifndef WITHOUT_FILESYSTEM
+   const char *filename;
+   int result;
++  jboolean exists;
+ 
+   /* Don't use the JCL convert function because it throws an exception
+      on failure */
+@@ -250,9 +251,10 @@ Java_java_io_VMFile_exists (JNIEnv * env,
+     }
+ 
+   result = cpio_isFileExists (filename);
++  exists = (result == CPNATIVE_OK ? 1 : 0);
+   (*env)->ReleaseStringUTFChars (env, name, filename);
+ 
+-  return result == CPNATIVE_OK ? 1 : 0;
++  return exists;
+ #else /* not WITHOUT_FILESYSTEM */
+   return 0;
+ #endif /* not WITHOUT_FILESYSTEM */
+@@ -278,6 +280,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 +291,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 */
+@@ -315,6 +319,7 @@ Java_java_io_VMFile_isDirectory (JNIEnv * env,
+   const char *filename;
+   int result;
+   jint entryType;
++  jboolean isdirectory;
+ 
+   /* Don't use the JCL convert function because it throws an exception
+      on failure */
+@@ -325,9 +330,10 @@ Java_java_io_VMFile_isDirectory (JNIEnv * env,
+     }
+   
+   result = cpio_checkType (filename, &entryType);
++  isdirectory = (result == CPNATIVE_OK && entryType == CPFILE_DIRECTORY ? 1 : 
0);
+   (*env)->ReleaseStringUTFChars (env, name, filename);
+ 
+-  return result == CPNATIVE_OK && entryType == CPFILE_DIRECTORY ? 1 : 0;
++  return isdirectory;
+ #else /* not WITHOUT_FILESYSTEM */
+   return 0;
+ #endif /* not WITHOUT_FILESYSTEM */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]