sgerrand / alpine-pkg-glibc

A glibc compatibility layer package for Alpine Linux
2.05k stars 280 forks source link

Oracle JDK11.0.5 crashed in apline+glibc latest version #129

Closed menghuxiashan closed 4 years ago

menghuxiashan commented 4 years ago

My Dockerfile:

FROM alpine:latest
RUN apk --no-cache add ca-certificates wget && \
    wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
    wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk && \
    wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-bin-2.30-r0.apk && \
    apk add glibc-2.30-r0.apk && \
    apk add glibc-bin-2.30-r0.apk

RUN mkdir -p /usr/java/
ADD jdk-11.0.5_linux-x64_bin.tar.gz /usr/java/
ENV JAVA_HOME=/usr/java/jdk-11.0.5
ENV PATH ${PATH}:${JAVA_HOME}/bin

when enter alpine-jdk container and input "java -version", infos:

/ # java -version
java version "11.0.5" 2019-10-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)
[thread 11 also had an error]

 A fatal error has been detected by the Java Runtime Environment:

  SIGSEGV (0xb) at pc=0x00007f6e6aa66ab1, pid=6, tid=21

 JRE version: Java(TM) SE Runtime Environment (11.0.5+10) (build 11.0.5+10-LTS)
 Java VM: Java HotSpot(TM) 64-Bit Server VM (11.0.5+10-LTS, mixed mode, tiered, compressed oops, 1 gc, linux-amd64)
 Problematic frame:
 C  [libc.so.6+0x11dab1][thread 12 also had an error]

 Core dump will be written. Default location: Core dumps may be processed with "/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e %P %I %h" (or dumping to //core.6)
 An error report file with more information is saved as:
 //hs_err_pid6.log
[thread 9 also had an error]
[thread 16 also had an error]
[thread 13 also had an error]
[thread 7 also had an error]

 If you would like to submit a bug report, please visit:
   http://bugreport.java.com/bugreport/crash.jsp

Aborted (core dumped)

Is there any problem in my Dockfile ?

sgerrand commented 4 years ago

Apologies for the delayed reply! This issue is caused by zlib symbols remaining in the executable. If you have a version of zlib.so which was compiled by glibc, then the issue is fixed.

diff --git a/Dockerfile b/Dockerfile
index 16ec3ef..82b2aec 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,6 +6,14 @@ RUN apk --no-cache add ca-certificates wget && \
     apk add glibc-2.30-r0.apk && \
     apk add glibc-bin-2.30-r0.apk

+WORKDIR /tmp
+RUN wget http://mirror.f4st.host/archlinux/core/os/x86_64/zlib-1:1.2.11-4-x86_64.pkg.tar.xz -O ./libz.tar.xz && \
+    tar -xf ./libz.tar.xz && \
+    cp /tmp/usr/lib/libz.so.1.2.11 /usr/glibc-compat/lib/libz.so.1.2.11 && \
+    rm -fr /tmp/usr /tmp/libz.tar.xz
+WORKDIR /
+RUN /usr/glibc-compat/sbin/ldconfig
+
 RUN mkdir -p /usr/java/
 ADD jdk-11.0.5_linux-x64_bin.tar.gz /usr/java/
 ENV JAVA_HOME=/usr/java/jdk-11.0.5
$ docker build . --pull --tag issue-129
Sending build context to Docker daemon    180MB
Step 1/10 : FROM alpine:latest
latest: Pulling from library/alpine
Digest: sha256:b276d875eeed9c7d3f1cfa7edb06b22ed22b14219a7d67c52c56612330348239
Status: Image is up to date for alpine:latest
 ---> a187dde48cd2
Step 2/10 : RUN apk --no-cache add ca-certificates wget &&     wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub &&     wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk &&     wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-bin-2.30-r0.apk &&     apk add glibc-2.30-r0.apk &&     apk add glibc-bin-2.30-r0.apk
 ---> Using cache
 ---> d6e160de90f4
Step 3/10 : WORKDIR /tmp
 ---> Running in 965efa6c4390
Removing intermediate container 965efa6c4390
 ---> 1783f00b579c
Step 4/10 : RUN wget http://mirror.f4st.host/archlinux/core/os/x86_64/zlib-1:1.2.11-4-x86_64.pkg.tar.xz -O ./libz.tar.xz &&     tar -xf ./libz.tar.xz &&     cp /tmp/usr/lib/libz.so.1.2.11 /usr/glibc-compat/lib/libz.so.1.2.11 &&     rm -fr /tmp/usr /tmp/libz.tar.xz
 ---> Running in 4af34f80d44c
--2020-04-01 15:43:24--  http://mirror.f4st.host/archlinux/core/os/x86_64/zlib-1:1.2.11-4-x86_64.pkg.tar.xz
Resolving mirror.f4st.host... 144.76.111.189, 2a01:4f8:192:61b4::5003
Connecting to mirror.f4st.host|144.76.111.189|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 83444 (81K) [application/octet-stream]
Saving to: './libz.tar.xz'

     0K .......... .......... .......... .......... .......... 61%  723K 0s
    50K .......... .......... .......... .                    100%  101M=0.07s

2020-04-01 15:43:25 (1.15 MB/s) - './libz.tar.xz' saved [83444/83444]

Removing intermediate container 4af34f80d44c
 ---> 89dcfdcf92a2
Step 5/10 : WORKDIR /
 ---> Running in ce7605e10d1b
Removing intermediate container ce7605e10d1b
 ---> 61e35aa08f99
Step 6/10 : RUN /usr/glibc-compat/sbin/ldconfig
 ---> Running in a85b095830c5
/usr/glibc-compat/sbin/ldconfig: /usr/glibc-compat/lib/ld-linux-x86-64.so.2 is not a symbolic link

Removing intermediate container a85b095830c5
 ---> b8edeb70d11e
Step 7/10 : RUN mkdir -p /usr/java/
 ---> Running in f28dfbd5f9c6
Removing intermediate container f28dfbd5f9c6
 ---> 73928af33133
Step 8/10 : ADD jdk-11.0.5_linux-x64_bin.tar.gz /usr/java/
 ---> 7903df118872
Step 9/10 : ENV JAVA_HOME=/usr/java/jdk-11.0.5
 ---> Running in 3c1769e17e67
Removing intermediate container 3c1769e17e67
 ---> 6a410684c27b
Step 10/10 : ENV PATH ${PATH}:${JAVA_HOME}/bin
 ---> Running in 4c94c3e26d46
Removing intermediate container 4c94c3e26d46
 ---> a9c58358a159
Successfully built a9c58358a159
Successfully tagged issue-129:latest
$ docker run --rm issue-129 java -version
java version "11.0.5" 2019-10-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)