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

FontMetrics crashes jvm for many-glyph fonts (really!)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.1.4
    • client-libs
    • 2d
    • sparc
    • solaris_2.5.1



      Name: rm29839 Date: 11/25/97


      The JVM will crash when you try to get FontMetrics for a font with
      many glyphs (like a Unicode font, for example)
      This code demonstrates the problem using the jis
      font that you are likely to have on your system.


      Add this to your font.properties file to REALLY GET the jis font:

      ------------------------------------------------
      jis.0=-jis-fixed-medium-r-normal--0-0-75-75-c-0-jisx0208.1983-0
      fontcharset.jis.0=CharToByteUnicode
      fontset.jis.0=-jis-fixed-medium-r-normal--0-0-75-75-c-0-jisx0208.1983-0
      --------------------------------------------------


      now, you can really draw with it

      compile this code:

      -------------------------------------------------

      import java.awt.*;
      import java.awt.event.*;

      // prove that you GOT THE FONT, by drawing with it!!!
      public class FontMetricsCrashProof extends Frame
      {
        Font font;
        public FontMetricsCrashProof ( Font font )
        {
          this.font = font;

          // press this button to crash jvm
          Button boom = new Button ( "Get Font Metrics" );
          boom.addActionListener ( new ActionListener () {
            public void actionPerformed ( ActionEvent e ) {
      getMyFontMetrics ();
            }
          });

          add ( boom, "South" );
          setSize ( 200, 200 );
          show ();
        }

        public void getMyFontMetrics ()
        {
          FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics ( font );
          System.out.println ( "FontMetrics: " + fm );
        }

        // draw the character. If you get a box, or don't see a japanese
        // character, you didn't get the Font!!!!!
        // see notes on changes to font.properties
        public void paint ( Graphics g )
        {
          g.setFont ( font );
          char [] chars = { '\u3021' }; // a Japanese character
          g.drawChars ( chars, 0, 1, 100, 100 );
        }

        public static void main ( String [] args )
        {
          Font font = Font.decode ( args[0] );
          System.out.println ( "Font for " + args[0] + " is " + font );
          FontMetricsCrashProof p = new FontMetricsCrashProof ( font );
        }
      }
      ---------------------------------------------
          
      run it like this:

      java FontMetricsCrashProof jis-plain-16

      -or-

      java FontMetricsCrashProof jis

      and you will see a japanese character from the jis
      font drawn in the frame. If you DON'T see a Japanese
      character, you didn't get the Font!!

      if you run it like this:
      java FontMetricsCrashProof -jis-fixed-medium-r-normal--0-0-75-75-c-0-jisx0208.1983-0

      you WON'T get the font.


      After you are sure you actually have the Font, press the
      'Get Font Metrics' Button to get the FontMetrics
      from the font.
      The jvm will crash in the init method of
      sun.awt.motif.X11FontMetrics

      like this:

      SIGSEGV 11* segmentation violation
              si_signo [11]:SIGSEGV 11* segmentation violation
              si_errno [0]: Error 0
              si_code [1]: SEGV_MAPERR [addr: 0x0]


                 stackbase=EE012000, stackpointer=EE011488

      Full thread dump:
          "AWT-Finalizer" (TID:0xee70780, sys_thread_t:0xedf81de0, state:CW) prio=9
              java.lang.Object.wait(Object.java)
              sun.awt.AWTFinalizer.run(AWTFinalizer.java:48)
          "AWT-Motif" (TID:0xee7049d0, sys_thread_t:0xedfb1de0, state:CW) prio=5
              java.lang.Thread.run(Thread.java)
          "AWT-Input" (TID:0xee7049b0, sys_thread_t:0xedfe1de0, state:CW) prio=5
          "AWT-EventQueue-0" (TID:0xee704998, sys_thread_t:0xee011de0, state:R) prio=5
      *current thread*
              sun.awt.motif.X11FontMetrics.<init>(X11FontMetrics.java:111)
              sun.awt.motif.X11FontMetrics.getFontMetrics(X11FontMetrics.java:259)
              sun.awt.motif.MToolkit.getFontMetrics(MToolkit.java:210)
              FontMetricsCrashProof.getMyFontMetrics(FontMetricsCrashProof.java:27)
              FontMetricsCrashProof$1.actionPerformed(FontMetricsCrashProof.java:16)
              java.awt.Button.processActionEvent(Button.java:254)
              java.awt.Button.processEvent(Button.java:227)
              java.awt.Component.dispatchEventImpl(Component.java:1764)
              java.awt.Component.dispatchEvent(Component.java:1704)
              java.awt.EventDispatchThread.run(EventDispatchThread.java:63)
          "Finalizer thread" (TID:0xee700220, sys_thread_t:0xee2c1de0, state:CW) prio=1
          "Async Garbage Collector" (TID:0xee7001d8, sys_thread_t:0xee2c1de0, state:CW) prio=1
          "Idle thread" (TID:0xee700190, sys_thread_t:0xee3c1de0, state:R) prio=0
          "Clock" (TID:0xee7000d0, sys_thread_t:0xee3f1de0, state:CW) prio=12
          "main" (TID:0xee7000a8, sys_thread_t:0x7fbb8, state:CW) prio=5
      Monitor Cache Dump:
          sun.awt.motif.MToolkit@EE704918/EE74F090: owner "AWT-EventQueue-0" (0xee011de0, 1 entry)
              Waiting to be notified:
                  "AWT-Motif"
          <unknown key> (0xee2f1de0): <unowned>
              Waiting to be notified:
                  "Async Garbage Collector"
          java.lang.Class@1080963312/1081343296: owner "AWT-EventQueue-0" (0xee011de0, 1 entry)
          sun.awt.AWTFinalizer@EE707780/EE7599D8: <unowned>
              Waiting to be notified:
                  "AWT-Finalizer"
      Registered Monitor Dump:
          Thread queue lock: <unowned>
              Waiting to be notified:
                  "main"
          Name and type hash table lock: <unowned>
          String intern lock: <unowned>
          JNI pinning lock: <unowned>
          JNI global reference lock: <unowned>
          BinClass lock: <unowned>
          Class loading lock: <unowned>
          Java stack lock: <unowned>
          Code rewrite lock: <unowned>
          Heap lock: <unowned>
          Has finalization queue lock: <unowned>
          Finalize me queue lock: <unowned>
              Waiting to be notified:
                  "Finalizer thread"
          Monitor IO lock: <unowned>
          Child death monitor: <unowned>
          Event monitor: <unowned>
          I/O monitor: <unowned>
              Waiting to be notified:
                  "AWT-Input"
          Alarm monitor: <unowned>
              Waiting to be notified:
                  "Clock"
          Monitor cache expansion lock: <unowned>
          Monitor registry: owner "AWT-EventQueue-0" (0xee011de0, 1 entry)
      Thread Alarm Q:
          sys_thread_t 0xedfe1de0 [Timeout expired]
          sys_thread_t 0xee2f1de0 [Timeout in 255 ms]
      Abort (core dumped)
      (Review ID: 20627)
      ======================================================================

            Unassigned Unassigned
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: