Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4510477

lookupPrintServices on win9x crashes if there's an HP OfficeJet 600 installed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.1
    • 1.4.0
    • client-libs
    • 2d
    • hopper
    • x86
    • windows_98

      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)
      ======================================================================

            jgodinez Jennifer Godinez (Inactive)
            prr Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: