JDK-4510477 : lookupPrintServices on win9x crashes if there's an HP OfficeJet 600 installed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_98
  • CPU: x86
  • Submitted: 2001-10-03
  • Updated: 2002-02-21
  • Resolved: 2002-02-21
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.
Other
1.4.1 hopperFixed
Related Reports
Duplicate :  
Relates :  
Description
The simple program below crashes the merlin (1.4) JDK on windows 98 (not NT)
if you have an HP OfficeJet 600 installed.

import javax.print.*;

public class GDP {

   public static void main(String args[]) {
 
       PrintService defSvc = PrintServiceLookup.lookupDefaultPrintService();
       System.out.println("default = " + defSvc);
    }
}


you get a GPF as follows :-
> This program has performed an illegal operation and will be shut down.
> If the problem persists, contact the program vendor.
> JAVA caused a general protection fault
> in module HPOWIN01.DLL at 0002:000005e3.
> Registers:
> EAX=0e2f0000 CS=2997 EIP=000005e3 EFLGS=00000246
> EBX=000181e8 SS=0e2f ESP=000081e0 EBP=000081e0
> ECX=0000ffff DS=51ff ESI=00009cff FS=0000
> EDX=0000016f ES=0000 EDI=00000000 GS=0000
> Bytes at CS:EIP:
> f2 ae f7 d1 75 01 49 91 8b fa 5d cb 00 55 8b ec
> Stack dump:
> 41b581ee 0000441f 4b770000 85d09cff 90271f12 00000080 84a20000
> 05d70e2f 016f9cff
> 006a32b4 006a32cc 006a32d8 006a32d8 00000018 00000002 00000064

Name: ddT132432			Date: 11/29/2001


java version "1.4.0-beta3"
Java (TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)

Synopsis. general protection fault when printing with HP 722C printer on Win 98SE

When attempting to print (on my HP DeskJet 722C) the runtime crashes on the
call to pjob.print():

O.S. : Windows 98SE
Printer Driver:  HP DeskJet 720C Series Version 10.3 

JAVA caused a general protection fault
in module HPFWIN14.DLL at 0016:00008019.
Registers:
EAX=74af0000 CS=3277 EIP=00008019 EFLGS=00000297
EBX=00010000 SS=8d7f ESP=000081d6 EBP=000081da
ECX=0000ffff DS=77ff ESI=00000000 FS=0000
EDX=00000000 ES=0000 EDI=0000024f GS=0000
Bytes at CS:EIP:
26 80 78 ff 3a 75 01 4e 66 ff 76 0c 06 53 8b c6
Stack dump:
000077af b2da85b4 008074af 00000000 8d7f84a0 34ff06c7 fd2e024f 18406d33
010c006a f2640000 53ce0057 c7246d38 c7200ac0 002a0ac0 02090000 e4eb6d3b

Not pretty!

Code to reproduce follows.  This was a problem for me in beta2 (your review ID
132734) but you were not able to reproduce it.  It looks very similar to bugs
4530428 and 4470606 that describe similar things happening under NT,
especially with HP printers!  Hmmmmmmmm!  Sounds like a funky interaction with
HP printer drivers to me...but what do I know?

The following snippet reproduces the problem on my system:

import java.awt.*;
import java.awt.event.*;
import java.awt.List;
import java.io.*;
import java.util.*;
import java.awt.print.*;
import javax.swing.*;
import javax.swing.filechooser.*;
import javax.swing.event.*;

public class PrintTest
{  public static void main(String [] args)
   {  PrinterJob pjob = PrinterJob.getPrinterJob();
      PageFormat pageFormat = pjob.defaultPage();
      pageFormat.setOrientation(pageFormat.LANDSCAPE);
      Paper paper = new Paper();
      double pw = 8.5 * 72;
      double pl =  11 * 72;
      double pm = 0.5 * 72;
      paper.setSize(pw, pl);
      paper.setImageableArea(pm, pm, pw - 2*pm, pl - 2*pm);
      pageFormat.setPaper(paper);

      pjob.setPrintable(new CalendarPrint(), pageFormat);
            
      if (pjob.printDialog())
      {  System.out.println("Just before print ");
         try
         {  pjob.print();
         }
         catch(PrinterException pe)
         {  System.out.println("Cannot print schedule.  Error = "+pe);
         }
      }
   }
}


class CalendarPrint implements Printable
{  public CalendarPrint()
   {  int i;
   
      for (i = 0 ; i < MAX_PAGES ; ++i)
      last_day[i] = UNDEFINED;
   }
   
   public int print(Graphics g, PageFormat pf, int p_index) throws PrinterException
   {  int d_of_wk, d_of_mth, dow;
      
      int line_y, cur_x, week_height, font_ht, font_descent;
      int y;
      
      int day_width;
       
      int cur_y, left_margin;
      
      int d_offset = 0;
       
      int p_height, p_width;
     
      if (p_index >= MAX_PAGES || (p_index > 0 && last_day[p_index-1] == LAST_PAGE))
         return NO_SUCH_PAGE;
            
      Font f = new Font("Serif", Font.PLAIN,  7);

      left_margin = (int)pf.getImageableX();
            
      g.setFont(f);
      g.setColor(Color.black);

      FontMetrics fm = g.getFontMetrics(f);
      font_descent = fm.getDescent();
      font_ht = fm.getAscent()+font_descent;
       
      cur_x = left_margin;
      cur_y = (int)pf.getImageableY() + font_ht + 5;
      line_y = cur_y - font_ht;
             
      if (p_index == 0)
      {  g.drawString("Schedule for ", cur_x, cur_y);
         cur_y += font_ht+5;
      }
      return PAGE_EXISTS;
   }

/*private Calendar month;
*/
private int[] last_day = new int[MAX_PAGES];

private static final int LAST_PAGE = -2;
private static final int UNDEFINED = -1;
private static final int MAX_PAGES = 5;
}
(Review ID: 136291)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: hopper FIXED IN: hopper INTEGRATED IN: hopper
14-06-2004

WORK AROUND Install the generic HP DeskJet printer driver. That reportedly works fine.
11-06-2004

PUBLIC COMMENTS An HP OfficeJet 600 can cause a crash on printer lookup on windows 98.
10-06-2004

SUGGESTED FIX Pass in the port string (or anything apart from NULL) to the DeviceCapabilities routine. Alternatively report it to HP as a driver bug. ###@###.### 2001-10-03 ============================
03-10-2001

EVALUATION The crash happens on a call to DeviceCapabilities where the JDK passes NULL for port. This supposedly legal on win32. It is suspected that the HP OfficeJet 600 printer is a port of a win16 API (ie windows 3.0) driver where GDI used that value and the driver may have expected it too. This is the only printer driver on which the problem has been reported. ###@###.### 2001-10-03 ============================= Fix: added port in calls to DeviceCapabilities. ###@###.### 2002-02-04
03-10-2001