Thanks; I gave that a shot but I'm still having problems. I'm wondering if creating the "ConcreteItem" from Java, which implements a virtualized C++ interface isn't "deleteable" from C++. If I release the unique_ptr in the native code's destructor so that it's not deleted, the problem goes away. I've also tried deallocating the native object that holds the reference manually (so that its destructor is called before any of the Java objects go out of scope), and it didn't make a difference.
This is a representative stack trace:
Current thread (0x00007efe149e1000): JavaThread "JavaCPP Deallocator" daemon [_thread_in_native, id=2418, stack(0x00007efdb9f16000,0x00007efdba017000)]
Stack: [0x00007efdb9f16000,0x00007efdba017000], sp=0x00007efdba0157e8, free space=1021k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
C 0x0000000000000025
j org.bytedeco.javacpp.Pointer$NativeDeallocator.deallocate()V+27
j org.bytedeco.javacpp.Pointer$DeallocatorReference.clear()V+46
j org.bytedeco.javacpp.Pointer$DeallocatorThread.run()V+11
v ~StubRoutines::call_stub
V [libjvm.so+0x8adf03] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x333
V [libjvm.so+0x8ac090] JavaCalls::call_virtual(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, Thread*)+0x190
V [libjvm.so+0x8ac165] JavaCalls::call_virtual(JavaValue*, Handle, Klass*, Symbol*, Symbol*, Thread*)+0x85
V [libjvm.so+0x95d0af] thread_entry(JavaThread*, Thread*)+0x7f
V [libjvm.so+0xe75619] JavaThread::thread_main_inner()+0x1e9
V [libjvm.so+0xe7141c] Thread::call_run()+0x15c
V [libjvm.so+0xc26d5e] thread_native_entry(Thread*)+0xee
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.bytedeco.javacpp.Pointer$NativeDeallocator.deallocate(JJ)V+0
j org.bytedeco.javacpp.Pointer$NativeDeallocator.deallocate()V+27
j org.bytedeco.javacpp.Pointer$DeallocatorReference.clear()V+46
j org.bytedeco.javacpp.Pointer$DeallocatorThread.run()V+11
v ~StubRoutines::call_stub
siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000000000025
Again, ConcreteItem is a Java class that implements a virtualized C++ interface (IItem). Should native code be code be capable of calling delete on references to those Java objects? Interactions between the native code and the ConcreteItem appear to work Ok. I just run into problems when the native code deletes it. I'm also wondering about DeallocatorThread.run() showing up in the stack trace. Should I be seeing that if I explicitly call "deallocate()" on a bound object? If not, it would seem that the problem is a subsequent call to deallocate that's causing problems.