[OpenJDK 2D-Dev] Deadlock in SunGraphicsEnvironment / FontManager?

Jeremy Manson jeremymanson at google.com
Thu Oct 1 19:11:02 UTC 2009

Does anyone have any thoughts about this?  If we were to make up a
patch, would you take it?

I did get an email about how this should all be single threaded on an
event dispatcher thread, to which I would reply:

1) If it is all supposed to be single threaded, then there shouldn't
be any locks in it to cause a deadlock, and

2) This is in the font code, and you can use fonts for things other
than drawing to the screen (in this case, they are trying to render a


On Wed, Sep 23, 2009 at 5:16 PM, Jeremy Manson <jeremymanson at google.com> wrote:
> Hi 2d folks,
> We have an application running on OpenJDK6 that seems to be
> deadlocking in SunGraphicsEnvironment.  I found it rather difficult to
> write a cut-down reproduction, but the errant lock acquisition is on
> line 482 of SunGraphicsEnvironment.java.:
> http://hg.openjdk.java.net/jdk6/jdk6-gate/jdk/file/f9fa5c538031/src/share/classes/sun/java2d/SunGraphicsEnvironment.java
> After the lock is acquired, it goes on to call
> FontManager.initialiseDeferredFonts() on line 467, which acquires the
> other lock.  It looks as if you might be able to move the lock
> acquisition from line 462 to 468, which would eliminate the deadlock.
> The code looks pretty similar in recent OpenJDK7 builds (although the
> line numbers are changed).
> The relevant stacks follow.  It seems like a pretty easy fix for a
> pretty nasty problem.  Any chance someone could take a look?  Thanks!
> Thread 1:
>  sun.font.FontManager.initialiseDeferredFonts(FontManager.java:791)
>  sun.java2d.SunGraphicsEnvironment.loadFonts(SunGraphicsEnvironment.java:467)
>  sun.awt.X11GraphicsEnvironment.loadFonts(X11GraphicsEnvironment.java:885)
>  sun.font.FontManager.findFont2D(FontManager.java:1995)
>  java.awt.Font.getFont2D(Font.java:473)
>  java.awt.Font.getFontName(Font.java:1221)
>  java.awt.Font.getFontName(Font.java:1203)
> Thread 2:
>  sun.java2d.SunGraphicsEnvironment.loadFonts(SunGraphicsEnvironment.java:463)
>  sun.awt.X11GraphicsEnvironment.loadFonts(X11GraphicsEnvironment.java:885)
>  sun.font.FontManager.findFont2D(FontManager.java:1995)
>  sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1071)
>  sun.font.FontManager.initialiseDeferredFont(FontManager.java:960)
>  sun.font.FontManager.findJREDeferredFont(FontManager.java:875)
>  sun.font.FontManager.findDeferredFont(FontManager.java:912)
>  <snip lots of recursion>
>  sun.font.FontManager.findFont2D(FontManager.java:1904)
>  sun.font.FontManager.findFont2D(FontManager.java:1865)
>  java.awt.Font.getFont2D(Font.java:473)
>  java.awt.Font.getFontName(Font.java:1221)
>  java.awt.Font.getFontName(Font.java:1203)

More information about the 2d-dev mailing list