The function is exposed from R.dll and I actually see it being resolved successfully multiple times.
I think it might be a race condition, where the handle is being closed before all objects are being released, leading to GetProcAddress to fail and return null.
I see that when this issue occurs, it is happening during a finalizer call.
So probably what happened is that the engine handle was disposed (either in a different finalizer or by explicitly calling Dispose) and then a GC kicked in and started finalizing other objects. At this point, they failed.
It seems like either:
I think it might be a race condition, where the handle is being closed before all objects are being released, leading to GetProcAddress to fail and return null.
I see that when this issue occurs, it is happening during a finalizer call.
So probably what happened is that the engine handle was disposed (either in a different finalizer or by explicitly calling Dispose) and then a GC kicked in and started finalizing other objects. At this point, they failed.
It seems like either:
- Some references are not being kept, so the GC releases the engine before other objects.
-
Maybe some objects should be IDisposable and they should be disposed earlier (and not wait for the finalizaer).