AdoptOpenJDK / openjdk-docker

Scripts for creating Docker images of OpenJDK binaries.
https://hub.docker.com/_/adoptopenjdk/
Apache License 2.0
426 stars 237 forks source link

NPE in sun.awt.FontConfiguration.getVersion(...) #75

Closed ChristianCiach closed 3 years ago

ChristianCiach commented 5 years ago

We have some unit tests that create GUI components. Some of these fail with this stacktrace when using adoptopenjdk/openjdk11:latest:

        java.lang.NullPointerException
            at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1262)
            at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:225)
            at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:107)
            at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:719)
            at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:367)
            at java.base/java.security.AccessController.doPrivileged(Native Method)
            at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:312)
            at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
            at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)

This is not a new issue, as seen here: https://github.com/docker-library/openjdk/issues/46

This workaround also applies here: https://github.com/docker-library/openjdk/pull/48/commits/0f82de10e4aaa8b78d7f79cf725fd1fad1dc85e0 . You just have to install the package libfontconfig1 to fix this issue.

karianna commented 5 years ago

@dinogun Is this something that was stripped out or something we missed in the base JDK/JRE that we give you?

dinogun commented 5 years ago

@ChristianCiach Are you testing the Alpine images as well ? If yes, do these tests fail there as well ? Want to make sure that we add this in both if needed, though I am not sure if the GUI usecase makes sense in the Alpine case. @karianna The missing package is part of the base OS and not part of the JDK.

ChristianCiach commented 5 years ago

This is probably just me being incompatible with mondays, but I can't find any Alpine images on Docker Hub. Strange, I was sure they were there before.

dinogun commented 5 years ago

You should find them here, specifically the tag adoptopenjdk/openjdk11:x86_64-alpine-jdk-11.28. The latest alpine is always accessible as adoptopenjdk/openjdk11:alpine

ChristianCiach commented 5 years ago

The exact same NPE happens with the openjdk11:alpine image. I tried to install apk --no-cache add fontconfig ttf-dejavu into the image as seen here or here, but that doesn't fix it for me.

minhtran83 commented 5 years ago

@ChristianCiach It happens the same with me too. Both fontconfig or ttf-dejavu does not work for me. I have to switch to use ubuntu image, and it is good to me

gamma commented 5 years ago

Adding a simple fontconfig.properties (see https://github.com/AdoptOpenJDK/openjdk-build/issues/693) in the $JAVA_HOME/lib directory fixes the NPE. But it still does not work and requires something else I couldn't find yet. Using -Dsun.java2d.debugfonts=warning I get the following warnings and errors:

Nov 28, 2018 11:18:02 AM sun.font.FcFontConfiguration warning
WARNING: Failed to get info from libfontconfig
...
Nov 28, 2018 11:18:02 AM sun.awt.X11FontManager specificFontIDForName
SEVERE: Font Configuration Font ID is malformed:
Nov 28, 2018 11:18:02 AM sun.awt.X11FontManager getFileNameFromPlatformName
WARNING: ** Registering all font paths because can't find file for 
Nov 28, 2018 11:18:02 AM sun.awt.X11FontManager getFileNameFromPlatformName
WARNING: ** Finished registering all font paths
Nov 28, 2018 11:18:02 AM sun.awt.X11FontManager switchFontIDForName
SEVERE: Font Configuration Font ID is malformed:

I asume that the simple fontconfig.propertiesdoes not suffice, but what has to go in it? Can it be generated?

gamma commented 5 years ago

I asume that the simple fontconfig.propertiesdoes not suffice, but what has to go in it? Can it be generated?

I checked further. ldd /usr/lib/libfontconfig.so.1 gives the dependencies. I tried loading the lib from java by hand (System.loadLibrary("fontconfig")) - which threw an error that libc.musl-x86_64.so.1 was missing. But it is there in /lib

I linked it into /usr/lib.

Second: I had to set LD_LIBRARY_PATH=/usr/lib

Now it works.

jcoetzee commented 5 years ago

Experiencing the same. Installing ttf-dejavu and fontconfig doesn't help.

gamma commented 5 years ago

@jcoetzee have you checked my solution, setting the LD_LIBRARY_PATH as ENV and checking that libc.musl-x86_64.so.1 is available in /usr/lib

jcoetzee commented 5 years ago

@gamma Just tried and it works even without creating the simple fontconfig.properties file (which is what I wanted to avoid). Thanks.

jcoetzee commented 5 years ago

For those wondering, the workaround can be summarised as

RUN ln -s /lib/libc.musl-x86_64.so.1 /usr/lib/libc.musl-x86_64.so.1
ENV LD_LIBRARY_PATH /usr/lib
jgkirschbaum commented 5 years ago

Installing packages fontconfig and urw-fonts on CentOS 6 & 7 fixed the issue.

ReillyTevera commented 5 years ago

I wasn't able to get it working just with the workaround as described by @jcoetzee. I had to softlink a few additional libraries as well to make the JVM happy.

Full workaround (tested with adoptopenjdk/openjdk8-openj9:jdk8u202-b08_openj9-0.12.1-alpine and adoptopenjdk/openjdk11:jdk-11.0.2.9-alpine):

RUN apk add --no-cache fontconfig
RUN ln -s /usr/lib/libfontconfig.so.1 /usr/lib/libfontconfig.so && \
    ln -s /lib/libuuid.so.1 /usr/lib/libuuid.so.1 && \
    ln -s /lib/libc.musl-x86_64.so.1 /usr/lib/libc.musl-x86_64.so.1
ENV LD_LIBRARY_PATH /usr/lib
cwrau commented 5 years ago

@ReillyProcentive I can say that this workaround works for me, with imageadoptopenjdk/openjdk11:jdk-11.0.2.9-alpine-slim Thank you!

DukeyToo commented 5 years ago

Above fixes for me too. fontconfig and libuuid symbolic links were not needed in adoptopenjdk/openjdk11:jdk-11.0.1.13-alpine but they are needed in adoptopenjdk/openjdk11:jdk-11.0.2.9-alpine. Also added libuuid apk package, which I did not have before.

robinvanpraet commented 5 years ago

This made it work for me:

RUN apt-get update && apt-get install -y --no-install-recommends fontconfig
RUN ln -s /usr/lib/libfontconfig.so.1 /usr/lib/libfontconfig.so && \
    ln -s /lib/libuuid.so.1 /usr/lib/libuuid.so.1 && \
    ln -s /lib/libc.musl-x86_64.so.1 /usr/lib/libc.musl-x86_64.so.1
ENV LD_LIBRARY_PATH /usr/lib

I'm using the adoptopenjdk/openjdk11:jdk-11.0.1.13-slim image

ReillyTevera commented 5 years ago

For AdoptOpenJDK developers here is a reliable way to reproduce the issue (using the adoptopenjdk/openjdk8-openj9:jdk8u202-b08_openj9-0.12.1-alpine image):

apk add --no-cache fontconfig

public class Main {
  public static void main(String[] args) {
      System.loadLibrary("fontconfig");
    }
}

This fails with the error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: fontconfig (Not found in java.library.path)
    at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1434)
    at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1404)
    at java.lang.System.loadLibrary(System.java:540)
    at Main.main(Main.java:21)

Interestingly this fails in both the AdoptOpenJDK and Alpine docker images (openjdk:8u201-jre-alpine3.9). It appears that when the fontconfig library is installed it gets created at /usr/lib/libfontconfig.so.1 and OpenJDK is unable to detect libraries that do not end in .so (thus the first symbolic link creation). An upstream issue should probably be created for this issue but I'm unsure as to where it should go (the OpenJDK project itself?).

After you link the first library (ln -s /usr/lib/libfontconfig.so.1 /usr/lib/libfontconfig.so) you run into the second issue which is that the default list of Java libraries (java.library.path) is seemingly ignored. This issue is only present in AdoptOpenJDK.

If you run java -XshowSettings:properties you see that the following is the default list of library paths:

    java.library.path = /opt/java/openjdk/jre/lib/amd64/compressedrefs
        /opt/java/openjdk/jre/lib/amd64
        /usr/lib64
        /usr/lib

Interestingly AdoptOpenJDK seemingly ignores these and is thus unable to load fontconfig even after the first issue is worked around. Additionally setting these through a flag doesn't seem to work (-Djava.library.path=/usr/lib:/lib) but setting them through an environmental variable (export LD_LIBRARY_PATH=/usr/lib:/lib) seems to work.

A third issue seems to be present in JDK11 builds but not JDK 8 builds. This issue is that Java seems to fatally exit if /lib is included in the list of library paths. This error is the reason behind only using /usr/lib in the workaround and then softlinking the libraries that fontconfig needs into /usr/lib.

Error message:

/linked # export LD_LIBRARY_PATH=/usr/lib:/lib
/linked # java Main
Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f703dbad518, pid=82, tid=83
#
# JRE version:  (11.0.2+9) (build )
# Java VM: OpenJDK 64-Bit Server VM (11.0.2+9, mixed mode, aot, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C  [libc.so.6+0x52518]
#
# Core dump will be written. Default location: core.82 (may not exist)
#
# An error report file with more information is saved as:
# /linked/hs_err_pid82.log
#
# If you would like to submit a bug report, please visit:
#   https://github.com/AdoptOpenJDK/openjdk-build/issues
#
Aborted (core dumped)
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f703dbad518, pid=82, tid=83
#
# JRE version:  (11.0.2+9) (build )
# Java VM: OpenJDK 64-Bit Server VM (11.0.2+9, mixed mode, aot, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C  [libc.so.6+0x52518]
#
# Core dump will be written. Default location: core.82 (may not exist)
#
# If you would like to submit a bug report, please visit:
#   https://github.com/AdoptOpenJDK/openjdk-build/issues
#

---------------  S U M M A R Y ------------

Command Line: -XX:+UseContainerSupport Main

Host: Intel(R) Xeon(R) CPU E3-1240 v5 @ 3.50GHz, 
[error occurred during error reporting (printing summary machine and OS info), id 0xb, SIGSEGV (0xb) at pc=0x00007f703dbad518]

Time: Wed Apr 10 19:27:03 2019 UTC elapsed time: 0 seconds (0d 0h 0m 0s)

---------------  T H R E A D  ---------------

Current thread (0x00007f7038010800):  JavaThread "Unknown thread" [_thread_in_vm, id=83, stack(0x00007f703e5c0000,0x00007f703e6c1000)]

Stack: [0x00007f703e5c0000,0x00007f703e6c1000],  sp=0x00007f703e6bd1c0,  free space=1012k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libc.so.6+0x52518]

siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000000000048

Registers:
RAX=0x00000000fbad8001, RBX=0x00007f703e6bd8c0, RCX=0x0000000000000000, RDX=0x0000000000000000
RSP=0x00007f703e6bd1c0, RBP=0x00007f703e6bd890, RSI=0x00007f7038010800, RDI=0x00007f703e6bd8c0
R8 =0x0000000000000000, R9 =0x00007f7038000000, R10=0xfffffffffffff000, R11=0x0000000000000000
R12=0x00007f703e6beaa0, R13=0x00007f703e6bd8c0, R14=0x00007f703e6bda90, R15=0x00007f703d61757e
RIP=0x00007f703dbad518, EFLAGS=0x0000000000010206, CSGSFS=0x002b000000000033, ERR=0x0000000000000004
  TRAPNO=0x000000000000000e

Top of Stack: (sp=0x00007f703e6bd1c0)
0x00007f703e6bd1c0:   000000000005000a ffffffffffffffff
0x00007f703e6bd1d0:   0000000000050036 0000000000000000
0x00007f703e6bd1e0:   00007f703e6bd8e0 0000000000000000
0x00007f703e6bd1f0:   0000000000000013 00007f703e6bd910 

Instructions: (pc=0x00007f703dbad518)
0x00007f703dbad4f8:   41 8b 45 00 a8 04 0f 85 6c 25 00 00 48 85 f6 0f
0x00007f703dbad508:   84 8d 39 00 00 48 8b b5 00 fa ff ff 48 8b 56 08
0x00007f703dbad518:   48 8b 7a 48 48 8b 72 40 ba 00 00 00 00 80 3f 00
0x00007f703dbad528:   48 89 b5 58 f9 ff ff 8b 35 ab b1 36 00 48 0f 45 

---------------  P R O C E S S  ---------------

Threads class SMR info:
_java_thread_list=0x0000000001846810, length=0, elements={
}

Java Threads: ( => current thread )

Other Threads:

[error occurred during error reporting (printing all threads), id 0xb, SIGSEGV (0xb) at pc=0x00007f703d4efe93]

VM state:not at safepoint (not fully initialized)

VM Mutex/Monitor currently owned by a thread: None

[error occurred during error reporting (printing compressed oops mode), id 0xb, SIGSEGV (0xb) at pc=0x00007f703d5129b3]

Deoptimization events (0 events):
No events

Classes redefined (0 events):
No events

Internal exceptions (0 events):
No events

Events (0 events):
No events

Dynamic libraries:
00400000-00401000 r-xp 00000000 fd:02 12749247                           /opt/java/openjdk/bin/java
00600000-00601000 r--p 00000000 fd:02 12749247                           /opt/java/openjdk/bin/java
00601000-00602000 rw-p 00001000 fd:02 12749247                           /opt/java/openjdk/bin/java
01843000-01864000 rw-p 00000000 00:00 0                                  [heap]
7f702ef11000-7f7037589000 r--s 00000000 fd:02 13000521                   /opt/java/openjdk/lib/modules
7f7037589000-7f70375a4000 r-xp 00000000 fd:02 13000502                   /opt/java/openjdk/lib/libjimage.so
7f70375a4000-7f70377a4000 ---p 0001b000 fd:02 13000502                   /opt/java/openjdk/lib/libjimage.so
7f70377a4000-7f70377a6000 r--p 0001b000 fd:02 13000502                   /opt/java/openjdk/lib/libjimage.so
7f70377a6000-7f70377a7000 rw-p 0001d000 fd:02 13000502                   /opt/java/openjdk/lib/libjimage.so
7f70377a7000-7f70377ae000 r-xp 00000000 fd:02 13000520                   /opt/java/openjdk/lib/libzip.so
7f70377ae000-7f70379ad000 ---p 00007000 fd:02 13000520                   /opt/java/openjdk/lib/libzip.so
7f70379ad000-7f70379ae000 r--p 00006000 fd:02 13000520                   /opt/java/openjdk/lib/libzip.so
7f70379ae000-7f70379af000 rw-p 00007000 fd:02 13000520                   /opt/java/openjdk/lib/libzip.so
7f70379af000-7f70379ba000 r-xp 00000000 fd:02 12749185                   /usr/glibc-compat/lib/libnss_files-2.29.so
7f70379ba000-7f7037bb9000 ---p 0000b000 fd:02 12749185                   /usr/glibc-compat/lib/libnss_files-2.29.so
7f7037bb9000-7f7037bba000 r--p 0000a000 fd:02 12749185                   /usr/glibc-compat/lib/libnss_files-2.29.so
7f7037bba000-7f7037bbb000 rw-p 0000b000 fd:02 12749185                   /usr/glibc-compat/lib/libnss_files-2.29.so
7f7037bbb000-7f7037bc1000 rw-p 00000000 00:00 0 
7f7037bc1000-7f7037bea000 r-xp 00000000 fd:02 13000498                   /opt/java/openjdk/lib/libjava.so
7f7037bea000-7f7037dea000 ---p 00029000 fd:02 13000498                   /opt/java/openjdk/lib/libjava.so
7f7037dea000-7f7037deb000 r--p 00029000 fd:02 13000498                   /opt/java/openjdk/lib/libjava.so
7f7037deb000-7f7037ded000 rw-p 0002a000 fd:02 13000498                   /opt/java/openjdk/lib/libjava.so
7f7037ded000-7f7037dfe000 r-xp 00000000 fd:02 13000519                   /opt/java/openjdk/lib/libverify.so
7f7037dfe000-7f7037ffd000 ---p 00011000 fd:02 13000519                   /opt/java/openjdk/lib/libverify.so
7f7037ffd000-7f7037fff000 r--p 00010000 fd:02 13000519                   /opt/java/openjdk/lib/libverify.so
7f7037fff000-7f7038000000 rw-p 00012000 fd:02 13000519                   /opt/java/openjdk/lib/libverify.so
7f7038000000-7f7038047000 rw-p 00000000 00:00 0 
7f7038047000-7f703c000000 ---p 00000000 00:00 0 
7f703c1f7000-7f703c1fe000 r-xp 00000000 fd:02 12749198                   /usr/glibc-compat/lib/librt-2.29.so
7f703c1fe000-7f703c3fd000 ---p 00007000 fd:02 12749198                   /usr/glibc-compat/lib/librt-2.29.so
7f703c3fd000-7f703c3fe000 r--p 00006000 fd:02 12749198                   /usr/glibc-compat/lib/librt-2.29.so
7f703c3fe000-7f703c3ff000 rw-p 00007000 fd:02 12749198                   /usr/glibc-compat/lib/librt-2.29.so
7f703c3ff000-7f703c53f000 r-xp 00000000 fd:02 12749167                   /usr/glibc-compat/lib/libm-2.29.so
7f703c53f000-7f703c73e000 ---p 00140000 fd:02 12749167                   /usr/glibc-compat/lib/libm-2.29.so
7f703c73e000-7f703c73f000 r--p 0013f000 fd:02 12749167                   /usr/glibc-compat/lib/libm-2.29.so
7f703c73f000-7f703c740000 rw-p 00140000 fd:02 12749167                   /usr/glibc-compat/lib/libm-2.29.so
7f703c740000-7f703d812000 r-xp 00000000 fd:02 13000532                   /opt/java/openjdk/lib/server/libjvm.so
7f703d812000-7f703da11000 ---p 010d2000 fd:02 13000532                   /opt/java/openjdk/lib/server/libjvm.so
7f703da11000-7f703dacf000 r--p 010d1000 fd:02 13000532                   /opt/java/openjdk/lib/server/libjvm.so
7f703dacf000-7f703db08000 rw-p 0118f000 fd:02 13000532                   /opt/java/openjdk/lib/server/libjvm.so
7f703db08000-7f703db5b000 rw-p 00000000 00:00 0 
7f703db5b000-7f703dd0f000 r-xp 00000000 fd:02 12749156                   /usr/glibc-compat/lib/libc-2.29.so
7f703dd0f000-7f703df0f000 ---p 001b4000 fd:02 12749156                   /usr/glibc-compat/lib/libc-2.29.so
7f703df0f000-7f703df13000 r--p 001b4000 fd:02 12749156                   /usr/glibc-compat/lib/libc-2.29.so
7f703df13000-7f703df15000 rw-p 001b8000 fd:02 12749156                   /usr/glibc-compat/lib/libc-2.29.so
7f703df15000-7f703df19000 rw-p 00000000 00:00 0 
7f703df19000-7f703df1c000 r-xp 00000000 fd:02 12749162                   /usr/glibc-compat/lib/libdl-2.29.so
7f703df1c000-7f703e11b000 ---p 00003000 fd:02 12749162                   /usr/glibc-compat/lib/libdl-2.29.so
7f703e11b000-7f703e11c000 r--p 00002000 fd:02 12749162                   /usr/glibc-compat/lib/libdl-2.29.so
7f703e11c000-7f703e11d000 rw-p 00003000 fd:02 12749162                   /usr/glibc-compat/lib/libdl-2.29.so
7f703e11d000-7f703e12d000 r-xp 00000000 fd:02 13000482                   /opt/java/openjdk/lib/jli/libjli.so
7f703e12d000-7f703e32c000 ---p 00010000 fd:02 13000482                   /opt/java/openjdk/lib/jli/libjli.so
7f703e32c000-7f703e32d000 r--p 0000f000 fd:02 13000482                   /opt/java/openjdk/lib/jli/libjli.so
7f703e32d000-7f703e32e000 rw-p 00010000 fd:02 13000482                   /opt/java/openjdk/lib/jli/libjli.so
7f703e32e000-7f703e348000 r-xp 00000000 fd:02 12749192                   /usr/glibc-compat/lib/libpthread-2.29.so
7f703e348000-7f703e547000 ---p 0001a000 fd:02 12749192                   /usr/glibc-compat/lib/libpthread-2.29.so
7f703e547000-7f703e548000 r--p 00019000 fd:02 12749192                   /usr/glibc-compat/lib/libpthread-2.29.so
7f703e548000-7f703e549000 rw-p 0001a000 fd:02 12749192                   /usr/glibc-compat/lib/libpthread-2.29.so
7f703e549000-7f703e54d000 rw-p 00000000 00:00 0 
7f703e54d000-7f703e574000 r-xp 00000000 fd:02 12749147                   /usr/glibc-compat/lib/ld-2.29.so
7f703e5b6000-7f703e5be000 rw-s 00000000 fd:02 1248391                    /tmp/hsperfdata_root/82
7f703e5be000-7f703e5bf000 ---p 00000000 00:00 0 
7f703e5bf000-7f703e5c0000 r--p 00000000 00:00 0 
7f703e5c0000-7f703e5c4000 ---p 00000000 00:00 0 
7f703e5c4000-7f703e6c3000 rw-p 00000000 00:00 0 
7f703e6c3000-7f703e6da000 r--p 00000000 fd:02 1193431                    /lib/ld-musl-x86_64.so.1
7f703e6da000-7f703e71f000 r-xp 00017000 fd:02 1193431                    /lib/ld-musl-x86_64.so.1
7f703e71f000-7f703e751000 r--p 0005c000 fd:02 1193431                    /lib/ld-musl-x86_64.so.1
7f703e751000-7f703e752000 r--p 0008d000 fd:02 1193431                    /lib/ld-musl-x86_64.so.1
7f703e752000-7f703e753000 rw-p 0008e000 fd:02 1193431                    /lib/ld-musl-x86_64.so.1
7f703e753000-7f703e756000 rw-p 00000000 00:00 0 
7f703e757000-7f703e75a000 r--p 00000000 fd:02 1193436                    /lib/libz.so.1.2.11
7f703e75a000-7f703e768000 r-xp 00003000 fd:02 1193436                    /lib/libz.so.1.2.11
7f703e768000-7f703e76f000 r--p 00011000 fd:02 1193436                    /lib/libz.so.1.2.11
7f703e76f000-7f703e770000 r--p 00017000 fd:02 1193436                    /lib/libz.so.1.2.11
7f703e770000-7f703e771000 rw-p 00018000 fd:02 1193436                    /lib/libz.so.1.2.11
7f703e771000-7f703e773000 rw-p 00000000 00:00 0 
7f703e773000-7f703e774000 r--p 00026000 fd:02 12749147                   /usr/glibc-compat/lib/ld-2.29.so
7f703e774000-7f703e775000 rw-p 00027000 fd:02 12749147                   /usr/glibc-compat/lib/ld-2.29.so
7f703e775000-7f703e776000 rw-p 00000000 00:00 0 
7ffde5f95000-7ffde5fb6000 rw-p 00000000 00:00 0                          [stack]
7ffde5fbc000-7ffde5fbf000 r--p 00000000 00:00 0                          [vvar]
7ffde5fbf000-7ffde5fc0000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

VM Arguments:
jvm_args: -XX:+UseContainerSupport 
java_command: Main
java_class_path (initial): .
Launcher Type: SUN_STANDARD

[Global flags]
     uint G1ConcRefinementThreads                  = 8                                         {product} {ergonomic}
    uintx GCDrainStackTargetSize                   = 64                                        {product} {ergonomic}
   size_t InitialHeapSize                          = 328760448                                 {product} {ergonomic}
   size_t MaxHeapSize                              = 5260167168                                {product} {ergonomic}
    uintx ReservedCodeCacheSize                    = 251658240                              {pd product} {ergonomic}
     bool SegmentedCodeCache                       = true                                      {product} {ergonomic}
     bool UseCompressedClassPointers               = true                                 {lp64_product} {ergonomic}
     bool UseCompressedOops                        = true                                 {lp64_product} {ergonomic}
     bool UseContainerSupport                      = true                                      {product} {environment}
     bool UseG1GC                                  = true                                      {product} {ergonomic}

Logging:
Log output configuration:
 #0: stdout all=warning uptime,level,tags
 #1: stderr all=off uptime,level,tags

Environment Variables:
JAVA_HOME=/opt/java/openjdk
JAVA_TOOL_OPTIONS=-XX:+UseContainerSupport
PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LD_LIBRARY_PATH=/usr/lib:/lib

Signal Handlers:
SIGSEGV: [libjvm.so+0xe1b7f0], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGBUS: [libjvm.so+0xe1b7f0], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGFPE: [libjvm.so+0xe1b7f0], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGPIPE: [libjvm.so+0xbef880], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGXFSZ: [libjvm.so+0xbef880], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGILL: [libjvm.so+0xe1b7f0], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGUSR2: [libjvm.so+0xbef720], sa_mask[0]=00000000000000000000000000000000, sa_flags=SA_RESTART|SA_SIGINFO
SIGHUP: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGINT: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGTERM: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGQUIT: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none

---------------  S Y S T E M  ---------------

OS:NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.9.0
PRETTY_NAME="Alpine Linux v3.9"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
uname:Linux 5.0.5-113.current #1 SMP PREEMPT Sat Mar 30 15:03:15 UTC 2019 x86_64
libc:glibc 2.29 NPTL 2.29 
rlimit: STACK 8192k, CORE infinity, NPROC infinity, NOFILE 1048576, AS infinity, DATA infinity, FSIZE infinity
load average:
[error occurred during error reporting (printing OS information), id 0xb, SIGSEGV (0xb) at pc=0x00007f703dba6129]

CPU:total 8 (initial active 8) 
CPU Model and flags from /proc/cpuinfo:
model name  : Intel(R) Xeon(R) CPU E3-1240 v5 @ 3.50GHz
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d

Memory: 4k page
[error occurred during error reporting (printing memory info), id 0xb, SIGSEGV (0xb) at pc=0x00007f703dbad518]

vm_info: OpenJDK 64-Bit Server VM (11.0.2+9) for linux-amd64 JRE (11.0.2+9), built on Jan 28 2019 15:50:01 by "jenkins" with gcc 7.3.1 20180303 (Red Hat 7.3.1-5)

END.
keeganwitt commented 5 years ago

Is there a simple way to reproduce this problem? System.loadLibrary("fontconfig") fails for me even with Oracle JDK on Windows.

varunkumarm commented 5 years ago
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]);
        }
    }
}

This code fails with NPE at FontConfiguration.getVersion()

Same code runs fine after installing the fontconfig package.

@keeganwitt let me know if you need any more information to reproduce the issue.

keeganwitt commented 5 years ago

Thank you. I should have made a follow up comment to this question. I tested this in a downstream issue (https://github.com/keeganwitt/docker-gradle/issues/104) using

import java.awt.image.BufferedImage
task fontTest {
    new BufferedImage(128, 128, BufferedImage.TYPE_INT_RGB).createGraphics().drawString("test", 1, 1)
}

But same idea. I also observed that the problem was resolved by installing the fontconfig package.

I think given what we've seen, it'd be prudent to include the package in the adoptopenjdk images.

ReillyTevera commented 5 years ago

@keeganwitt I don't think we're on the same page here. The issue isn't that fontconfig isn't installed in the adoptopenjdk docker image but that when it is installed it isn't usable without making some library symlinks.

This is a departure from the "official" OpenJDK images and makes it so that AdoptOpenJDK is not necessarily drop-in compatible (note that my knowledge is from before the official images got switched from the Debian build of OpenJDK so this may not be true today). This behavior is likely a bug but I don't know that we've received a response from and AdoptOpenJDK maintainer on the issue.

I don't agree on adding fontconfig by default to the AdoptOpenJDK images as it is not required by many projects and it adds a couple of MB to the Docker images because of it's required dependencies.

It makes more sense to me for downstream projects to add it themselves if they need it as a dependency. In that case however it should work as soon as it's installed without requiring any symlinks.

ReillyTevera commented 5 years ago

Oh, and I just tested and reproduced the original issue with adoptopenjdk/openjdk8-openj9:x86_64-alpine-jdk8u212-b04_openj9-0.14.2-slim and I still need to make the symlinks for the library loading to work however I can now omit the ENV LD_LIBRARY_PATH /usr/lib part.

saruye commented 5 years ago

For x86_64-alpine-jdk-12.0.2_10 installing ttf-dejavu helped. Nothing else was necessary.

RUN apk add --no-cache ttf-dejavu \
    && rm -rf /var/cache/apk/* 
xfh commented 4 years ago

For the record: the solution from @ReillyProcentive works for me in JDK8, JDK11 and JDK13 images. I still got a linking error in JDK10 though.

It is caused by an incompatible version of libfreetype. Removing the file /opt/java/openjdk/lib/libfreetype.so.6 fixed the issue.

ijabz commented 4 years ago

I have the same problem on a Java 11 built for custom unix hardware, im unclear what the correct solution is, I dont realy have the possibility to install anything over the internet but I can copy/create files.

PascalSchumacher commented 4 years ago

@ijabz For me https://github.com/AdoptOpenJDK/openjdk-docker/pull/224 solved the issue (for the distributions updated in the pull request).

ijabz commented 4 years ago

Okay, but Im not using Docker here, I need something I can run on linux machine where java 11 runtime has been installed to fix things.

steinybot commented 4 years ago

In case anyone comes across this issue who is not using the docker image (like I did) then here is how I fixed the problem. Nothing particularly new here, it has all been mentioned before but there were so many conflicting answers that I wasn't sure which to follow.

The first thing that I would recommend is to enable debug logging. You need to pass these options to the JVM.

-Djava.util.logging.config.file=logging.properties -Dsun.java2d.debugfonts=true

Then create a logging.properties file:

java.util.logging.ConsoleHandler.level = ALL

sun.awt.FontConfiguration.level = ALL
sun.java2d = ALL

Now when you start your application you will see something like this:

2020-05-26 22:08:30.267 +0000 main                      INFO  sun.awt.FontConfiguration      - Did not find a fontconfig file.
2020-05-26 22:08:30.312 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for sans:regular:roman
2020-05-26 22:08:30.312 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for sans:bold:roman
2020-05-26 22:08:30.312 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for sans:regular:italic
2020-05-26 22:08:30.313 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for sans:bold:italic
2020-05-26 22:08:30.313 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for serif:regular:roman
2020-05-26 22:08:30.313 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for serif:bold:roman
2020-05-26 22:08:30.313 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for serif:regular:italic
2020-05-26 22:08:30.313 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for serif:bold:italic
2020-05-26 22:08:30.313 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for monospace:regular:roman
2020-05-26 22:08:30.314 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for monospace:bold:roman
2020-05-26 22:08:30.314 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for monospace:regular:italic
2020-05-26 22:08:30.314 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no font for monospace:bold:italic
2020-05-26 22:08:30.314 +0000 main                      INFO  sun.java2d                     - Fontconfig returned no fonts at all.
2020-05-26 22:08:30.314 +0000 main                      WARN  sun.awt.FontConfiguration      - Failed to get info from libfontconfig
2020-05-26 22:08:30.314 +0000 main                      WARN  sun.awt.FontConfiguration      - Failed to get info from libfontconfig
2020-05-26 22:25:11.627 +0000 main                      ERROR com.geneious.shared.Operation  - Exception with message: java.lang.reflect.InvocationTargetException

Forget about the missing fontconfig file for now, that is not the main issue, although you may need to provide a configuration file if you need certain fonts.

The real problem is Failed to get info from libfontconfig, at least this is what it is looking for on Debian (on Alpine linux it is the fontconfig package). libfontconfig is a virtual package meaning you have to install a package that provides this yourself. For Ubuntu you can search for the libfontconfig package and see that it is provided by libfontconfig1.

Now only if you require specific fonts do you need to also install them, such as the DejaVu fonts (package ttf-dejavu on both Ubuntu and Alpine linux) which others have mentioned. In this case you may also need to configure it by creating a fontconfig file at one of the paths mentioned in the logs.

anydoby commented 4 years ago

I wasn't able to get it working just with the workaround as described by @jcoetzee. I had to softlink a few additional libraries as well to make the JVM happy.

Full workaround (tested with adoptopenjdk/openjdk8-openj9:jdk8u202-b08_openj9-0.12.1-alpine and adoptopenjdk/openjdk11:jdk-11.0.2.9-alpine):

RUN apk add --no-cache fontconfig
RUN ln -s /usr/lib/libfontconfig.so.1 /usr/lib/libfontconfig.so && \
    ln -s /lib/libuuid.so.1 /usr/lib/libuuid.so.1 && \
    ln -s /lib/libc.musl-x86_64.so.1 /usr/lib/libc.musl-x86_64.so.1
ENV LD_LIBRARY_PATH /usr/lib

I still had to install ttf-dejavu before it worked on alpine jdk14 on my raspberry 4 (from liberica).

FROM bellsoft/liberica-openjdk-alpine:14-aarch64

RUN apk add --no-cache fontconfig ttf-dejavu && fc-cache -f && \
    ln -s /usr/lib/libfontconfig.so.1 /usr/lib/libfontconfig.so && \
    ln -s /lib/libuuid.so.1 /usr/lib/libuuid.so.1 && \
    ln -s /lib/libc.musl-x86_64.so.1 /usr/lib/libc.musl-x86_64.so.1

ENV LD_LIBRARY_PATH /usr/lib
oliviermeurice commented 3 years ago

With adoptopenjdk/openjdk8:alpine-jre I had to do this to have X11 (java app GUI) redirected to the host: RUN apk add xorg-server \ && apk add libxrender \ && apk add libxtst \ && apk add libxi \ && apk add ttf-dejavu \ && rm -rf /var/cache/apk/*

Adding fontconfig did not solve the NPE. Instead I had to add a font package (here I added ttf-dejavu).

karianna commented 3 years ago

Closing this issue in favor of a more specific one for Alpine since this appears to be resolved for all other platforms. If you have a specific docker image of ours that does not work, please raise a separate issue.

ygordaudt commented 3 years ago

Não consegui fazer funcionar apenas com a solução alternativa descrita por @jcoetzee . Tive que fazer um softlink de algumas bibliotecas adicionais também para deixar o JVM feliz.

Solução alternativa completa (testado com adoptopenjdk/openjdk8-openj9:jdk8u202-b08_openj9-0.12.1-alpinee adoptopenjdk/openjdk11:jdk-11.0.2.9-alpine):

RUN apk add --no-cache fontconfig
RUN ln -s /usr/lib/libfontconfig.so.1 /usr/lib/libfontconfig.so && \
    ln -s /lib/libuuid.so.1 /usr/lib/libuuid.so.1 && \
    ln -s /lib/libc.musl-x86_64.so.1 /usr/lib/libc.musl-x86_64.so.1
ENV LD_LIBRARY_PATH /usr/lib

It worked perfectly for me. You rock!

Tested on adoptopenjdk/openjdk11:alpine-jre

mattpsvreis commented 1 year ago

Sorry to re-open this issue, but it was never mentioned the following image: amazoncorretto:11-alpine-jdk.

The same stack trace as the OP happens when using the autoSizeColumn() function from the Sheet class that was generated by the createSheet() function from the HSSFWorkbook class from the package org.apache.poi.hssf.usermodel.HSSFWorkbook while running in a Docker container that uses amazoncorretto:11-alpine-jdk as the image for Java, using the Spring Boot Framework.

After digging I stumbled upon many 'fixes', including this GitHub Issue, but all suggested fixes didn't work. The same stack trace continues to happen.

Further help would be appreciated!

ReillyBrogan commented 1 year ago

Sorry to re-open this issue, but it was never mentioned the following image: amazoncorretto:11-alpine-jdk.

Amazon Corretto is a completely different build of the JDK than the AdoptOpenJDK builds (now known as Adoptium), and is supported by a completely different vendor (Amazon).

I don't know what support resources Corretto has, but you should utilize them instead.

mattpsvreis commented 1 year ago

Sorry to re-open this issue, but it was never mentioned the following image: amazoncorretto:11-alpine-jdk.

Amazon Corretto is a completely different build of the JDK than the AdoptOpenJDK builds (now known as Adoptium), and is supported by a completely different vendor (Amazon).

I don't know what support resources Corretto has, but you should utilize them instead.

Figured as much, but posted it here just in case someone passes by this popular GitHub issue can see that I mentioned it in a different thread, and also stated that I had the same issue but with a different JDK!

Also, if anyone here happens to have a light, it'd be appreciated. But I'm not expecting much truthfully.