JDK-4234839 : Java 2D requires windows system fonts to be in a windows system directory
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.2.1,1.3.0
  • Priority: P5
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_98,windows_nt
  • CPU: x86
  • Submitted: 1999-05-03
  • Updated: 2000-08-07
  • Resolved: 2000-08-07
Related Reports
Relates :  
Description

Name: dbT83986			Date: 05/03/99


I've submitted this bug once before, about a week ago. (id: 57417 - see original bug report below)
I've been told, essentially, that "it's not a bug because it works on our system".
It also works on my fellow coworkers' systems (NT and Solaris).
I'm trying to find out what is different about my system/setup that causes this crash.

It is reproduceable: Every time I run any swing app under 1.2 that displays (or attempts
to display) a font, I get this crash. Any swing app (see Test.java I've attached) that
displays text does this, including the SwingSet demo.
The crash always occurs when a setVisible() or show() is called.
In the SwingSet demo, the crash is when the progress JFrame's show() is called.
In my Test.java, it's on the "t.setVisible(true);" line.

The SwingSet demo works on my machine with jdk1.1.8 and swing 1.0.3.
So does Test.java.
The SwingSet demo and my Test also work on fellow coworkers' NT and Solaris machines under jdk 1.2.
The only problem is my NT system with jdk 1.2.

I've uninstalled/reinstalled countless times, always to encounter the same results.
I'm using the MSVCRT.DLL that comes with the jvm/jre.

I've downloaded the community source to the jvm, and have debugged it to the point
of the exact line in the exact files where the problem occurs.

To restate my problem again: (see original bug report at bottom)

call stack given by MS VC++ 5.0 when I CANCEL/debug now with compiled debug version of the jvm:
Strike::getGlyphAdvanceX(Strike * const 0x00000000, int 87674197) line 203 + 76 bytes
Strike::getCharAdvanceX(Strike * const 0x00000000, unsigned short 43643) line 197
Java_sun_awt_font_NativeFontWrapper_getAdvance(JNIEnv_ * 0x10046542, _jclass * 0x00000000, _jobject * 0x0012ecb4, unsigned short 29924, _jdoubleArray * 0x0000004c, unsigned char 236, unsigned char 0) line 247 + 12 bytes
_sysInvokeNative() line 163
@ILT+1830(_Java_sun_awt_font_NativeFontWrapper_getAdvance@28) address 0x0537172b

Java_sun_awt_font_NativeFontWrapper_getAdvance( ... ) (lines 246-247 of share\native\sun\awt\font\FontWrapper.cpp):
    Strike& theStrike = fo->getStrike(tx, isAntiAliased, usesFractionalMetrics);
    retval = theStrike.getCharAdvanceX(theChar);

After line 246 executes, the value of theStrike is null (0x00000000). When a method is called
on the null pointer in line 247, the jvm crashes.

The crash actually occurs in
Strike::getGlyphAdvanceX( ...) (line 203 of share\native\sun\awt\font\Strike.cpp):
    theStrike = compositeStrikeForGlyph(glyphCode);


Can you offer any assistance more than "it works here so it's not a bug" ?
Uninstalling / reinstalling hasn't helped.

=============================
REVIEW NOTE 5/2/99 - User responded with additional information


I can cause this crash with CLASSPATH empty, and with nothing in my path but the jdk.

My partial directory structure:
  h:\jdk
    sun1.1.8     - installed from jdk1_1_8-win.exe
    sun1.2       - installed from jdk12-win32.exe, jdk1_2_1-win.exe (depending on whether my last install was 1.2 or 1.2.1. currently 1.2)
    swing-1.0.3  - unzipped from swing103.zip
I'm also unable to run swing11-win32-install.exe -- I get a screen that has "Introduction" on the top right, then the virtual machine crashes in the same way all the other crashes happen.
(I'm guessing InstallAnywhere uses 1.2 internally(?) -- it GPF's no matter what I set my path and CLASSPATH to.)

Also, notice in my Test.java:
//    label = new JLabel(""); // this works in 1.1 and 1.2
    label = new JLabel("a"); // this works in 1.1, crashes in 1.2
If I have no text for the label, my Test.java runs fine under 1.2.

To answer your question:
"When you mention things work with JDK1.1.8 and Swing 1.0.3 - are you trying to run 1.1.8w/1.0.3 demos under 1.2?"
I get:
    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/java/swing/JPanel
        at java.lang.ClassLoader.defineClass0(Native Method)
        ...
which is to be expected.

----------
case 1:
PATH=h:\jdk\sun1.1.8\bin (that's it, no windows directories, windows/system directories, nothing else. I have tried it with winnt and winnt/system32 in the path, with same results.)
CLASSPATH=.;h:\jdk\sun1.1.8\lib\classes.zip
SWING_HOME=H:\jdk\swing-1.0.3

SwingSet demo:
cd H:\jdk\swing-1.0.3\examples\SwingSet
runnit.bat
    result: all OK, everything runs fine

my Test.java:
cd \swingtest\1.1
javac -classpath ".;h:\jdk\sun1.1.8\lib\classes.zip;h:\jdk\swing-1.0.3\swingall.jar" Test.java
    result: no compilation errors
java -classpath ".;h:\jdk\sun1.1.8\lib\classes.zip;h:\jdk\swing-1.0.3\swingall.jar" Test
    result: all OK, everything runs fine

----------
case 2:
PATH=h:\jdk\sun1.2\bin (that's it, no windows directories, windows/system directories, nothing else. I have tried it with winnt and winnt/system32 in the path, with same results.)
CLASSPATH=
SWING_HOME=

SwingSet demo:
cd H:\jdk\sun1.2\demo\jfc\SwingSet
java SwingSet
    result: virtual machine crashes (see original message)

my Test.java:
cd \swingtest\1.2
javac Test.java
    result: no compilation errors
java Test
    result: virtual machine crashes (see original message)


----------
Thank you for your help thus far.


----------------- Test.java -------------------
import java.awt.*;
import java.awt.event.*;

//1.1
//import com.sun.java.swing.*;
//1.2
import javax.swing.*;

class Test extends JFrame implements ActionListener
{
  JLabel label;

  Test()
  {
    super("Test");
    setSize(400, 200);
    addWindowListener(new ExitMonitor());

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.LEFT));

//    label = new JLabel(""); // this works in 1.1 and 1.2
    label = new JLabel("a"); // this works in 1.1, crashes in 1.2
    panel.add(label);

    getContentPane().add(panel, BorderLayout.NORTH);
  }

  public void actionPerformed(ActionEvent ae)
  {
  }

  public static void main(String args[])
  {
    System.out.println("start");
    Test t = new Test();
    System.out.println("Test t = new Test();");
    t.setVisible(true);
    System.out.println("t.setVisible(true);");
  }
}

class ExitMonitor extends WindowAdapter
{
  public void windowClosing(WindowEvent e)
  {
    Window w = e.getWindow();
    w.setVisible(false);
    w.dispose();
    System.exit(0);
  }
}



----------------- Original Bug Report-------------------

id : 57417
category : java
subcategory : classes_swing
type : bug
synopsis : java.exe / fontmanager.dll crash when running SwingSet demo
description : from a command prompt in the demo\jfc\SwingSet directory,
  type "java SwingSet"
produces the dialog:
--- java.exe - Application Error ---
The instruction at "0x5021cdc4" reference memory at "0x0000000c".
The memory could not be "read".
Click on OK to terminate the application
Click on CANCEL to debug the application

call stack given by MS VC++ 5.0 when I CANCEL/debug:
FONTMANAGER! 5021cdc4()
FONTMANAGER! 5021cd55()
FONTMANAGER! 5020aa7b()
JVM! 50466542()
FONTMANAGER! 501f172b()

>java -version
java version "1.2.1"
Classic VM (build JDK-1.2.1-A, native threads)
>java -fullversion
java full version "JDK-1.2.1-A"

I'm using NT workstation 4.0 Service Pack 4.0.
I also have installed (in different directories):
(h: is a local drive, not network)
  Java 2           - h:\jdk\sun1.2
  Java 2 runtime   - h:\jre\sun1.2
  jdk 1.1.8        - h:\jdk\sun1.1.8
  IBM's jdk 1.1.7a - h:\jdk\ibm1.1.7
  IBM's Visual Age for Java 2.0

None of these directories are in my environment "path"
or CLASSPATH when I get this error.

I've noticed these files in my \WINNT\SYSTEM32 directory,
and have no idea what they are for or if they have any
bearing on this:
  99.03.27   6:59p         24,064  java.exe
  96.10.15   5:40a         39,424  javacom.dll
  99.01.25   5:05a        192,784  javacypt.dll
  99.01.25   5:05a        139,536  javaee.dll
  99.01.25   4:15a         11,403  javaperm.hlp
  99.01.25   5:35a         34,576  javaprxy.dll
  99.01.25   6:30a        365,328  javart.dll
  99.01.25   4:15a         21,444  javasec.hlp
  99.01.25   4:47a          7,315  javasup.vxd
  99.03.27   6:59p         24,576  javaw.exe

I have not tried recompiling the class files.

If I run a class that is strictly AWT, all seems to be OK.

I've searched the Bug Parade, and noticed there were a few
somewhat related references. This is English, not Japanese, on
NT, not win95, using jdk 1.2.1, not a beta.

This same error occurred with jdk 1.2 (though I can't vouch for
the exact same hex addresses in fontmanager.dll when it crashed),
so I downloaded 1.2.1 hoping it might be fixed. But same result.
comments : (company - PSI Technologies , email - ###@###.###)
This bug causes application to crash.
workaround : 
suggested_val : 
cust_name : Mitchell Ackermann
cust_email : ###@###.###
company : PSI Technologies
release : 1.2.1
hardware : x86
OSversion : win_nt_4.0
status : Deleted
delReason : User Error
priority : 4
bugtraqID : 0
dateCreated : 1999-04-23 10:39:16.0
dateEvaluated : 1900-01-01 00:00:00.0
(Review ID: 57707) 
======================================================================

Comments
WORK AROUND REVIEW NOTE 5/29/99 - User sent additional information. By experimenting, I've found more very useful information you may be able to add to this. I've also found a workaround. I'm using WinNT, but I believe this applies to all of win3.1/95/98/NT) You can install truetype fonts either to the "windows" directory (in NT: x:\<winnt dir>\fonts), or you can install them with just a pointer to the file without copying the font to the windows directory. In NT, from Start->Settings->Control Panel->Fonts, go to File->Install New Font. If, when installing fonts, you select the "Copy fonts to Fonts folder" checkbox, the files get copied to the winnt\fonts directory (which, for some unknown Microsoft reasoning, has the System attribute set.) If this checkbox is not checked, somehow (through the registry or something) the system simply uses a pointer to the original font file without copying it into the windows directory. You can also "uninstall" fonts from the windows directory (which deletes them from the windows directory), and "install" a reference to them somewhere else. This is what I've done. I've removed all truetype fonts from my winnt\fonts directory. ALL TrueType fonts, including: Arial (normal, Bold, Bold Italic, and Italic) Courier New (normal, Bold, Bold Italic, and Italic) Symbol Times New Roman (normal, Bold, Bold Italic, and Italic) Wingdings I copied them out of this directory to another directory, "uninstalled" them, then "installed" a "reference" to them in this second directory. (Why? I multi-boot between different OS's, and use all the same physical font files between all OS's.) What I found in experimenting today was the following: - If I any one (or more) of the 14 above listed fonts are installed with a copy existing in the winnt\fonts directory, the virtual machine no longer crashes. - If none of these 14 fonts physically exist in the winnt\fonts directory, the VM crashes. - If any or all of these fonts are installed with a reference to them, but they don't actually physically exist in the winnt\fonts directory, the VM crashes. And, none of this applies to the pre- 1.2 VM's, only the 1.2 VM. So, steps to recreate the problem: 1) uninstall the 14 above listed fonts from the windows\fonts directory (install them elsewhere with a reference if you like) 2) run SwingSet demo As a workaround, I've simply installed the Arial font in my winnt\fonts directory.
11-06-2004

EVALUATION This seems more like a 2D problem than swing, I'm reassigning to 2D. scott.violet@eng 1999-05-05 User wants something a bit unusual, and I'm in no rush to implement this. 2D needs to find the fonts. If MS treats the registry locations as an API they won't change, then perhaps we can program to it, but its a big change for small benefit. We already look in %WINDIR%\FONTS and %WINDIR%\SYSTEM\FONTS which will cover almost all fonts on the system except for a few that are registered by applications and ones which are moved elsewhere as in this case. ========================== Not clear that this is an appropriate change so it will not be implemented in any planned release. phil.race@eng 2000-08-07 =========================
07-08-2000