[ https://issues.apache.org/jira/browse/IGNITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15000129#comment-15000129 ]
Pavel Tupitsyn commented on IGNITE-1884: ----------------------------------------- 1,2) Both of these cases go down to ThrowToJava. It just sets an exception in Java, but does not affect C++ program flow. So the handle won't leak. http://mindprod.com/jgloss/jni.html#EXCEPTIONS However, in future there may be the case with C++ or some other client where exceptions are possible. I'll address this with a wrapper/destructor. 3,4) Creating a wrapper and checking thread id would also introduce an overhead. Before doing this, we need to make sure if that is actually faster than GlobalRef. Let's do that separately. > .Net: JNI local ref can't be accessed from another thread > --------------------------------------------------------- > > Key: IGNITE-1884 > URL: https://issues.apache.org/jira/browse/IGNITE-1884 > Project: Ignite > Issue Type: Bug > Components: interop > Affects Versions: 1.1.4 > Reporter: Pavel Tupitsyn > Assignee: Pavel Tupitsyn > Priority: Blocker > Fix For: 1.5 > > > Documentation: > https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/design.html > {code} > Local references are only valid in the thread in which they are created. The > native code must not pass local references from one thread to another. > {code} > We have two places where we DO pass local JNI reference to another thread: > * CacheParallelLoadStoreAdapter > * CacheTestStore.LoadCache > And, potentially (due to user code): > * UnmanagedCallbacks.DataStreamerStreamReceiverInvoke > For some reason it has worked for us before. > But renamings in IGNITE-1881 have caused test execution order to change, and > these store tests cause process crash. > To reproduce, BinaryBuilderSelfTest (former PortableApiSelfTest) has to be > executed before store tests. All other tests can be excluded. 100% repro > rate: "FATAL ERROR in native method: Bad global or local ref passed to JNI". -- This message was sent by Atlassian JIRA (v6.3.4#6332)