Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8073858

jps, jstat et al when run as root does not show full info for processes != root

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • None
    • 7u75
    • core-svc
    • x86_64
    • linux

    Description

      FULL PRODUCT VERSION :
      java version "1.7.0_75"
      Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux hostname 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Before 7u75, java processes running as non-root user would show up correctly in jps output, when jps is run as root. Now they don't.

      In my example I have a cassandra process running as the cassandra user. If I run 'jps' as the cassandra user, the process shows up as expected, but if I run 'jps' as the root user, all I get is:

      # jps
      9063 Jps
      13926 -- process information unavailable

      Stracing the jps program, I see:

      # strace -f jps -v 2>&1|grep /tmp/hsperfdata
      [pid 9064] open("/tmp/hsperfdata_root", O_RDONLY|O_NOFOLLOW) = 3
      [pid 9064] open("/tmp/hsperfdata_root", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 4
      [pid 9064] mkdir("/tmp/hsperfdata_root", 0755) = -1 EEXIST (File exists)
      [pid 9064] lstat("/tmp/hsperfdata_root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
      [pid 9064] open("/tmp/hsperfdata_root", O_RDONLY|O_NOFOLLOW) = 3
      [pid 9064] open("/tmp/hsperfdata_root", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 4
      [pid 9064] stat("/tmp/hsperfdata_root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
      [pid 9064] open("/tmp/hsperfdata_root", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 5
      [pid 9064] stat("/tmp/hsperfdata_root/9063", {st_mode=S_IFREG|0600, st_size=32768, ...}) = 0
      [pid 9064] access("/tmp/hsperfdata_root/9063", R_OK) = 0
      [pid 9064] stat("/tmp/hsperfdata_cassandra", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
      [pid 9064] open("/tmp/hsperfdata_cassandra", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 5
      [pid 9064] stat("/tmp/hsperfdata_cassandra/13926", {st_mode=S_IFREG|0600, st_size=32768, ...}) = 0
      [pid 9064] access("/tmp/hsperfdata_cassandra/13926", R_OK) = 0
      [pid 9064] open("/tmp/hsperfdata_root", O_RDONLY|O_NOFOLLOW) = 6
      [pid 9064] open("/tmp/hsperfdata_root", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 7
      [pid 9064] lstat("/tmp/hsperfdata_root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
      [pid 9064] open("/tmp/hsperfdata_cassandra", O_RDONLY|O_NOFOLLOW <unfinished ...>
      [pid 9064] open("/tmp/hsperfdata_13926", O_RDONLY <unfinished ...>
      [pid 9064] unlink("/tmp/hsperfdata_root/9063") = 0

      Since jps is running as the root user, there is obviously no permission problem reading /tmp/hsperfdata_cassandra.

      Notice how jps is mysteriously trying to open /tmp/hsperfdata_13926, where 13926 is the pid of the cassandra server.

      /tmp/hsperfdata_cassandra/13926 does exist and contains data (if I cat it, it has binary info which looks relevant).

      # stat /tmp/hsperfdata_cassandra/13926
        File: `/tmp/hsperfdata_cassandra/13926'
        Size: 32768 Blocks: 64 IO Block: 4096 regular file
      Device: fe01h/65025d Inode: 393272 Links: 1
      Access: (0600/-rw-------) Uid: ( 1002/cassandra) Gid: ( 1002/cassandra)
      Access: 2015-02-05 09:20:52.773098573 +0000
      Modify: 2015-02-05 09:58:40.896527532 +0000
      Change: 2015-02-05 09:58:40.896527532 +0000
       Birth: -

      The cassandra process is running on the 7u75 JDK as well.

      Bug also seems to appear in openjdk 7u75: https://bugs.launchpad.net/ubuntu/+source/openjdk-6/+bug/1417962?comments=all

      This obviously mess up monitoring tools and make it harder to use program such as jstack (also affected).


      REGRESSION. Last worked in version 6u45


      REPRODUCIBILITY :
      This bug can be reproduced always.

      Attachments

        Issue Links

          Activity

            People

              csahu Cheleswer Sahu (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: