jstack - well-known file is not secure

Michał Šrajer picture Michał Šrajer · Feb 1, 2012 · Viewed 48.1k times · Source

I am running tomcat 5.5 on x86_64 CentOS 5.7 using 32-bit Oracle Java 1.6.0.

JVM process used by tomcat has 6421 pid. Tomcat is working fine.

When run jstack it fails with:

[root@mybox ~]# jstack 6421
6421: well-known file is not secure

To get any reasonable output, I need to use force option:

[root@mybox ~]# jstack -F 6421
Attaching to process ID 6421, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 17.0-b16
Deadlock Detection:

No deadlocks found.
(...)

The questions are:

  1. what does the error message "well-known file is not secure" mean?
  2. what is the "well-known" file?
  3. why/when does the jstack command not work without a force option?

Thanks in advance.

Answer

Roger Lindsjö picture Roger Lindsjö · Feb 1, 2012

This is probably due to the file in /tmp used to communicate with the process having different permissions than the one the jstack gets. The file in question is /tmp/hsperfdata_$USER/$PID.

Don't know why it works with -F as the man page just says "Force a stack dump when 'jstack [-l] pid' does not respond."