Skip to content

jmap not happy on alpine #76

Closed
Closed
@devinrsmith

Description

@devinrsmith

We ran into an issue today where we needed to take a heap dump (jmap). But it wasn't working.

Image was java:openjdk-8u92-jdk-alpine.

$ docker exec server1_v3_1 ps aux
PID   USER     TIME   COMMAND
    1 root       1:54 java -server -verbose:gc ...
  121 root       0:00 ps aux

$ docker exec server1_v3_1 jmap -dump:live,format=b,file=/data/dump.map 1
1: Unable to get pid of LinuxThreads manager thread

Here's the source of the error: http://code.metager.de/source/xref/openjdk/jdk8/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c#255

We suspect it might be because alpine is using musl instead of glibc.

jmap works in java:openjdk-8u91-jdk.

Activity

niloc132

niloc132 commented on May 25, 2016

@niloc132

Other tools that don't work: jstack, jinfo, jhat.

paranoid945

paranoid945 commented on Aug 30, 2016

@paranoid945

Not working in openjdk 7 neither.
does any openjdk engineer watching this issue?

yosifkit

yosifkit commented on Sep 1, 2016

@yosifkit
Member

This seems related: gliderlabs/docker-alpine#11.

michaelzg

michaelzg commented on Jan 15, 2017

@michaelzg

Tried what @yosifkit linked.

Installed glibc as suggested by sgerrand in https://github.com/sgerrand/alpine-pkg-glibc/issues/1 and still no luck:

/opt # apk info | grep glibc
glibc
glibc-bin

/opt # java -version
openjdk version "1.8.0_111-internal"
OpenJDK Runtime Environment (build 1.8.0_111-internal-alpine-r0-b14)
OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)

/opt # ps aux
PID   USER     TIME   COMMAND
    1 root       8:38 java ...-jar ...
  303 root       0:00 /bin/sh
  421 root       0:00 ps aux

/opt # jmap -dump:format=b,file=heap.bin 1
1: Unable to get pid of LinuxThreads manager thread

Docker image: 8u111-jdk-alpine

tianon

tianon commented on Jan 27, 2017

@tianon
Member

Indeed -- I don't think there's much we can do about this. 😞

dkolog

dkolog commented on Jan 31, 2017

@dkolog

I noticed that too. This happens because your java process PID is 1.
I use the same setup (alpine + glibc + jmap) and it works well if the PID is not 1 (when bash scripts forks the java process)

yosifkit

yosifkit commented on Jan 31, 2017

@yosifkit
Member

If you keep bash as PID 1, you'd no longer get signals from docker stop and docker kill (without having to write traps). With docker 1.13 you can use --init to have docker put in tini as PID 1; it'll forward signals and reap zombies.

dkolog

dkolog commented on Feb 1, 2017

@dkolog

@yosifkit you are absolutely right.
@devinrsmith I was able to get heap/thread dump from PID 1 using Oracle's JDK.

elyscape

elyscape commented on Feb 20, 2017

@elyscape

This may be a result of the debug symbols not being installed in the image. See comment 9 on this issue or comment 15 on this issue.

sgerrand

sgerrand commented on Jun 20, 2017

@sgerrand

Installed glibc as suggested by @sgerrand

For those arriving late to the party, like me, this issue appears to be unrelated to the underlying libc implementation.

sitnik

sitnik commented on Jul 5, 2017

@sitnik

I have to use docker 1.12 and don't know if '--init' will be used in Kubernetes, so I solved this issue by wrapping java process in shell script and adding trap for TERM signal. At least jmap now works for me.

tianon

tianon commented on Jan 3, 2018

@tianon
Member

Closing, since this appears to be solved by either using Docker's --init flag, or adding something like tini / dumb-init to images which suffer from this problem. 👍

28 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tianon@sgerrand@niloc132@sitnik@jhmartin

        Issue actions

          jmap not happy on alpine · Issue #76 · docker-library/openjdk