GNU bug report logs - #46451
[PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts

Previous Next

Package: guix-patches;

Reported by: Björn Höfling <bjoern.hoefling <at> bjoernhoefling.de>

Date: Thu, 11 Feb 2021 23:15:02 UTC

Severity: normal

Tags: patch

Done: Leo Prikler <leo.prikler <at> student.tugraz.at>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 46451 in the body.
You can then email your comments to 46451 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#46451; Package guix-patches. (Thu, 11 Feb 2021 23:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Björn Höfling <bjoern.hoefling <at> bjoernhoefling.de>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 11 Feb 2021 23:15:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Björn Höfling <bjoern.hoefling <at> bjoernhoefling.de>
To: <guix-patches <at> gnu.org>
Subject: [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts
Date: Fri, 12 Feb 2021 00:14:05 +0100
[Message part 1 (text/plain, inline)]
These two patches fix a NullPointerException in the OpenJDK packages.

The patches apply only to OpenJDK9 and OpenJDK11, but with inheritence
all OpenJDKx with x\in[9..14] are covered.

Here is the bug report:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41177

In order to test it you can use the following Main.java:

~~~~~~
import java.awt.*;

public class Main {

    public static void main(String[] args)
    {
        String fonts[] =
            GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();

        for ( int i = 0; i < fonts.length; i++ )
	    {
		System.out.println(fonts[i]);
	    }
    }
}

~~~~~~~~
Compile: javac Main.java
Run: java -cp . Main

It should print a list of the available fonts.


Björn


Björn Höfling (2):
  gnu: openjdk <at> 9 : Add phase to hardcode libraries.
  gnu: openjdk11: Add phase to hardcode libraries.

 gnu/packages/java.scm | 56 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)

-- 
2.27.0

[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#46451; Package guix-patches. (Thu, 11 Feb 2021 23:21:01 GMT) Full text and rfc822 format available.

Message #8 received at 46451 <at> debbugs.gnu.org (full text, mbox):

From: Björn Höfling <bjoern.hoefling <at> bjoernhoefling.de>
To: 46451 <at> debbugs.gnu.org
Subject: [PATCH 1/2] gnu: openjdk <at> 9 : Add phase to hardcode libraries.
Date: Fri, 12 Feb 2021 00:20:16 +0100
[Message part 1 (text/plain, inline)]
* gnu/packages/java.scm (openjdk9)[arguments]: Add patch-jni-libs phase.

This fixes a NullPointerException related to using fontconfig
reported by Jonathan Frederickson <jonathan <at> terracrypt.net>
in <https://bugs.gnu.org/41177>.
---
 gnu/packages/java.scm | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index d6afb2e9d3..a63dad8755 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -10,7 +10,7 @@
 ;;; Copyright © 2018, 2019 Gábor Boskovits <boskovits <at> gmail.com>
 ;;; Copyright © 2018 Chris Marusich <cmmarusich <at> gmail.com>
 ;;; Copyright © 2018, 2019, 2020 Efraim Flashner <efraim <at> flashner.co.il>
-;;; Copyright © 2019, 2020 Björn Höfling <bjoern.hoefling <at> bjoernhoefling.de>
+;;; Copyright © 2019, 2020, 2021 Björn Höfling <bjoern.hoefling <at> bjoernhoefling.de>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
 ;;; Copyright © 2020 Raghav Gururajan <raghavgururajan <at> disroot.org>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
@@ -1928,6 +1928,33 @@ new Date();"))
                                                  (number->string (parallel-job-count))))
                             '())
                       ,@make-flags))))
+         (add-after 'unpack 'patch-jni-libs
+           ;; Hardcode dynamically loaded libraries.
+           (lambda _
+             (let* ((library-path (search-path-as-string->list
+                                   (getenv "LIBRARY_PATH")))
+                    (find-library (lambda (name)
+                                    (search-path
+                                     library-path
+                                     (string-append "lib" name ".so")))))
+               (for-each
+                (lambda (file)
+                  (catch 'decoding-error
+                    (lambda ()
+                      (substitute* file
+                        (("VERSIONED_JNI_LIB_NAME\\(\"(.*)\", \"(.*)\"\\)"
+                          _ name version)
+                         (format #f "\"~a\""  (find-library name)))
+                        (("JNI_LIB_NAME\\(\"(.*)\"\\)" _ name)
+                         (format #f "\"~a\"" (find-library name)))))
+                    (lambda _
+                      ;; Those are safe to skip.
+                      (format (current-error-port)
+                                      "warning: failed to substitute: ~a~%"
+                                      file))))
+                (find-files "."
+                            "\\.c$|\\.h$"))
+               #t)))
          ;; Some of the libraries in the lib/ folder link to libjvm.so.
          ;; But that shared object is located in the server/ folder, so it
          ;; cannot be found.  This phase creates a symbolic link in the
-- 
2.27.0

[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#46451; Package guix-patches. (Thu, 11 Feb 2021 23:21:02 GMT) Full text and rfc822 format available.

Message #11 received at 46451 <at> debbugs.gnu.org (full text, mbox):

From: Björn Höfling <bjoern.hoefling <at> bjoernhoefling.de>
To: 46451 <at> debbugs.gnu.org
Subject: [PATCH 2/2] gnu: openjdk11: Add phase to hardcode libraries.
Date: Fri, 12 Feb 2021 00:20:53 +0100
[Message part 1 (text/plain, inline)]
* gnu/packages/java.scm (openjdk11)[arguments]: Add patch-jni-libs phase.

    This fixes a NullPointerException related to using fontconfig
    reported by Jonathan Frederickson <jonathan <at> terracrypt.net>
    in <https://bugs.gnu.org/41177>.
---
 gnu/packages/java.scm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index a63dad8755..85ca37d8b6 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -2139,6 +2139,33 @@ new Date();"))
              (substitute* "make/data/blacklistedcertsconverter/blacklisted.certs.pem"
                (("^#!.*") "#! java BlacklistedCertsConverter SHA-256\n"))
              #t))
+         (add-after 'unpack 'patch-jni-libs
+           ;; Hardcode dynamically loaded libraries.
+           (lambda _
+             (let* ((library-path (search-path-as-string->list
+                                   (getenv "LIBRARY_PATH")))
+                    (find-library (lambda (name)
+                                    (search-path
+                                     library-path
+                                     (string-append "lib" name ".so")))))
+               (for-each
+                (lambda (file)
+                  (catch 'decoding-error
+                    (lambda ()
+                      (substitute* file
+                        (("VERSIONED_JNI_LIB_NAME\\(\"(.*)\", \"(.*)\"\\)"
+                          _ name version)
+                         (format #f "\"~a\""  (find-library name)))
+                        (("JNI_LIB_NAME\\(\"(.*)\"\\)" _ name)
+                         (format #f "\"~a\"" (find-library name)))))
+                    (lambda _
+                      ;; Those are safe to skip.
+                      (format (current-error-port)
+                                      "warning: failed to substitute: ~a~%"
+                                      file))))
+                (find-files "."
+                            "\\.c$|\\.h$"))
+               #t)))
          (add-before 'build 'write-source-revision-file
            (lambda _
              (with-output-to-file ".src-rev"
-- 
2.27.0

[Message part 2 (application/pgp-signature, inline)]

Reply sent to Leo Prikler <leo.prikler <at> student.tugraz.at>:
You have taken responsibility. (Fri, 12 Feb 2021 10:53:02 GMT) Full text and rfc822 format available.

Notification sent to Björn Höfling <bjoern.hoefling <at> bjoernhoefling.de>:
bug acknowledged by developer. (Fri, 12 Feb 2021 10:53:03 GMT) Full text and rfc822 format available.

Message #16 received at 46451-done <at> debbugs.gnu.org (full text, mbox):

From: Leo Prikler <leo.prikler <at> student.tugraz.at>
To: Björn Höfling <bjoern.hoefling <at> bjoernhoefling.de>
Cc: 46451-done <at> debbugs.gnu.org, 41177-done <at> debbugs.gnu.org
Subject: Re: [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts
Date: Fri, 12 Feb 2021 11:52:50 +0100
Hi Björn

Am Freitag, den 12.02.2021, 00:14 +0100 schrieb Björn Höfling:
> These two patches fix a NullPointerException in the OpenJDK packages.
> 
> The patches apply only to OpenJDK9 and OpenJDK11, but with
> inheritence
> all OpenJDKx with x\in[9..14] are covered.
> 
> Here is the bug report:
> 
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41177
> 
> In order to test it you can use the following Main.java:
> 
> ~~~~~~
> import java.awt.*;
> 
> public class Main {
> 
>     public static void main(String[] args)
>     {
>         String fonts[] =
>             GraphicsEnvironment.getLocalGraphicsEnvironment().getAvai
> lableFontFamilyNames();
> 
>         for ( int i = 0; i < fonts.length; i++ )
> 	    {
> 		System.out.println(fonts[i]);
> 	    }
>     }
> }
> 
> ~~~~~~~~
> Compile: javac Main.java
> Run: java -cp . Main
> 
> It should print a list of the available fonts.
Indeed, that it does.  At least for 9 and 11, which I've invoked
directly from their store paths.

I've pushed your patches with small changes to the commit messages and
followed up with an indentation fix.

Regards,
Leo





Information forwarded to guix-patches <at> gnu.org:
bug#46451; Package guix-patches. (Fri, 12 Feb 2021 20:00:02 GMT) Full text and rfc822 format available.

Message #19 received at 46451-done <at> debbugs.gnu.org (full text, mbox):

From: Björn Höfling <bjoern.hoefling <at> bjoernhoefling.de>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>
Cc: 46451-done <at> debbugs.gnu.org, 41177-done <at> debbugs.gnu.org
Subject: Re: [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts
Date: Fri, 12 Feb 2021 20:59:39 +0100
[Message part 1 (text/plain, inline)]
On Fri, 12 Feb 2021 11:52:50 +0100
Leo Prikler <leo.prikler <at> student.tugraz.at> wrote:

> I've pushed your patches with small changes to the commit messages and
> followed up with an indentation fix.

Thanks! 

Björn

[Message part 2 (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 13 Mar 2021 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 16 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.