gcj, gdb warnings & jni method signatures

Tom Tromey tromey@redhat.com
Fri Sep 17 17:39:00 GMT 2004


>>>>> "Rutger" == Rutger Ovidius <r_ovidius@eml.cc> writes:

Rutger> warning: Invalid Address specified to RtlFreeHeap( 00240000, 0022F800 )

I'm not a Windows hacker, I have no clue what this means.  But...

Rutger> Note: It only causes the warning the first time
Rutger> this native call is made; subsequent calls to the same native method
Rutger> do not cause the warning.

This is suggestive, since the first time a given native method is
called, we cache the function pointer and don't do the lookup again.
I.e., the bug is probably in the lookup code.

Rutger> So, I look it up in the swt.dll's source, and see the signature is:
Rutger> JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateFontIndirectW__Lorg_eclipse_swt_internal_win32_LOGFONTW_2
Rutger> { fprintf "stupid"; return 1 }...
Rutger> But, for fun, I change it to:
Rutger> JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateFontIndirectW
Rutger> recompile the .dll and re-run the app under gdb.  No more warning!

Also suggestive.  To find the native method's name, we construct the
long name in a temporary buffer.  Then we truncate it to be the short
name, try to look it up, and finally restore the long name and try
again.  On Windows there are some added complications.

I would suggest starting your search in jni.cc:_Jv_LookupJNIMethod.
There is probably some kind of buffer overwrite bug in the Windows
specific code.

Tom



More information about the Java mailing list