@AaronRobinsonMSFT I don't suppose you can provide some assistance on this one, eh? You seem to know what you're doing.
I'm getting a periodic access violation exception here. It's not consistent. It doesn't happen inside the VS debugger. It only happens, as far as I can tell, when running dotnet test from the command line, through this code. And it only happens once out of every 4 or 5 times. And... I think it's only happening on Framework on Windows.
So, I've resulted to catching a dump file and using WinDbg.
It looks like it's the call to __JNI_NewObjectV, happening as a result of the the __JNI_NewObject call. The macro in jni_varargs.h calls back into .NET. The point of GetMethodArgs is to take a method handle, and return the count of arguments and their types (as a signature). So the C code can unpack the va_List into an array.
I don't see it enter into GetMethodArgs. So, it's not getting into user code.
I thought it might be related to calling conventions again. Or the delegate getting GC'd. The delegate is in JNINativeInterface.cs:
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int GetMethodArgsDelegateType(JNIEnv* pEnv, jmethodID methodID, byte* sig);
It's forced to cdecl.
We store this delegate away on the reserved0 field of JNINativeInterface, since it's IKVM-only. We also store the delegate instance itself on a static readonly field. It should not be getting GC'd.
https://github.com/ikvmnet/ikvm/blob/2d053c4a427f5ca96466e09c7c7e48297e681bb5/src/libjvm/jni_vargs.c#L17
@AaronRobinsonMSFT I don't suppose you can provide some assistance on this one, eh? You seem to know what you're doing.
I'm getting a periodic access violation exception here. It's not consistent. It doesn't happen inside the VS debugger. It only happens, as far as I can tell, when running
dotnet test
from the command line, through this code. And it only happens once out of every 4 or 5 times. And... I think it's only happening on Framework on Windows.So, I've resulted to catching a dump file and using WinDbg.
It looks like it's the call to __JNI_NewObjectV, happening as a result of the the __JNI_NewObject call. The macro in jni_varargs.h calls back into .NET. The point of GetMethodArgs is to take a method handle, and return the count of arguments and their types (as a signature). So the C code can unpack the va_List into an array.
I don't see it enter into GetMethodArgs. So, it's not getting into user code.
I thought it might be related to calling conventions again. Or the delegate getting GC'd. The delegate is in JNINativeInterface.cs:
It's forced to cdecl.
We store this delegate away on the reserved0 field of JNINativeInterface, since it's IKVM-only. We also store the delegate instance itself on a static readonly field. It should not be getting GC'd.
We call it from C:
I set this specifically to cdecl.
I've been working with this for a couple days now, and just can't figure out the issue.