JDK-4997835 : RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.4.2_03,5.0,6u11
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2004-02-20
  • Updated: 2022-10-04
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u18Fixed 7Fixed hs15Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Java on Windows will only generate a crash dump, when running with 
-XX:+ShowMessageErrorOnBox. Any other windows application however, will 
create a crash dump upon each and every crash.

Running Java with -XX:+ShowMessageErrorOnBox does yield a windows dump 
file, however it suppresses the creation of an hs_err_pid.log file. On 
Unix (Solaris and Linux), both a crash dump (core file) and an hs_err_pid.log 
file are generated at one time.

So, the proposal is:
Is it possible to get both crash dump and hs_err_pid.log file on Windows
platforms at one time (possibly without using -XX:+ShowMessageErrorOnBox).
The crash dump file will be generated depending on Dr Watson being installed.

Here is an example: Please find attached a complete example.

It is supposed than Dr Watson is installed.

1. native testcase
1.1 Testcase
% more Hello.c

#include <stdio.h>
int main() {
  char str1[]="Sample string";
  char * str2= NULL;
  strcpy(str2, str1);

1.2. run native testcase 
It will crash and generate a crash dump.
Compile with Borland's bcc32 (for example):

C:> C:\bcc32 -IC:\bcc55\include -LC:\bcc55\include -ehello.exe hello.c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
Warning W8065 Hello.c 10: Call to function 'strcpy' with no prototype in function main
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland



[ hello.exe has generated errors and will be closed by Windows.
  You will need to restart the program.

  An error log is being created.


drwtsn32.log and user.dmp has been created.

C:>more drwtsn32.log

Microsoft (R) Windows 2000 (TM) Version 5.00 DrWtsn32
Copyright (C) 1985-1999 Microsoft Corp. All rights reserved.

Application exception occurred:
        App:  (pid=856)
        When: 2/20/2004 @ 13:37:44.542
        Exception number: c0000005 (access violation)

*----> System Information <----*
        Computer Name: SUN-DE9D5C19522
        User Name: Administrator
        Number of Processors: 1
        Processor Type: x86 Family 15 Model 2 Stepping 7
        Windows 2000 Version: 5.0
        Current Build: 2195
        Service Pack: 3
        Current Type: Uniprocessor Free
        Registered Organization: Sun Microsystems
        Registered Owner: Sun Microsystems

*----> Task List <----*
[ ... ]
 856 hello.exe

3. Try a JNI testcase based on the above example
3.1 Compile

C:>set JAVA_HOME=C:\j2sdk1.4.2

C:>set PATH=C:\bcc55\bin;C:\bcc55\bin;C:\bcc55\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem

C:>set INCLUDES=-IC:\bcc55\include -IC:\j2sdk1.4.2\include -IC:\j2sdk1.4.2\include\win32

C:>C:\j2sdk1.4.2\bin\javac HelloWorld.java

C:>C:\j2sdk1.4.2\bin\javah -jni HelloWorld

C:>bcc32 -tWD -IC:\bcc55\include -IC:\j2sdk1.4.2\include -IC:\j2sdk1.4.2\include\win32 -LC:\bcc55\lib HelloWorldImp.c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
Warning W8065 HelloWorldImp.c 13: Call to function 'strcpy' with no prototype in function Java_HelloWorld_displayHelloWorld
Warning W8057 HelloWorldImp.c 15: Parameter 'env' is never used in function Java_HelloWorld_displayHelloWorld
Warning W8057 HelloWorldImp.c 15: Parameter 'obj' is never used in function Java_HelloWorld_displayHelloWorld
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland


3.2 Run without -XX:+ShowMessageBoxOnError

C:>c:\j2sdk1.4.2\bin\java HelloWorld

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x182
[ ... ]

 Please note that *no* crash dump file is be created.

3.3 Run with -XX:+ShowMessageBoxOnError

C:>c:\j2sdk1.4.2\bin\java -XX:+ShowMessageBoxOnError HelloWorld

[ An error has occurred. Do you want to debug the problem ?
  [Yes]  [No]

 Choose "No" and you will get an hs_err_pid.log file.

 Choose "Yes" and you will get:

[ java.exe has generated errors and will be closed by Windows.
  You will need to restart the program.

  An error log is being created.


 Both a crash dump file and a drwtsn32.log file will be generated, but *no*
 hs_err_pid.log file.

There is a comment that should have been public but currently isn't, so reproducing the information here: I [Steve Bohne] am including some info about how WER/Dr. watson works in modern Windows, we may need this information when crafting a fix for this and related issues. From "Microsoft® Windows® Internals, Fourth Edition: Microsoft Windows Server™ 2003, Windows XP, and Windows 2000" by By Mark E. Russinovich, David A. Solomon Chapter 3 - Trap Dispatching - Exception Dispatching (http://book.itzero.com/read/microsoft/0507/Microsoft.Press.Microsoft.Windows.Internals.Fourth.Edition.Dec.2004.internal.Fixed.eBook-DDU_html/0735619174/ch03lev1sec1.html) "... When an unhandled exception is caught by the unhandled exception filter (described in the previous section), an initial check is made to see whether or not to initiate Windows Error Reporting. If the registry value HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Auto is set to zero or the Debugger string contains the text "Drwtsn32", the unhandled exception filter loads \Windows\System32\Faultrep.dll into the failing process and calls its ReportFault function. ReportFault then checks the error-reporting configuration stored under HKLM\Software\Microsoft\PCHealth\ErrorReporting to see whether this process crash should be reported, and if so, how. In the normal case, ReportFault creates a process running \Windows\System32\Dwwin.exe, which displays a message box announcing the process crash along with an option to submit the error report to Microsoft...." "... If the Send Error Report button is clicked, the error report (a minidump and a text file with details on the DLL version numbers loaded in the process) is sent to Microsoft's online crash analysis server, Watson.Microsoft.com. (Unlike kernel mode system crashes, in this situation there is no way to find out whether a solution is available at the time of the report submission.) Then the unhandled exception filter creates a process to run the system-defined debugger (normally Drwtsn32.exe), which by default creates its own dump file and log entry. Unlike Windows 2000, the dump file is a minidump, not a full dump. So, in the case where a full process memory dump is needed to debug a failing application, you can change the configuration of Dr. Watson by running it with no command-line arguments as described in the previous section."

EVALUATION I'm marking this fixed. If there are specific suggestions on improvement or what isn't working now, we can open new bugs. hotspot build number available is shot in the dark... If hotspot splits to a master hs14 workspace, I want to check this in there too, but I think I need a new CR number for that anyway.

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/dabd8d202164

EVALUATION See Poonam's webblog at http://blogs.sun.com/poonam/entry/windows_crash_dumps_for_java When we go into the debugger through ShowMessageBoxOnError, the frame shown is that of the os::message_box and below, the windows exception handler. The frame that crashed is not in this stack trace. If you use -XX:+UseOSErrorReporting, the top frame shown in the debugger (if attached) is the frame that caused the crash, but during unwind to find the exception handler (the topLevelExceptionFilter is called for each level until the handler is found) the vmError function report_and_die() is called each time. At some point, it reports it's had too many errors and dies. A partial fix is to determine that this error message is redundant and not print it if UseOSErrorReporting is true. With the partial fix, the debugger is attached (via windows message box on Vista) for each level of call until the exception handler (after you exit the debugger, it pops up again). At least at every level the crashing frame is on the top of stack and has not been unwound. I haven't figured out how to prevent this from happening and only have the debuggeer break into the Java process for the crash and not for calling topLevelExceptionFilter for each level of the call stack. With -XX:+UseOSErrorReporting if you have your registry keys set to get a dr watson or other dump, we will print out the hs_err_pid.log file completely and then have Windows create the crash dump file. So this is works the way we want with UseOSErrorReporting. The reason that UseOSErrorReporting is not default is that this also causes WER to send Microsoft an error report and we don't currently get and process them. We also would like to add more information to send along with WER and on Vista there are new APIs for doing so. This other work is tracked under bug 6394477.

EVALUATION I think I fixed this with the error handling putback I did (just found it deleting old mail).