Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6761791
Votes 0
Synopsis Crash in the FontManager code due to use of JNIEnv saved by another thread
Category java:classes_2d
Reported Against
Release Fixed 7(b54), 6-open(b16) (Bug ID:2168734)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs
Submit Date 21-OCT-2008
Description
JNI code in the font manager caches JNIEnv and it may be saved by one thread and reused 
by another. This may cause crash.
	
The 'font2D' jobject needs to be converted into a global reference because its lifetime exceeds the lifetime of a native method call.

This is applicable at least to Freetype glue code.

Here is sample stacktrace from the crash:

Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x298366]
C  [libfontmanager.so+0x59e4]
C  [libfreetype.so.6+0x73c9]  FT_Stream_Close+0x19
C  [libfreetype.so.6+0xa065]  FT_Stream_Free+0x25
C  [libfreetype.so.6+0xa6e2]
C  [libfreetype.so.6+0xaf78]  FT_Done_Face+0x78
C  [libfontmanager.so+0x6964]
Java_sun_font_FreetypeFontScaler_disposeNativeScaler+0x34
Posted Date : 2008-10-21 10:10:47.0
Work Around
N/A
Evaluation
I do not see how multithread usage may cause problems per se as all relevant (non private, and not methods dealing with scalercontext lifecycle) FreetypeScaler methods are synchronized. 

However, freetype scaler does not always update cached JNIEnv/font2d values but calling freetype functions may cause callbacks and actual attempt to use cached values. I've added requests to update cached values in 2 identified places (and lokking through the code it seems all over cases are covered).

Proposed fix is in line with what we do for T2K.

Note that fix proposed on openjdk mailing list suggests to make reference to font2d object global. However, it does not seem necessary as it is not possible to save it in one thread and use on another thread for the same reasons - all methods are synchronized and we update cached reference every time native scaler is called.
Posted Date : 2008-12-17 19:13:24.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang