Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java SIGSEGV error when running from docker

I have no experience in Java and I can run my code successfully from the development. But only when I built the project and runs it from docker, I got an error like this.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00000000000200a6, pid=1, tid=0x00007ff7227f9b10
#
# JRE version: OpenJDK Runtime Environment (8.0_212-b04) (build 1.8.0_212-b04)
# Java VM: OpenJDK 64-Bit Server VM (25.212-b04 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 3.12.0
# Distribution: Custom build (Sat May  4 17:33:35 UTC 2019)
# Problematic frame:
# C  0x00000000000200a6
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /opt/my_project/hs_err_pid1.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   https://icedtea.classpath.org/bugzilla
#

I have followed the error message to use ulimit -c unlimited by adding it in the docker command: docker run --ulimit core=-1 --env-file -t my_project but still not helping and got another similar error

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00000000000200a6, pid=1, tid=0x00007eff79c95b10
#
# JRE version: OpenJDK Runtime Environment (8.0_212-b04) (build 1.8.0_212-b04)
# Java VM: OpenJDK 64-Bit Server VM (25.212-b04 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 3.12.0
# Distribution: Custom build (Sat May  4 17:33:35 UTC 2019)
# Problematic frame:
# C  0x00000000000200a6
#
# Core dump written. Default location: /opt/my_project/core or core.1
#
# An error report file with more information is saved as:
# /opt/my_project/hs_err_pid1.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   https://icedtea.classpath.org/bugzilla
#

Here's my Dockerfile

FROM openjdk:8-jre-alpine
ADD ./build/libs/ /opt/my_project
RUN apk update && apk add --no-cache libc6-compat && ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
WORKDIR /opt/my_project
CMD ["java", "-jar", "my_project.jar"]

I have no idea if the error is related to the java environment or the docker or something else. Appreciate the help!

EDIT:

The error occurred when running on this line:

Logging logging = LoggingOptions.newBuilder().setCredentials(googleCredentials).setProjectId(projectId).build().getService();
like image 454
rahmathd Avatar asked Oct 19 '25 14:10

rahmathd


2 Answers

This is solved by using the debian based image instead of alpine.

Thanks to the folks in the comment section!

like image 54
rahmathd Avatar answered Oct 22 '25 03:10

rahmathd


Just documenting our own experience here, which corroborates rahmathd's answer.

We were using an alpine-based Amazon Corretto:

FROM amazoncorretto/amazoncorretto:11-alpine-jre

RUN apk --update --no-cache add tzdata && apk add --no-cache libstdc++ && apk add --no-cache libc6-compat && ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2

ENV TZ Asia/Tokyo

One of the following two messages accompanied the crash that happened every time when running the app for a couple of seconds.

1)

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fbd3196c5d6, pid=1, tid=60
#
# JRE version: OpenJDK Runtime Environment Corretto-11.0.8.10.1 (11.0.8+10) (build 11.0.8+10-LTS)
# Java VM: OpenJDK 64-Bit Server VM Corretto-11.0.8.10.1 (11.0.8+10-LTS, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C  [ld-musl-x86_64.so.1+0x235d6]  free+0x28
#
# Core dump will be written. Default location: //core
#
# An error report file with more information is saved as:
# //hs_err_pid1.log
[thread 301 also had an error]
[thread 37 also had an error]
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

2)

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Switching to either a Ubuntu and Amazon Linux based Corretto both solved the issue for us as well.

like image 37
Evgeniy Berezovsky Avatar answered Oct 22 '25 04:10

Evgeniy Berezovsky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!