This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FYI: Linker & Verifier fixes


Hi Robert,

I believe there is still a bug here with the String being passed to ffi_prep_closure:

+ // Initializes the cif and the closure. If that worked the closure is
+ // stored as a function pointer in the atable.
+ if ( ffi_prep_cif(cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_void, arg_types) == FFI_OK
+ && (ffi_prep_closure
+ (closure, cif,
+ _Jv_ThrowNoClassDefFoundErrorTrampoline,
+ (void *) _Jv_NewStringUtf8Const(sym.class_name))
+ == FFI_OK))


The String returned by _Jv_NewStringUtf8Const(sym.class_name) is allocated by the GC, but there is no pointer to this string that is visible to the GC, so it is at risk of being prematurely collected. (The closure data itself will not be visible to the GC as it will not scan malloc()'ed memory).

A simple solution would be to add the Strings as keys in a HashMap each time a closure is created.

Bryce


Robert Schuster wrote:
Hi,
I apply the following patch with this ChangeLog. I tested it on
i686-pc-linux-gnu and there where no regressions.

However since this introduces a memory leak I will file a PR about this.

2006-02-01 Robert Schuster <robertschuster@fsfe.org>

	* link.cc:
	(_Jv_Linker::find_field_helper): Added checks.
	(_Jv_Linker::find_field): Use exception swallowing class resolution
	and added early return.
	(_Jv_ThrowNoClassDefFoundErrorTrampoline): New function.
	(_Jv_Linker::link_symbol_table):  Use exception swallowing class
	resolution, added ffi_closure installation routine, use
	_Jv_ThrowNoClassDefFoundError for missing static method.
	(_Jv_Linker::ensure_class_linked): Added string check which does
	not trigger class resolution.
	* java/lang/natClassLoader.cc:
	(_Jv_FindClassNoException): New method.
	* java/lang/Class.h:
	(_Jv_FindClassNoException): New method declaration.
	* include/jvm.h:
	(_Jv_FindClassNoException): New method declaration.
	(_Jv_FindClassFromSignatureNoException): New method declaration.
	* prims.cc:
	(_Jv_FindClassFromSignatureNoException): New method.
        * gcj/javaprims.h:
        (_Jv_equalsUtf8Classname): New method declaration.
        (_Jv_isPrimitiveOrDerived): Dito.
        * prims.cc:
	(_Jv_equalsUtf8Classnames): New method.
        (_Jv_isPrimitiveOrDerived): New method.
        * verify.cc:
        (ref_intersection::equals): Use new classname comparison method.
        (type::compatible): Use new classname comparison method. Added
        check whether LHS' type is java.lang.Object .
        (type::resolve): Added new optional debug message and simplified
        if-expression.
        (type::to_array): Added codepath that generates an array type
        without resolving the element type.

cya
Robert


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]