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

ACCESS VIOLATION Error in Java VM Causes by Big Font SIZE.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • client-libs
    • 2d
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0"
      Java(TM) SE Runtime Environment (build 1.6.0-b105)
      Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode)

      FULL OS VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Just Regular HOME Desktop Computer,
      with Windows OS and NetBeans 5.5 IDE.

      A DESCRIPTION OF THE PROBLEM :
      ACCESS VIOLATION Exception occur when trying to set Font SIZE to valid
      integer bigger than 10000.

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Yes

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the sample code
      2. Change the font size to 10000 & press enter
      Exceptions show in Windows.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Setting the Font Size to a given number, and check if it is not possible return a Valid Error.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      #
      # An unexpected error has been detected by Java Runtime Environment:
      #
      # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d2d6819, pid=1704, tid=5912
      #
      # Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode)
      # Problematic frame:
      # C [fontmanager.dll+0x26819]
      #
      # If you would like to submit a bug report, please visit:
      # http://java.sun.com/webapps/bugreport/crash.jsp
      #

      (see full report in attachment)



      --------------- S Y S T E M ---------------

      OS: Windows XP Build 2600 Service Pack 2

      CPU:total 2 family 15, cmov, cx8, fxsr, mmx, sse, sse2, ht

      Memory: 4k page, physical 1047724k(268124k free), swap 2519300k(1777304k free)

      vm_info: Java HotSpot(TM) Client VM (1.6.0-b105) for windows-x86, built on Nov 29 2006 00:48:48 by "java_re" with unknown MS VC++:1310



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import javax.swing.event.*;
      import javax.swing.colorchooser.*;
      import javax.swing.text.*;
      import java.awt.*;
      import java.awt.event.*;

      public class FontChooser extends JDialog implements ActionListener {

        JColorChooser colorChooser;
        JComboBox fontName;
        JCheckBox fontBold, fontItalic;
        JTextField fontSize;
        JLabel previewLabel;
        SimpleAttributeSet attributes;
        Font newFont;
        Color newColor;

        public FontChooser(Frame parent) {
          super(parent, "Font Chooser", true);
          setSize(450, 450);
          attributes = new SimpleAttributeSet();

          // Make sure that any way the user cancels the window does the right thing
          addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              closeAndCancel();
            }
          });

          // Start the long process of setting up our interface
          Container c = getContentPane();
          
          JPanel fontPanel = new JPanel();
          fontName = new JComboBox(new String[] {"TimesRoman",
                                                 "Helvetica", "Courier"});
          fontName.setSelectedIndex(1);
          fontName.addActionListener(this);
          fontSize = new JTextField("12", 4);
          fontSize.setHorizontalAlignment(SwingConstants.RIGHT);
          fontSize.addActionListener(this);
          fontBold = new JCheckBox("Bold");
          fontBold.setSelected(true);
          fontBold.addActionListener(this);
          fontItalic = new JCheckBox("Italic");
          fontItalic.addActionListener(this);

          fontPanel.add(fontName);
          fontPanel.add(new JLabel(" Size: "));
          fontPanel.add(fontSize);
          fontPanel.add(fontBold);
          fontPanel.add(fontItalic);

          c.add(fontPanel, BorderLayout.NORTH);
          
          // Set up the color chooser panel and attach a change listener so that color
          // updates get reflected in our preview label.
          colorChooser = new JColorChooser(Color.black);
          colorChooser.getSelectionModel()
                      .addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
              updatePreviewColor();
            }
          });
          c.add(colorChooser, BorderLayout.CENTER);

          JPanel previewPanel = new JPanel(new BorderLayout());
          previewLabel = new JLabel("Here's a sample of this font.");
          previewLabel.setForeground(colorChooser.getColor());
          previewPanel.add(previewLabel, BorderLayout.CENTER);

          // Add in the Ok and Cancel buttons for our dialog box
          JButton okButton = new JButton("Ok");
          okButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              closeAndSave();
            }
          });
          JButton cancelButton = new JButton("Cancel");
          cancelButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              closeAndCancel();
            }
          });

          JPanel controlPanel = new JPanel();
          controlPanel.add(okButton);
          controlPanel.add(cancelButton);
          previewPanel.add(controlPanel, BorderLayout.SOUTH);

          // Give the preview label room to grow.
          previewPanel.setMinimumSize(new Dimension(100, 100));
          previewPanel.setPreferredSize(new Dimension(100, 100));

          c.add(previewPanel, BorderLayout.SOUTH);
        }
        // Ok, something in the font changed, so figure that out and make a
        // new font for the preview label
        public void actionPerformed(ActionEvent ae) {
          // Check the name of the font
          if (!StyleConstants.getFontFamily(attributes)
                             .equals(fontName.getSelectedItem())) {
            StyleConstants.setFontFamily(attributes,
                                         (String)fontName.getSelectedItem());
          }
          // Check the font size (no error checking yet)
          if (StyleConstants.getFontSize(attributes) !=
                                         Integer.parseInt(fontSize.getText())) {
            StyleConstants.setFontSize(attributes,
                                       Integer.parseInt(fontSize.getText()));
          }
          // Check to see if the font should be bold
          if (StyleConstants.isBold(attributes) != fontBold.isSelected()) {
            StyleConstants.setBold(attributes, fontBold.isSelected());
          }
          // Check to see if the font should be italic
          if (StyleConstants.isItalic(attributes) != fontItalic.isSelected()) {
            StyleConstants.setItalic(attributes, fontItalic.isSelected());
          }
          // and update our preview label
          updatePreviewFont();
        }

        // Get the appropriate font from our attributes object and update
        // the preview label
        protected void updatePreviewFont() {
          String name = StyleConstants.getFontFamily(attributes);
          boolean bold = StyleConstants.isBold(attributes);
          boolean ital = StyleConstants.isItalic(attributes);
          int size = StyleConstants.getFontSize(attributes);

          
          Font f = new Font(name, (bold ? Font.BOLD : 0) +
                                  (ital ? Font.ITALIC : 0), size);
          previewLabel.setFont(f);
        }

        // Get the appropriate color from our chooser and update previewLabel
        protected void updatePreviewColor() {
          previewLabel.setForeground(colorChooser.getColor());
          // Manually force the label to repaint
          previewLabel.repaint();
        }
        public Font getNewFont() { return newFont; }
        public Color getNewColor() { return newColor; }
        public AttributeSet getAttributes() { return attributes; }

        public void closeAndSave() {
          // Save font & color information
          newFont = previewLabel.getFont();
          newColor = previewLabel.getForeground();

          // Close the window
          setVisible(false);
        }

        public void closeAndCancel() {
          // Erase any font information and then close the window
          newFont = null;
          newColor = null;
          setVisible(false);
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      check given number argument number on .setFontSize method.

            Unassigned Unassigned
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: