United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 4997835 RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
4997835 : RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError

Details
Type:
Enhancement
Submit Date:
2004-02-20
Status:
Closed
Updated Date:
2009-02-11
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
hotspot
OS:
windows_xp,windows_2000
Sub-Component:
runtime
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.2_03,5.0,6u11
Fixed Versions:
hs15

Related Reports
Backport:
Backport:
Duplicate:

Sub Tasks

Description
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);
    return;
}
%

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
Hello.c:
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

C:>


C:>hello

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

  An error log is being created.

 [OK]
]

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
C:>


3. Try a JNI testcase based on the above example
------------------------------------------------
3.1 Compile
-----------
C:>make

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
HelloWorldImp.c:
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

C:>


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
722BA
Function=Java_HelloWorld_displayHelloWorld+0x1082
Library=C:\test\HelloWorldImp.dll
[ ... ]

 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.

 [OK]
]

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

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/dabd8d202164
                                     
2008-12-23
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.
                                     
2008-12-23
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.
                                     
2008-12-18
EVALUATION

I think I fixed this with the error handling putback I did (just found it deleting old mail).
                                     
2007-08-16



Hardware and Software, Engineered to Work Together