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.
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
Created attachment 21495 [details] Crash report
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
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
it's not bcs of fonts installed on the system. I moved ~/Library/Fonts and /Library/Fonts elsewhere. Still crashing
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)
Created attachment 21498 [details] jar with patched java.awt.Font (both c.lass and .java)
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
Created attachment 21558 [details] patch for applemenu module to hack JVM not to call Font.finalize()
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
I tested the patch on my custom build and it worked for me. No crash, no new problems.
ok, I consider it fixed. will prepare a review proposal to integrate it into 4.1 branch.
merged to release41 branch.
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?
How is this issue in 4.2?? Does it still persist?? If no other comments from MAC users, I'll close this.Thanx.
We've hacked around it. No issues that I'm aware of reported since then. Can be closed.
OK, closing then.