Consistent crashes

Upon using the tip of JUCE I get consistent crashes:


I/DEBUG   (  182): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  182): Build fingerprint: 'Android/aosp_hammerhead/hammerhead:5.0/LRX21O/builder11211238:eng/test-keys'
I/DEBUG   (  182): Revision: '11'
I/DEBUG   (  182): ABI: 'arm'
I/DEBUG   (  182): pid: 3268, tid: 3310, name: Thread-300  >>> com.domain.MyApp <<<
I/DEBUG   (  182): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xc8
I/DEBUG   (  182): Abort message: 'art/runtime/thread.cc:1019] Native thread exited without calling DetachCurrentThread: Thread[22,tid=3310,Native,Thread*=0xaf9
68400,peer=0x12d9e080,"Thread-300"]'
I/DEBUG   (  182):     r0 00000000  r1 a2803db0  r2 fffffa98  r3 0000000c
I/DEBUG   (  182):     r4 c985d93a  r5 a2803a60  r6 b4ffeffc  r7 fffffa9c
I/DEBUG   (  182):     r8 703afce0  r9 00000000  sl 703afce0  fp 719bbb00
I/DEBUG   (  182):     ip b4ffca7c  sp a2803888  lr b4f5aef1  pc b4f5aef0  cpsr 80070030
I/DEBUG   (  182):
I/DEBUG   (  182): backtrace:
I/DEBUG   (  182):     #00 pc 00261ef0  /system/lib/libart.so (art::verifier::MethodVerifier::FindLocksAtDexPc(art::mirror::ArtMethod*, unsigned int, std::__1::
vector<unsigned int, std::__1::allocator<unsigned int> >*)+59)
I/DEBUG   (  182):     #01 pc 001f41fd  /system/lib/libart.so (art::Monitor::VisitLocks(art::StackVisitor*, void (*)(art::mirror::Object*, void*), void*, bool)+
252)
I/DEBUG   (  182):     #02 pc 00233a1f  /system/lib/libart.so (art::StackDumpVisitor::VisitFrame()+374)
I/DEBUG   (  182):     #03 pc 0022dc03  /system/lib/libart.so (art::StackVisitor::WalkStack(bool)+702)
I/DEBUG   (  182):     #04 pc 002361e1  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+224)
I/DEBUG   (  182):     #05 pc 0023f335  /system/lib/libart.so (art::ThreadList::DumpLocked(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+120)
I/DEBUG   (  182):     #06 pc 00225da9  /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+272)
I/DEBUG   (  182):     #07 pc 00225ff3  /system/lib/libart.so (art::Runtime::Abort()+82)
I/DEBUG   (  182):     #08 pc 000a72e9  /system/lib/libart.so (art::LogMessage::~LogMessage()+1360)
I/DEBUG   (  182):     #09 pc 002337ff  /system/lib/libart.so (art::Thread::ThreadExitCallback(void*)+186)
I/DEBUG   (  182):     #10 pc 00016955  /system/lib/libc.so (pthread_key_clean_all()+80)
I/DEBUG   (  182):     #11 pc 000165d3  /system/lib/libc.so (pthread_exit+30)
I/DEBUG   (  182):     #12 pc 000162e5  /system/lib/libc.so (__pthread_start(void*)+32)
I/DEBUG   (  182):     #13 pc 000142d3  /system/lib/libc.so (__start_thread+6)
I/DEBUG   (  182):
I/DEBUG   (  182): Tombstone written to: /data/tombstones/tombstone_02
 

It seems to be related to this: http://stackoverflow.com/questions/26534304/android-jni-call-attachcurrentthread-without-detachcurrentthread

 

 

There's no juce code on the stack though?

And the juce threads do call DetachCurrentThread AFAICT..

Ok, solution wide searched turned up zero DetachCurrentThread entries. That aside, I'm 99.99% sure it must be something in my code, but I have no little to no possiblity to debug it. Digging on...

It happens in juce_android_JNIHelpers.h, line 292

Ok, thanks. And I found the problem: To off-load the main thread with image loading, I used std::thread(<lambda>).detach(). Now I create an off-load thread with JUCE thread instead, which deletes itself when done. Works fine.

I have no idea why the std::thread construct suddenly stopped working, have been using it over a month...

Sorry for the noise.