JDK-4780313 : Access violation happens in getPrintJob method in 1.4.x
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0,1.4.1_01
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_98
  • CPU: x86
  • Submitted: 2002-11-18
  • Updated: 2003-07-09
  • Resolved: 2003-07-09
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
When users try to print, access violation occurs and hotspot log has been gotten
only on Windows98/ME.
This seems to happen in getPrintJob method.

REPRODUCE:
 1) Compile the attached sample code
 2) Launshja "java PrintTest"
 3) Click Print button.
    Youo will see the print dilaogue.
 4) Click "OK" button.

RESULTS:
 User reported they got a hotspot log at the above 4) step.
 
     VM    |   result
-----------+-------------
 1.3.1_06  |  Not occur
 1.4.0     |   occur
 1.4.0_01  |   occur
 1.4.0_02  |   occur
 1.4.1     |   occur
 1.4.1_01  |   occur
 1.4.2_b03 |   occur

   OS: windows 98 (Second Edition, Japanese)
   Printer: Fujitsu XL-6100(Page Printer)


However, JPE tried this program and any violation did not occur.

     VM    |   result
-----------+-------------
 1.3.1_06  |  Not occur
 1.4.0_03  |  Not occur
 1.4.1_01  |  Not occur
 1.4.2_b06 |  Not occur

   OS: windows 98 (Second Edition, Japanese)
       Windows ME (Second Edition, Japanese)
   MEM: 384[MB]
   MPU: Pentium IV 1.4[GHz]
   Printers:
     - FujiXerox DocuPrint 400 J (PS printer)
         (Adobe PostScript printer driver 4.5.2(003))
     - EPSON LP8700 (PS and Page Printer)
         (EPSON printer Driver 3.5.8cm)


REQUEST: 
  User suggested the fix and ask SUN STRONGLY to review it !!
  Please evaluate.


NOTE:
 - Please useWindows(Japanese) and Printer which can print Japanese
   character because the sample program includes Japanese String.

ATTACHED FILES:
  - PrintTest.java: Sanple program
  - hs_log : Hotspot log

============================================================================

Comments
EVALUATION =================================== Looks like a duplicate of 4697214 which is fixed in 1.4.2. Can the submitter verify this? Marking incomplete pending information. ###@###.### 2003-06-04 =================================== No response from submitter, closing and marking as duplicate. ###@###.### 2003-07-09 ====================================
04-06-2003

SUGGESTED FIX The followings are suggested fix based on 1.4.1 from Fujitsu. ===> *** src\windows\native\sun\windows\awt_PrintJob.cpp.org --- src\windows\native\sun\windows\awt_PrintJob.cpp *************** *** 3653,3658 **** --- 3653,3664 ---- ::GetPrinter(hPrinter, 2, NULL, 0, &dwBytesNeeded); PRINTER_INFO_2* p2 = (PRINTER_INFO_2*)::GlobalAlloc(GPTR, dwBytesNeeded); + + if (p2 == NULL) { + ::ClosePrinter(hPrinter); + return FALSE; + } + if (::GetPrinter(hPrinter, 2, (LPBYTE)p2, dwBytesNeeded, &dwBytesReturned) == 0) { ::GlobalFree(p2); *************** *** 3659,3673 **** ::ClosePrinter(hPrinter); return FALSE; } - ::ClosePrinter(hPrinter); ! // Allocate a global handle for DEVMODE and copy DEVMODE data. ! HGLOBAL hDevMode = ::GlobalAlloc(GHND, ! (sizeof(*p2-pDevMode) + p2-pDevMode-dmDriverExtra)); ! DEVMODE* pDevMode = (DEVMODE*)::GlobalLock(hDevMode); ! memcpy(pDevMode, p2-pDevMode, sizeof(*p2-pDevMode) ! + p2-pDevMode-dmDriverExtra); ! ::GlobalUnlock(hDevMode); // Compute size of DEVNAMES structure you'll need. // All sizes are WORD as in DEVNAMES structure --- 3665,3738 ---- ::ClosePrinter(hPrinter); return FALSE; } ! DEVMODE *pDevMode = NULL; ! HGLOBAL hDevMode = NULL; ! /* If GetPrinter didn't fill in the DEVMODE, try to get it by calling ! DocumentProperties... ! */ ! if (p2-pDevMode == NULL){ ! LONG bytesNeeded = ::DocumentProperties(NULL, hPrinter, ! pszDeviceName, ! NULL, NULL, 0); ! ! if (bytesNeeded <= 0) { ! ::GlobalFree(p2); ! ::ClosePrinter(hPrinter); ! return FALSE; ! } ! ! hDevMode = ::GlobalAlloc(GHND, bytesNeeded); ! if (hDevMode == NULL) { ! ::GlobalFree(p2); ! ::ClosePrinter(hPrinter); ! return FALSE; ! } ! ! pDevMode = (DEVMODE*)::GlobalLock(hDevMode); ! if (pDevMode == NULL) { ! ::GlobalFree(hDevMode); ! ::GlobalFree(p2); ! ::ClosePrinter(hPrinter); ! return FALSE; ! } ! ! LONG lFlag = ::DocumentProperties(NULL, hPrinter, ! pszDeviceName, ! pDevMode, NULL, ! DM_OUT_BUFFER); ! if (lFlag != IDOK) { ! ::GlobalUnlock(hDevMode); ! ::GlobalFree(hDevMode); ! ::GlobalFree(p2); ! ::ClosePrinter(hPrinter); ! return FALSE; ! } ! ! } else { ! // Allocate a global handle for DEVMODE and copy DEVMODE data. ! hDevMode = ::GlobalAlloc(GHND, ! (sizeof(*p2-pDevMode) + p2-pDevMode-dmDriverExtra)); ! if (hDevMode == NULL) { ! ::GlobalFree(p2); ! ::ClosePrinter(hPrinter); ! return FALSE; ! } ! ! pDevMode = (DEVMODE*)::GlobalLock(hDevMode); ! if (pDevMode == NULL) { ! ::GlobalFree(hDevMode); ! ::GlobalFree(p2); ! ::ClosePrinter(hPrinter); ! return FALSE; ! } ! ! memcpy(pDevMode, p2-pDevMode, ! sizeof(*p2-pDevMode) + p2-pDevMode-dmDriverExtra); ! } ! ! ::GlobalUnlock(hDevMode); ! ::ClosePrinter(hPrinter); // Compute size of DEVNAMES structure you'll need. // All sizes are WORD as in DEVNAMES structure <=== ###@###.### 2002-11-18 =============================================================================
18-11-2002