IDEA crashes when trying to change font in Ubuntu

I should note that this actually worked at one point, then I did an update to my Ubuntu system and now things just aren't jiving. IDEA runs pretty well for the most part, except when I go to Settings -> Colors & Fonts. The "Colors & Fonts" dialog comes up just fine. I then attempt to click the "..." button in the "Editor Font" section (this button is what pulls up a dialog allowing you to select the editor font), and IDEA crashes out with this:


Let me note a few things:
1. The "Appearance" dialog comes up fine!
2. I have seen this issue: http://support.jetbrains.com/kb/entry.jspa?externalID=172&categoryID=4
3. I ran the FontTest program attached to the above issue, and it did not crash and did not have any problems!

I also saw another forum thread where someone was having an issue bringing up the "Appearance" dialog - however, again, my appearance dialog comes up fine.
Does anyone have any tips on getting this working in Ubuntu (I updated to Dapper Drake Flight 2)?

Thanks,
Andy

12 comments

Hello Andy,

AD> I should note that this actually worked at one point, then I did an
AD> update to my Ubuntu system and now things just aren't jiving. IDEA
AD> runs pretty well for the most part, except when I go to Settings ->
AD> Colors & Fonts. The "Colors & Fonts" dialog comes up just fine. I
AD> then attempt to click the "..." button in the "Editor Font" section
AD> (this button is what pulls up a dialog allowing you to select the
AD> editor font), and IDEA crashes out with this:
AD>
AD> #
AD> # An unexpected error has been detected by HotSpot Virtual Machine:
AD> #
AD> # SIGSEGV (0xb) at pc=0x9bc4e25b, pid=5811, tid=2612104112
AD> #
AD> # Java VM: Java HotSpot(TM) Server VM (1.5.0_06-b05 mixed mode)
AD> # Problematic frame:
AD> # C

One critical detail is missing from your report: Which exactly version of
IDEA are you using? Some fixes relevant to this problem are included in version
5.0.2.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

Sorry about that, the version is 5.0.2 build #3542.

- Andy

0

OK, I evolved the "FontTest" program from http://support.jetbrains.com/kb/entry.jspa?externalID=172&categoryID=4 so that it now reproduces the problem. Apparently, it wasn't enough to just call "canDisplay" against the font. I suspected that the problem was in the rendering of the font since I can pull up my "Appearance" dialog (which contains a list of all available fonts and their names). However, it ended up that not even rendering the font as returned by GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts() was enough. In the end, I had to derive a larger font and render that. The moment it is set on a JLabel that is visible, the app crashes (I also tried setting it on a JLabel that was not visible and the system did not crash).

Here is the final evolved (some of the changes aren't really necessary) FontTest:

?'\";:[{]}\\|`~"); label.setFont(label.getFont().deriveFont(16.0f)); frame.getContentPane().add(label, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); final Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); for (int i = 0; i < fonts.length; i++) { final Font font = fonts[ i ]; final String name = font.getName(); System.out.print("Checking Font: " + name); final boolean t1 = testChars(font, 'a', 'z'); final boolean t2 = testChars(font, 'A', 'Z'); final boolean t3 = testChars(font, '0', '9'); final boolean t4 = font.canDisplayUpTo("The quick brown fox jumped over the lazy dog's back!@#$%^&*()_+-=,./<>?'\";:[{]}\\|`~") == -1; printTest(frame, label, font); if (t1 && t2 && t3 && t4) { System.out.println(" OK."); } else { System.out.println(); } } } private static boolean testChars(final Font font, final int start, final int end) { System.out.println("testChars('" + (char)start + "', '" + (char)end + "')"); boolean ret = true; for(int i = start;i <= end;i++) { if(!font.canDisplay((char)i)) { ret = false; } } return ret; } private static void printTest(final JFrame frame, final JLabel label, Font font) { System.out.println("Entering printTest."); final Font derived = font.deriveFont(16.0f); System.out.println("Derived font"); label.setFont(derived); System.out.println("Set font"); frame.repaint(); System.out.println("Repainted and leaving printTest."); } }{code}]]>

I've also attached the hs_err_*.log produced from the crash.

- Andy



Attachment(s):
hs_err_pid11877.log
0

Oh, btw, the offending font seems to be "Saab". Now all I have to do is figure out how to remove it. :)

- Andy

0

The saga continues. I made my test string in the JLabel longer by including all capital letters ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), and now even "SansSerif.bold" is crashing the system, so I'm truly confounded. What now?

0

OK, this was an illusion - it looked like SansSerif.bold was causing a problem, but that was because of threading (the System.out.println was happening in the "main" thread, while the repaint was happening for the prior font in the event dispatch thread). It ended up that there were quite a few fonts that caused the JDK to barf, and after removing them all things are now working.
So, the long and short of it:
On Ubuntu (and, I suspect, Debian in general, and possibly Linux in general?) the JDK (1.5) can get real picky about which fonts you have installed... if it encounters a font it doesn't like, it crashes. The fix for me was to have a more thorough FontTest which actually rendered the font in order to detect which fonts were causing crashes. I then removed each font until the test runs without crashing. My final FontTest is here:

?'\";:[{]}\\|`~");
    label.setFont(label.getFont().deriveFont(16.0f));
    frame.getContentPane().add(label, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
    try {
        final Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
        for (int i = 0; i < fonts.length; i++) {
          final int idx = i;
          SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
              final Font font = fonts[idx];
              final String name = font.getName();
    
              System.out.println("Checking Font: " + name);
    
              final boolean t1 = testChars(font, 'a', 'z');
              final boolean t2 = testChars(font, 'A', 'Z');
              final boolean t3 = testChars(font, '0', '9');
              System.out.println("Executing canDisplayUpTo...");
              final boolean t4 = font.canDisplayUpTo("The quick brown fox jumped over the lazy dog's back!@#$%^&*()_+-=,./<>?'\";:[{]}\\|`~") == -1;
              System.out.println("Executing printTest...");
              printTest(frame, label, font);
    
              if (t1 && t2 && t3 && t4) {
                System.out.println(" OK.");
              } else {
                System.out.println();
              }
            }
          });
        }
        System.out.println("Finished");
        System.exit(0);
    } catch(Exception e) {
      throw new RuntimeException(e);
    }
  }

  private static boolean testChars(final Font font, final int start, final int end)
  {
    System.out.println("testChars('" + (char)start + "', '" + (char)end + "')");
    boolean ret = true;

    for(int i = start;i <= end;i++) {
      if(!font.canDisplay((char)i)) {
        ret = false;
      }
    }

    return ret;
  }

  private static void printTest(final JFrame frame, final JLabel label, final Font font)
  {
    System.out.println("Entering printTest.");
    final Font derived = font.deriveFont(16.0f);
    System.out.println("Derived font");
    label.setFont(derived);
    System.out.println("Set font");
    frame.repaint();
    System.out.println("Repainted and leaving printTest.");
  }
}]]>


I ended up having to put the SwingUtilities.invokeAndWait in the loop to get things to work. I should note that because of this the repaint (and thus rendering of the font) for a font occurs after the invokeAndWait returns (because it is queued on the event thread) - so, when a crash occurs, if it is due to rendering, then it will seem the last font printed succeeded, but that last font will be the one whose rendering caused the crash.
I suppose the page that I referenced in an earlier message (which the original FontTest) program should be updated.

- Andy

0

Andy DePue wrote on 19/01/06 05:56:

I also saw another forum thread where someone was having an issue bringing up the "Appearance" dialog - however, again, my appearance dialog comes up fine.
Does anyone have any tips on getting this working in Ubuntu (I updated to Dapper Drake Flight 2)?


Currently I'd be inclined to say "dapper? good luck"... dapper is the
EAP of Ubuntu operating systems.

I think it'd be better reporting the problem to Ubuntu - find out what
changed in libfontmanager...

0

Currently I'd be inclined to say "dapper? good
luck"... dapper is the
EAP of Ubuntu operating systems.

I think it'd be better reporting the problem to
Ubuntu - find out what
changed in libfontmanager...


You're right, dapper is the EAP of Ubuntu, so this kind of thing is to be expected. However, in my googling I discovered that this is a common problem on Debian distributions with Java 1.5. I also discovered that most people fix the problem by removing offensive fonts. I believe it comes down to some Debian based distros (especially EAP ones) including fonts that the JDK isn't very happy with. I should note that libfontmanager is distributed with and specific to the JDK (see java/jre/lib/i386/libfontmanager.so), so it is the exact same version that is shipped by Sun and in use by the JDK on all Linux variants.
Fortunately for me, I was able to write a more thorough FontTest which helped me to identify the offensive fonts on my system. By removing them, my problem is now solved.

- Andy

0

Andy DePue wrote on 19/01/06 08:47:

(especially EAP ones) including fonts that the JDK isn't very happy
with. I should note that libfontmanager is distributed with and
specific to the JDK (see java/jre/lib/i386/libfontmanager.so), so it
is the exact same version that is shipped by Sun and in use by the


Ah ok - my bad. I currently have no problems on Breezy, thou I am
running Mustang as my JDK. And I don't recall seeing a font called Saab.

JDK on all Linux variants. Fortunately for me, I was able to write a
more thorough FontTest which helped me to identify the offensive
fonts on my system. By removing them, my problem is now solved.


Cool..

0

For the reference of others who run into this problem.

On Dapper the toxic fonts are Rekha-normal and aakar-MagNet these are in the ttf-gujarati-fonts package.

To workaround this use:
sudo apt-get remove ttf-gujarati-fonts

Note: that this will harmlessly remove the meta-packages ubuntu-desktop and indic-fontsm.

This information should be added to a FAQ somewhere.

btw: the JVM failure apparently happens on the next font after the toxic ones. Hence the confusion about which font(s) was causing the failures in the earlier posts. Something to keep in mind if you need to track down other toxic fonts.

0

The SwingUtilities.invokeAndWait() is masking a threading bug in your example. The problem is your main() method should not be creating and using Swing components. The simple fix is:

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
swingSafeMain();
}
}
}

private static void swingSafeMain() {
// now you are on the event dispatch thread; ALL swing apps should start this way
}

0

Yes!

Thanks you guys! I have ripping my hair off (even though I'm bald) for weeks now.

I use jcaptcha which randomly changes fonts and eventually then uses a font which the JVM cannot handle and crashes, not good in a production environment.

After removing the fonts suggested at least the fonttest finishes without crash.

Regards

//Marcus Herou

0

Please sign in to leave a comment.