This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 57664 - Random crashes on Mac OS X
Summary: Random crashes on Mac OS X
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 4.x
Hardware: Macintosh All
: P1 blocker (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks: 106965
  Show dependency tree
 
Reported: 2005-04-08 13:09 UTC by _ ttran
Modified: 2008-12-22 11:29 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Crash report (36.26 KB, text/plain)
2005-04-08 13:13 UTC, _ ttran
Details
jar with patched java.awt.Font (both c.lass and .java) (45.12 KB, application/octet-stream)
2005-04-08 14:56 UTC, _ ttran
Details
patch for applemenu module to hack JVM not to call Font.finalize() (5.39 KB, patch)
2005-04-12 00:09 UTC, _ ttran
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description _ ttran 2005-04-08 13:09:43 UTC
Quite a few users reported frequent JVM crashes of NetBeans, both 4.0 and 4.1, on Mac OS X.
The problem so far has been tracked down to a bug in the JNI portion of the font handling code in 
Apple JDK.  The crash seems to happen in Java_sun_awt_font_NativeFontWrapper_getFontMetrics, 
frequently there but there are other places as well

According to public mailing lists, Apple Java is quite flaky when it comes to fonts.  A combination of 
fonts installed on the machine can cause java apps crash badly.  There were many bugs filed and the 
problem is known for two years (according to one person's account).

It seems that java.awt.Font.finalize() releases pointers in C code which are in fact still used.  Perhaps 
some kind of buggy optimization.

We finally have one reproducible test case:

- create new Web Application
- (click randomly around in the IDE)
- right click on the web app project, Run
- (click randomly around in the IDE)

Repeat the above steps a few times and you get the crash.

My config: OS X 10.3.8, JDK 1.4.2 update 2 (latest, greatest), NB 4.1 built from CVS

I'll attach a sample crash report
Comment 1 _ ttran 2005-04-08 13:13:16 UTC
Created attachment 21495 [details]
Crash report
Comment 2 _ ttran 2005-04-08 13:17:44 UTC
From: Greg Guerin <glguerin@amug.org>
Subject: Re: NetBeans crashing
Date: Thu, 07 Apr 2005 11:55:23 -0700
To: java-dev@lists.apple.com

Trung Duc Tran <Trung.Duc.Tran@Sun.COM> wrote:

>I noticed people reported java crashes due to bad fonts.  I didn't
>install any additional fonts.

Check anyway.  Some apps install fonts.  Start here:
  ~/Library/Fonts/

If you didn't install any fonts, nor did any apps, then it will be empty.

Apps might also install fonts here:
  /Library/Fonts/

so you should check there for fonts with unexpected names or mod-dates.

Also, compare what's in /Library/Fonts/ with what's in
/System/Library/Fonts/.  As I vaguely recall, some of the font-caused
problems are when there are conflicts or overrides of those two domains.

If you don't find anything obvious, use binary-partitioning to
remove/replace fonts to find problems.  By binary partition, I mean move
half the fonts out, try running the app.  If it works, move half the ones
you moved out back in, run again.  If it still fails, move out half the
ones still left.  Lather, rinse, repeat.

  -- GG
Comment 3 _ ttran 2005-04-08 13:22:34 UTC
Date: Fri, 08 Apr 2005 11:18:56 +0200
From: =?ISO-8859-1?Q?Bj=F8rn_Ole_Bakke?= <bakbjo@online.no>
Subject: Re: NetBeans crashing
To: Java Dev <java-dev@lists.apple.com>

I see you mention Vera fonts, I do not have these installed on my 
system, but netbeans 4.1beta seems to crash a lot anyway.
Netbeans crashes as far as i can tell, when it is either recompiling or 
searching libraries. (this is just an impression i got)

Anyways it almost always crashes on thread 14, and it always writes 
this in the log file: 
Java_sun_awt_font_NativeFontWrapper_getFontMetrics
but aside from what is mentioned in the log file, I have no clue what 
so ever about why. I thought a while back that it had something to do 
with me changing
the editor font to monaco, but it crashes all the same with the default 
selected font -  "monospaced 13"

One of my 100 crash log entries:
Thread 14 Crashed:
0   libobjc.A.dylib          	0x908311ec objc_msgSend + 0xc
1   libawt.jnilib            	0x78f12360 
Java_sun_awt_font_NativeFontWrapper_getFontMetrics + 0xf4


PĆ„ 8. apr. 2005 kl. 04.41 skrev Greg Guerin:

> Trung Duc Tran wrote:
>
>> Indeed there are Bitstream Vera font files there. Probably installed 
>> by
>> NeoOffice/J. But I am kind of hesitant to say these are bad fonts 
>> given the
>> reputation of Bitstream and popularity of Vera.
>
> I'm not suggesting "bad" in the sense of malformed files.  I'm only
> suggesting that they might lead to a manifestation of the problem, not 
> that
> they are the primary cause.  The fonts themselves could be perfectly 
> good,
> but could simply precipitate a bug that can be avoided by removing 
> fonts.
>
> Font problems may be hard to pin to a specific malformed font.  For
> example, some versions of Java on Mac OS X would misbehave if there 
> were
> certain duplicate fonts in the user's Fonts folder.  The fonts 
> themselves
> were apparently OK.  Something just objected to the duplication of a 
> font's
> name, or couldn't figure out the override.
>
>
>> I didn't configure NetBeans to use Vera fonts. Can the app crash even 
>> if it
>> only interates the bad fonts not actually use them?
>
> Hard to say.  I've seen it go both ways.  And I've seen it fail simply 
> from
> the number of fonts present, not anything related to a bad font or a
> duplicated font or anything else discernible.
>
>   -- GG
Comment 4 _ ttran 2005-04-08 13:29:18 UTC
it's not bcs of fonts installed on the system.  I moved ~/Library/Fonts and /Library/Fonts elsewhere.  
Still crashing
Comment 5 _ ttran 2005-04-08 14:54:19 UTC
It looks like java.awt.Font.finalize() finalizes too much.  If I patch this class and comment out this 
method, I cannot reproduce the crash (so far)
Comment 6 _ ttran 2005-04-08 14:56:02 UTC
Created attachment 21498 [details]
jar with patched java.awt.Font (both c.lass and .java)
Comment 7 _ ttran 2005-04-08 15:29:02 UTC
To use the patch put the jar on the bootclasspath like this

   -J-Xbootclasspath/p:/Users/ttran/work/fontpatch/fontpatch.jar 

There are two flags independent of each other

-J-Djava.awt.Font.log=true 

   prints to System.out information about Font creations and finalization

-J-Djava.awt.Font.dontFinalize=true

   don't release the native font data.  This would leak but with won't cause the JVM to crash
Comment 8 _ ttran 2005-04-12 00:09:19 UTC
Created attachment 21558 [details]
patch for applemenu module to hack JVM not to call Font.finalize()
Comment 9 _ ttran 2005-04-12 00:12:23 UTC
I committed the attched diff into the CVS trunk.  PLEASE TEST.  This leaks font data but at least I can't 
reproduce the crash with new web applications test case

Checking in src/org/netbeans/modules/applemenu/FontReferenceQueue.java;
/cvs/ide/applemenu/src/org/netbeans/modules/applemenu/FontReferenceQueue.java,v  <--  
FontReferenceQueue.java
initial revision: 1.1
done
Checking in src/org/netbeans/modules/applemenu/Install.java;
/cvs/ide/applemenu/src/org/netbeans/modules/applemenu/Install.java,v  <--  Install.java
new revision: 1.2; previous revision: 1.1
Comment 10 Martin Schovanek 2005-04-12 17:39:50 UTC
I tested the patch on my custom build and it worked for me. No crash, no new
problems.

Comment 11 Milos Kleint 2005-04-13 12:19:37 UTC
ok, I consider it fixed. will prepare a review proposal to integrate it into 4.1
branch.
Comment 12 Milos Kleint 2005-04-15 10:55:29 UTC
merged to release41 branch.
Comment 13 Martin Schovanek 2005-04-22 14:08:39 UTC
Cannot reproduce on [Mac OS X 10.4 Tiger, JDK 1.4.2_07, Nb #200404011800].

Do we plan to remove this fix after Tiger release?
Comment 14 Tomas Danek 2005-07-27 11:53:27 UTC
How is this issue in 4.2?? Does it still persist?? If no other comments from MAC
users, I'll close this.Thanx.
Comment 15 Jan Chalupa 2005-07-27 11:55:17 UTC
We've hacked around it. No issues that I'm aware of reported since then. Can be
closed.
Comment 16 Tomas Danek 2005-08-01 08:26:42 UTC
OK, closing then.