JDK-8189674 : -Djava.io.tmpdir doesn't work for generating hs_error files
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 8,9,10
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2017-10-18
  • Updated: 2017-10-23
  • Resolved: 2017-10-23
Related Reports
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_144"
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux 4.4.74-92.38-default
 x86_64 x86_64 x86_64 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
When Java process starts it creates .java_pid<provide PID> file in /tmp folder, can we set to use different folder than /tmp

it is already specified with -Djava.io.tmpdir for user defined path, but this path is not taken into consideration and always it creates in /tmp folder

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
start any java process and the file will be created in /tmp folder


REPRODUCIBILITY :
This bug can be reproduced always.


Comments
For reasons that David Holmes stated in the comments, we are closing this WNF. For its internal use, the VM doesn't use the java.io.tmpdir property.
23-10-2017

The JVM doesn't use the -Djava.io.tmpdir setting. We have tried in the past (JDK-6938627) and it isn't workable (JDK-7009828). The tools and the VM that is the target of the tools have to agree on well known file locations and that can't happen if the "tmp" location can be customized. While that specific issue doesn't apply to the generation of the error file, it complicates things too much if we have to have different "tmp" locations for different files. We provide -XX:ErrorFile to allow specific control of the error file (which falls back to the "tmp" location if the specified location can not be written (or the target file exists).
22-10-2017

This is a functionality of the JVM, assigning it to the appropriate team for evaluation.
20-10-2017

Ok I could able to verify this issue on 10 ea b26 below are my observations //Restrict write permission to the current directory, let hs_error file created under /tmp directory -sh-4.2$ chmod 555 ./ sh-4.2$ /scratch/fairoz/JAVA/jdk-10-ea+26/bin/java -XX:+CrashOnOutOfMemoryError -Xmx10m Wrapper Aborting due to java.lang.OutOfMemoryError: Java heap space # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (debug.cpp:298), pid=93775, tid=93776 # fatal error: OutOfMemory encountered: Java heap space # # JRE version: Java(TM) SE Runtime Environment (10.0+26) (build 10-ea+26) # Java VM: Java HotSpot(TM) 64-Bit Server VM (10-ea+26, mixed mode, tiered, compressed oops, g1 gc, linux-amd64) # Core dump will be written. Default location: Core dumps may be processed with "/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e" (or dumping to /scratch/fairoz/JI/9051242/core.93775) # # An error report file with more information is saved as: # /tmp/hs_err_pid93775.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # Aborted (core dumped) //Provide different path in -Djava.io.tmpdir=/scratch/fairoz/ to force JVM to generate hs_error file in -Djava.io.tmpdir directory instead of /tmp -sh-4.2$ /scratch/fairoz/JAVA/jdk-10-ea+26/bin/java -Djava.io.tmpdir=/scratch/fairoz/ -XX:+CrashOnOutOfMemoryError -Xmx10m Wrapper Aborting due to java.lang.OutOfMemoryError: Java heap space # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (debug.cpp:298), pid=94089, tid=94090 # fatal error: OutOfMemory encountered: Java heap space # # JRE version: Java(TM) SE Runtime Environment (10.0+26) (build 10-ea+26) # Java VM: Java HotSpot(TM) 64-Bit Server VM (10-ea+26, mixed mode, tiered, compressed oops, g1 gc, linux-amd64) # Core dump will be written. Default location: Core dumps may be processed with "/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e" (or dumping to /scratch/fairoz/JI/9051242/core.94089) # # An error report file with more information is saved as: # /tmp/hs_err_pid94089.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # Aborted (core dumped) You could see file is still created under /tmp directory
20-10-2017

The problem here is if user current directory is full/doesn't have write permission hs_error file will be written to /tmp directory unless you have specified different path through " -Djava.io.tmpdir". Lets consider you have specified -Djava.io.tmpdir path, and hs_error file need to be created under -Djava.io.tmpdir specified path (provided that no permission on current directory/current directory is full). This particular scenario i am unable to reproduce. Don't get confused with -XX:ErrorFile i tried all possible scenario's.
20-10-2017

I am confused by the bug details, there are 3 things being described: 1. The creation of temp files using the Java APIs, this should be controlled by -Djava.io.tmpdir, this is created by the java.io APIs and its implemented in the JDK. 2. .java_pid being created by the VM see http://hg.openjdk.java.net/jdk9/dev/hotspot/file/b756e7a2ec33/src/os/bsd/dtrace/jvm_dtrace.c#l176 3. again -XX:ErrorFile is handled by the VM. So which is it ?
19-10-2017

Could not verify the exact scenario for making crash and verifying file generated in /tmp folder. Meanwhile found another issue -XX:ErrorFile doesn't work JDK-8189672
19-10-2017

Verified "-Djava.io.tmpdir" works properly by executing the attached program. == without specifying "-Djava.io.tmpdir" java_re/jdk/8u152/fcs/b16/binaries/linux-x64/bin/java CreateTemp Temp file : /tmp/temp-name6468653566581176500.log //File created in /temp directory With specifying "-Djava.io.tmpdir" java_re/jdk/8u152/fcs/b16/binaries/linux-x64/bin/java -Djava.io.tmpdir=/home/fmatte CreateTemp Temp file : /home/fmatte/temp-name8185659887887174796.log // File created in the directory specified through -Djava.io.tmpdir option
19-10-2017