JDK-6704262 : Printing to shared printer crashes JVM
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0u15
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2008-05-19
  • Updated: 2010-07-29
  • Resolved: 2008-07-07
Related Reports
Relates :  
Description
Printing to a shared windows printer from a java program crashes JVM.

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x768599c4, pid=5676, tid=2904
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_15-b04 mixed mode, sharing)
# Problematic frame:
# C  [MSCTF.dll+0x99c4]
#
# An error report file with more information is saved as hs_err_pid5676.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

$ cat hs_err_pid5676.log
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x768599c4, pid=5676, tid=2904
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_15-b04 mixed mode, sharing)
# Problematic frame:
# C  [MSCTF.dll+0x99c4]
#

---------------  T H R E A D  ---------------

Current thread (0x032a0a00):  JavaThread "AWT-Windows" daemon [_thread_in_native, id=2904]

siginfo: ExceptionCode=0xc0000005, writing address 0x001f00bc

Registers:
EAX=0x001f0004, EBX=0x00000000, ECX=0x00151d30, EDX=0x00b10501
ESP=0x036af888, EBP=0x036af8a8, ESI=0x00141568, EDI=0x80004005
EIP=0x768599c4, EFLAGS=0x00010202

Top of Stack: (sp=0x036af888)
0x036af888:   00b1052f 0014b380 00000000 768567c8
0x036af898:   00151d30 036c007c 00000000 0014b380
0x036af8a8:   036af8d4 76859948 036af8c0 036af950
0x036af8b8:   00000113 00000000 76856704 0013de10
0x036af8c8:   00b1052f 00000000 00000000 036af900
0x036af8d8:   76a61a10 005e0364 00000113 00000001
0x036af8e8:   00000000 00000113 dcbaabcd 00000000
0x036af8f8:   036af950 00000113 036af978 76a61ae8

Instructions: (pc=0x768599c4)
0x768599b4:   0f 84 96 c5 02 00 85 c0 7c 21 8b 01 85 c0 74 1b
0x768599c4:   81 a0 b8 00 00 00 ff ff ff 7f 8d 4d ec e8 41 ce


Stack: [0x03670000,0x036b0000),  sp=0x036af888,  free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [MSCTF.dll+0x99c4]
C  [MSCTF.dll+0x9948]
C  [USER32.dll+0x21a10]
C  [USER32.dll+0x21ae8]
C  [USER32.dll+0x22a47]
C  [USER32.dll+0x22a98]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  sun.awt.windows.WToolkit.eventLoop()V+0
j  sun.awt.windows.WToolkit.run()V+69
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x003f76c0 JavaThread "DestroyJavaVM" [_thread_blocked, id=1152]
  0x032ae078 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=5172]
  0x032a3920 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=4908]
=>0x032a0a00 JavaThread "AWT-Windows" daemon [_thread_in_native, id=2904]
  0x032a0878 JavaThread "AWT-Shutdown" [_thread_blocked, id=440]
  0x00faa538 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3936]
  0x00faa818 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2508]
  0x00fa9bb0 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=4364]
  0x00fa83d0 JavaThread "Finalizer" daemon [_thread_blocked, id=5720]
  0x00fa7608 JavaThread "Reference Handler" daemon [_thread_blocked, id=4568]

Other Threads:
  0x00fa64f8 VMThread [id=5900]
  0x00f99bf0 WatcherThread [id=3160]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 576K, used 373K [0x23260000, 0x23300000, 0x23740000)
  eden space 512K,  60% used [0x23260000, 0x232ad690, 0x232e0000)
  from space 64K, 100% used [0x232e0000, 0x232f0000, 0x232f0000)
  to   space 64K,   0% used [0x232f0000, 0x232f0000, 0x23300000)
 tenured generation   total 1408K, used 521K [0x23740000, 0x238a0000, 0x27260000)
   the space 1408K,  37% used [0x23740000, 0x237c24a8, 0x237c2600, 0x238a0000)
 compacting perm gen  total 8192K, used 715K [0x27260000, 0x27a60000, 0x2b260000)
   the space 8192K,   8% used [0x27260000, 0x27312cc0, 0x27312e00, 0x27a60000)
    ro space 8192K,  67% used [0x2b260000, 0x2b7c2410, 0x2b7c2600, 0x2ba60000)
    rw space 12288K,  47% used [0x2ba60000, 0x2c00f748, 0x2c00f800, 0x2c660000)

Dynamic libraries:
0x00400000 - 0x0040d000         C:\Program Files\Java\jdk1.5.0_15\bin\java.exe
0x77ac0000 - 0x77bde000         C:\Windows\system32\ntdll.dll
0x77790000 - 0x77868000         C:\Windows\system32\kernel32.dll
0x76380000 - 0x7643f000         C:\Windows\system32\ADVAPI32.dll
0x77920000 - 0x779e3000         C:\Windows\system32\RPCRT4.dll
0x77870000 - 0x7791a000         C:\Windows\system32\MSVCRT.dll
0x6d740000 - 0x6d8de000         C:\Program Files\Java\jdk1.5.0_15\jre\bin\client\jvm.dll
0x76a40000 - 0x76ade000         C:\Windows\system32\USER32.dll
0x76970000 - 0x769bb000         C:\Windows\system32\GDI32.dll
0x749d0000 - 0x74a03000         C:\Windows\system32\WINMM.dll
0x775b0000 - 0x776f4000         C:\Windows\system32\ole32.dll
0x77c70000 - 0x77cfc000         C:\Windows\system32\OLEAUT32.dll
0x74990000 - 0x749c8000         C:\Windows\system32\OLEACC.dll
0x77c50000 - 0x77c6e000         C:\Windows\system32\IMM32.DLL
0x76850000 - 0x76917000         C:\Windows\system32\MSCTF.dll
0x76130000 - 0x7615c000         C:\Windows\system32\apphelp.dll
0x77c10000 - 0x77c19000         C:\Windows\system32\LPK.DLL
0x767d0000 - 0x7684d000         C:\Windows\system32\USP10.dll
0x77be0000 - 0x77c0d000         C:\Windows\system32\WS2_32.dll
0x765c0000 - 0x765c6000         C:\Windows\system32\NSI.dll
0x761e0000 - 0x76201000         C:\Windows\system32\NTMARTA.DLL
0x76920000 - 0x76969000         C:\Windows\system32\WLDAP32.dll
0x762e0000 - 0x762e7000         C:\Windows\system32\PSAPI.DLL
0x761c0000 - 0x761d1000         C:\Windows\system32\SAMLIB.dll
0x6d300000 - 0x6d308000         C:\Program Files\Java\jdk1.5.0_15\jre\bin\hpi.dll
0x6d710000 - 0x6d71c000         C:\Program Files\Java\jdk1.5.0_15\jre\bin\verify.dll
0x6d380000 - 0x6d39d000         C:\Program Files\Java\jdk1.5.0_15\jre\bin\java.dll
0x6d730000 - 0x6d73f000         C:\Program Files\Java\jdk1.5.0_15\jre\bin\zip.dll
0x6d070000 - 0x6d1dd000         C:\Program Files\Java\jdk1.5.0_15\jre\bin\awt.dll
0x71da0000 - 0x71de1000         C:\Windows\system32\WINSPOOL.DRV
0x75080000 - 0x750bf000         C:\Windows\system32\uxtheme.dll
0x76ae0000 - 0x775ae000         C:\Windows\system32\shell32.dll
0x765e0000 - 0x76635000         C:\Windows\system32\SHLWAPI.dll
0x750c0000 - 0x75254000         C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6000.16386_none_5d07289e07e1d100\comctl32.dll
0x6d2b0000 - 0x6d300000         C:\Program Files\Java\jdk1.5.0_15\jre\bin\fontmanager.dll
0x6d540000 - 0x6d553000         C:\Program Files\Java\jdk1.5.0_15\jre\bin\net.dll
0x759b0000 - 0x759eb000         C:\Windows\system32\mswsock.dll
0x75a10000 - 0x75a16000         C:\Windows\System32\wship6.dll
0x6d560000 - 0x6d569000         C:\Program Files\Java\jdk1.5.0_15\jre\bin\nio.dll
0x769c0000 - 0x76a34000         C:\Windows\system32\COMDLG32.DLL
0x73b80000 - 0x73c06000         C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6000.16386_none_87e0cb09378714f1\COMCTL32.dll
0x6b6e0000 - 0x6b799000         C:\Windows\system32\spool\DRIVERS\W32X86\3\unidrvui.dll
0x75a20000 - 0x75a28000         C:\Windows\system32\VERSION.dll
0x6b620000 - 0x6b6db000         C:\Windows\system32\spool\DRIVERS\W32X86\3\mxdwdrv.dll
0x66800000 - 0x66a7b000         C:\Windows\system32\spool\DRIVERS\W32X86\3\CNMUI98.DLL
0x75810000 - 0x75815000         C:\Windows\system32\MSIMG32.dll
0x70760000 - 0x707c2000         C:\Windows\system32\mscms.dll
0x76230000 - 0x7624e000         C:\Windows\system32\USERENV.dll
0x76210000 - 0x76224000         C:\Windows\system32\Secur32.dll
0x66400000 - 0x6648a000         C:\Windows\system32\spool\DRIVERS\W32X86\3\CNMDR98.DLL
0x67000000 - 0x6701c000         C:\Windows\system32\spool\DRIVERS\W32X86\3\CNMCP98.DLL

VM Arguments:
java_command: printhello.HelloWorldPrinter
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Intel\DMIX;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\9.0\DLLShared;C:\PTS\Java\jdk\j2re1.4.2_16\bin
USERNAME=sun
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 11, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows Vista Build 6000

CPU:total 2 (cores per cpu 2, threads per core 1) family 6 model 15 stepping 11, cmov, cx8, fxsr, mmx, sse, sse2

Memory: 4k page, physical 2097151k(1961536k free), swap 4194303k(4194303k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_15-b04) for windows-x86, built on Feb  9 2008 01:07:28 by "java_re" with MS VC++ 6.0


On 1.5.0_11, same crash was seen, but there was slightly different crash.

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x768569e6, pid=5172, tid=5176
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_11-b03 mixed mode, sharing)
# Problematic frame:
# C  [MSCTF.dll+0x69e6]
#
# An error report file with more information is saved as hs_err_pid5172.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [MSCTF.dll+0x69e6]
C  [MSCTF.dll+0x9ae4]
C  [MSCTF.dll+0x91cd]
C  [MSCTF.dll+0x9bec]
C  [MSCTF.dll+0x8e6f]
C  [IMM32.DLL+0x3472]
C  [USER32.dll+0x199cd]
C  [USER32.dll+0x18e4c]
C  [USER32.dll+0x18de1]
C  [USER32.dll+0x19132]
C  [USER32.dll+0x21a10]
C  [USER32.dll+0x21ae8]
C  [USER32.dll+0x21c03]
C  [USER32.dll+0x23656]
C  [ntdll.dll+0x60e6e]
C  [USER32.dll+0x1c5cd]
...

The test program is very simple.  I selected to print 3 copies on the printer dialog.
Same operation works just fine for a local printer.  

$ cat printhello/HelloWorldPrinter.java
package printhello;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.print.*;

public class HelloWorldPrinter implements Printable, ActionListener {


    public int print(Graphics g, PageFormat pf, int page) throws
                                                        PrinterException {

        if (page > 0) { /* We have only one page, and 'page' is zero-based */
            return NO_SUCH_PAGE;
        }

        /* User (0,0) is typically outside the imageable area, so we must
         * translate by the X and Y values in the PageFormat to avoid clipping
         */
        Graphics2D g2d = (Graphics2D)g;
        g2d.translate(pf.getImageableX(), pf.getImageableY());

        /* Now we perform our rendering */
        g.drawString("Hello world!", 100, 100);

        /* tell the caller that this page is part of the printed document */
        return PAGE_EXISTS;
    }

    public void actionPerformed(ActionEvent e) {
         PrinterJob job = PrinterJob.getPrinterJob();
         job.setPrintable(this);
         boolean ok = job.printDialog();
         if (ok) {
             try {
                  job.print();
             } catch (PrinterException ex) {
                 ex.printStackTrace();
                 System.out.println("Cause:");
                 ex.getCause().printStackTrace();
              /* The job did not successfully complete */
             }
         }
    }

    public static void main(String args[]) {

        UIManager.put("swing.boldMetal", Boolean.FALSE);
        JFrame f = new JFrame("Hello World Printer");
        f.addWindowListener(new WindowAdapter() {
           public void windowClosing(WindowEvent e) {System.exit(0);}
        });
        JButton printButton = new JButton("Print Hello World");
        printButton.addActionListener(new HelloWorldPrinter());
        f.add("Center", printButton);
        f.pack();
        f.setVisible(true);
    }
}

Comments
EVALUATION The crash doesn't occur in 5.0u20. It looks like it has been fixed along with 6574633. Closing as not reproducible anymore.
07-07-2008