JDK-8073858 : jps, jstat et al when run as root does not show full info for processes != root
  • Type: Bug
  • Component: core-svc
  • Sub-Component: tools
  • Affected Version: 7u75
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2015-02-05
  • Updated: 2015-06-22
  • Resolved: 2015-06-22
Related Reports
Duplicate :  
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.


Comments
This is being worked in JDK-8075773
22-06-2015

Test Result [Linux AMD64 system]: For JDK 7u75 b17 : jpse@gbr10229:~/ws/ababroy/jdk1.7.0_75/bin$ jps 5291 Jps 5279 TestJdmc jpse@gbr10229:~/ws/ababroy/jdk1.7.0_75/bin$ strace -f jps -v 2>&1|grep /tmp/hsperfdata_jpse [pid 5317] open("/tmp/hsperfdata_jpse", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 [pid 5317] lstat("/tmp/hsperfdata_jpse", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5317] mkdir("/tmp/hsperfdata_jpse", 0755) = -1 EEXIST (File exists) [pid 5317] lstat("/tmp/hsperfdata_jpse", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5317] open("/tmp/hsperfdata_jpse/5316", O_RDWR|O_CREAT|O_TRUNC, 0600) = 3 [pid 5317] stat("/tmp/hsperfdata_jpse", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5317] open("/tmp/hsperfdata_jpse", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 9 [pid 5317] stat("/tmp/hsperfdata_jpse/5279", {st_mode=S_IFREG|0600, st_size=32768, ...}) = 0 [pid 5317] access("/tmp/hsperfdata_jpse/5279", R_OK) = 0 [pid 5317] stat("/tmp/hsperfdata_jpse/5316", {st_mode=S_IFREG|0600, st_size=32768, ...}) = 0 [pid 5317] access("/tmp/hsperfdata_jpse/5316", R_OK) = 0 [pid 5317] open("/tmp/hsperfdata_jpse", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC <unfinished ...> [pid 5317] lstat("/tmp/hsperfdata_jpse", <unfinished ...> [pid 5317] lstat("/tmp/hsperfdata_jpse/5279", {st_mode=S_IFREG|0600, st_size=32768, ...}) = 0 [pid 5317] lstat("/tmp/hsperfdata_jpse", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5317] open("/tmp/hsperfdata_jpse/5279", O_RDONLY) = 9 [pid 5317] unlink("/tmp/hsperfdata_jpse/5316") = 0 jpse@gbr10229:~/ws/ababroy/jdk1.7.0_75/bin$ jpse@gbr10229:~/ws/ababroy/jdk1.6.0_45/bin$ strace -f jps -v 2>&1|grep /tmp/hsperfdata_5279---[pid] jpse@gbr10229:~/ws/ababroy/jdk1.6.0_45/bin$ For JDK 6u45 b61 : jpse@gbr10229:~/ws/ababroy/jdk1.6.0_45/bin$ jps 5553 Jps 5479 TestJdmc jpse@gbr10229:~/ws/ababroy$ cd jdk1.6.0_45/bin/ jpse@gbr10229:~/ws/ababroy/jdk1.6.0_45/bin$ strace -f jps -v 2>&1|grep /tmp/hsperfdata_jpse [pid 5541] open("/tmp/hsperfdata_jpse", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 [pid 5541] lstat("/tmp/hsperfdata_jpse", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5541] mkdir("/tmp/hsperfdata_jpse", 0755) = -1 EEXIST (File exists) [pid 5541] lstat("/tmp/hsperfdata_jpse", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5541] open("/tmp/hsperfdata_jpse/5540", O_RDWR|O_CREAT|O_TRUNC, 0600) = 3 [pid 5541] stat("/tmp/hsperfdata_jpse", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5541] open("/tmp/hsperfdata_jpse", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 9 [pid 5541] stat("/tmp/hsperfdata_jpse/5540", {st_mode=S_IFREG|0600, st_size=32768, ...}) = 0 [pid 5541] access("/tmp/hsperfdata_jpse/5540", R_OK) = 0 [pid 5541] stat("/tmp/hsperfdata_jpse/5479", {st_mode=S_IFREG|0600, st_size=32768, ...}) = 0 [pid 5541] access("/tmp/hsperfdata_jpse/5479", R_OK) = 0 [pid 5541] open("/tmp/hsperfdata_jpse", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC <unfinished ...> [pid 5541] lstat("/tmp/hsperfdata_jpse", <unfinished ...> [pid 5541] lstat("/tmp/hsperfdata_jpse/5479", <unfinished ...> [pid 5541] lstat("/tmp/hsperfdata_jpse", <unfinished ...> [pid 5541] open("/tmp/hsperfdata_jpse/5479", O_RDONLY) = 9 [pid 5541] unlink("/tmp/hsperfdata_jpse/5540") = 0 jpse@gbr10229:~/ws/ababroy/jdk1.6.0_45/bin$ jpse@gbr10229:~/ws/ababroy/jdk1.6.0_45/bin$ strace -f jps -v 2>&1|grep /tmp/hsperfdata_5479---[pid] jpse@gbr10229:~/ws/ababroy/jdk1.6.0_45/bin$ For 8u60 ea b04 : jpse@gbr10229:~/ws/ababroy/jdk1.8.0_60/bin$ jps 5969 Jps 5957 TestJdmc jpse@gbr10229:~/ws/ababroy/jdk1.8.0_60/bin$ strace -f jps -v 2>&1|grep /tmp/hsperfdata_jpse/ [pid 5995] open("/tmp/hsperfdata_jpse/5994", O_RDWR|O_CREAT|O_TRUNC, 0600) = 3 [pid 5995] stat("/tmp/hsperfdata_jpse/5957", {st_mode=S_IFREG|0600, st_size=32768, ...}) = 0 [pid 5995] access("/tmp/hsperfdata_jpse/5957", R_OK) = 0 [pid 5995] stat("/tmp/hsperfdata_jpse/5994", {st_mode=S_IFREG|0600, st_size=32768, ...}) = 0 [pid 5995] access("/tmp/hsperfdata_jpse/5994", R_OK) = 0 [pid 5995] lstat("/tmp/hsperfdata_jpse/5957", <unfinished ...> [pid 5995] open("/tmp/hsperfdata_jpse/5957", O_RDONLY <unfinished ...> [pid 5995] unlink("/tmp/hsperfdata_jpse/5994") = 0 jpse@gbr10229:~/ws/ababroy/jdk1.8.0_60/bin$ jpse@gbr10229:~/ws/ababroy/jdk1.8.0_60/bin$ strace -f jps -v 2>&1|grep /tmp/hsperfdata_5957---[pid] jpse@gbr10229:~/ws/ababroy/jdk1.8.0_60/bin$
04-03-2015

Test Result [Linux AMD64 system]: For JDK 7u75 b13 : [root@olinux ~]# jps 5299 TestJdmc 5370 Jps [root@olinux ~]# strace -f jps -v 2>&1|grep /tmp/hsperfdata_root [pid 5386] open("/tmp/hsperfdata_root", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 [pid 5386] lstat("/tmp/hsperfdata_root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5386] mkdir("/tmp/hsperfdata_root", 0755) = -1 EEXIST (File exists) [pid 5386] lstat("/tmp/hsperfdata_root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5386] open("/tmp/hsperfdata_root/5385", O_RDWR|O_CREAT|O_TRUNC, 0600) = 3 [pid 5386] stat("/tmp/hsperfdata_root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5386] open("/tmp/hsperfdata_root", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 10 [pid 5386] stat("/tmp/hsperfdata_root/5385", <unfinished ...> [pid 5386] access("/tmp/hsperfdata_root/5385", R_OK) = 0 [pid 5386] open("/tmp/hsperfdata_root", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 11 [pid 5386] lstat("/tmp/hsperfdata_root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5386] unlink("/tmp/hsperfdata_root/5385") = 0 [root@olinux ~]# strace -f jps -v 2>&1|grep /tmp/hsperfdata_5299 [root@olinux ~]# For JDK 8u40 b24 : [oracle@olinux bin]$ jps 5645 Jps 5299 TestJdmc [oracle@olinux bin]$ strace -f jps -v 2>&1|grep /tmp/hsperfdata_root [pid 5670] stat("/tmp/hsperfdata_root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [pid 5670] open("/tmp/hsperfdata_root", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 10 [pid 5670] open("/tmp/hsperfdata_root", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 11 [pid 5670] lstat("/tmp/hsperfdata_root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 [oracle@olinux bin]$ strace -f jps -v 2>&1|grep /tmp/hsperfdata_5299 [oracle@olinux bin]$
04-03-2015