I'm coding an Android app doing graphics rendering in native side through OpenGL ES. When I compile it in debug mode the application crash, but don't when in release mode. I've detected that it happen just when setting up the Renderer, Just when it finishes the call to ( onSurfaceCreated
) function. Other thing that is happening is when I place a breakpoint in the XXXActivity.nativeSurfaceCreated();
line, even if I don't step into, just continue the normal flow of the program, then it doesn't crash at all. It seems like there is a thread synchronization problem but I can't figure out how to solve it.
Here is my Renderer class
public class Renderer implements GLSurfaceView.Renderer {
public Renderer(Context ctx)
{
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
XXXActivity.nativeSurfaceCreated();
}
public void onSurfaceChanged(GL10 gl, int w, int h) {
XXXActivity.nativeSurfaceChanged(w, h); //HERE is the problem just when it finish the execution of this line.
}
public void onDrawFrame(GL10 gl) {
XXXActivity.nativeDrawFrame();
}
}
here is my stack:
F/art (26519): art/runtime/mirror/object.cc:190] Invalid state during hashcode ForwardingAddress
F/art (26519): art/runtime/runtime.cc:284] Runtime aborting --- recursively, so no thread-specific detail!
F/art (26519): art/runtime/runtime.cc:284]
--------- beginning of crash
F/libc (26519): Fatal signal 6 (SIGABRT), code -6 in tid 26533 (HeapTrimmerDaem)
I/DEBUG ( 299): [2016-09-28 10:42:59.064]
I/DEBUG ( 299): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 299): Build fingerprint: 'lge/w7_tmo_us/w7:5.0.2/LRX22G/150651744a25e:user/release-keys'
I/DEBUG ( 299): Revision: '6'
I/DEBUG ( 299): ABI: 'arm'
I/DEBUG ( 299): pid: 26519, tid: 26533, name: HeapTrimmerDaem >>> com.XXX.ar.XXX <<<
I/DEBUG ( 299): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
W/NativeCrashListener( 972): Couldn't find ProcessRecord for pid 1530015793
I/DEBUG ( 299): Abort message: 'art/runtime/gc/collector/semi_space-inl.h:37] Check failed: IsAligned<kPageSize>(obj) '
E/DEBUG ( 299): AM write failure (32 / Broken pipe)
I/DEBUG ( 299): r0 00000000 r1 000067a5 r2 00000006 r3 00000000
I/DEBUG ( 299): r4 a452edd8 r5 00000006 r6 00000002 r7 0000010c
I/DEBUG ( 299): r8 00000001 r9 b78f2f48 sl b7eabab0 fp b81c5550
I/DEBUG ( 299): ip 000067a5 sp a452e288 lr b6ec57f5 pc b6eed344 cpsr 60070010
I/DEBUG ( 299):
I/DEBUG ( 299): backtrace:
I/DEBUG ( 299): #00 pc 0003b344 /system/lib/libc.so (tgkill+12)
I/DEBUG ( 299): #01 pc 000137f1 /system/lib/libc.so (pthread_kill+52)
I/DEBUG ( 299): #02 pc 00014403 /system/lib/libc.so (raise+10)
I/DEBUG ( 299): #03 pc 00010c55 /system/lib/libc.so (__libc_android_abort+36)
I/DEBUG ( 299): #04 pc 0000f3f4 /system/lib/libc.so (abort+4)
I/DEBUG ( 299): #05 pc 00226ccf /system/lib/libart.so (art::Runtime::Abort()+170)
I/DEBUG ( 299): #06 pc 000a6c59 /system/lib/libart.so (art::LogMessage::~LogMessage()+1360)
I/DEBUG ( 299): #07 pc 001efbb3 /system/lib/libart.so (art::mirror::Object::IdentityHashCode() const+390)
I/DEBUG ( 299): #08 pc 001f4223 /system/lib/libart.so (art::Monitor::DescribeWait(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Thread const*)+306)
I/DEBUG ( 299): #09 pc 00234627 /system/lib/libart.so (art::StackDumpVisitor::VisitFrame()+358)
I/DEBUG ( 299): #10 pc 0022e8ad /system/lib/libart.so (art::StackVisitor::WalkStack(bool)+272)
I/DEBUG ( 299): #11 pc 00236d69 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+224)
I/DEBUG ( 299): #12 pc 0023fc1d /system/lib/libart.so (art::ThreadList::DumpLocked(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+120)
I/DEBUG ( 299): #13 pc 00226a2d /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+272)
I/DEBUG ( 299): #14 pc 00226c77 /system/lib/libart.so (art::Runtime::Abort()+82)
I/DEBUG ( 299): #15 pc 000a6c59 /system/lib/libart.so (art::LogMessage::~LogMessage()+1360)
I/DEBUG ( 299): #16 pc 0012d2f1 /system/lib/libart.so (art::gc::collector::BitmapSetSlowPathVisitor::operator()(art::mirror::Object const*) const+160)
I/DEBUG ( 299): #17 pc 0012f5cf /system/lib/libart.so (void art::mirror::Object::VisitReferences<true, (art::VerifyObjectFlags)0, art::gc::collector::SemiSpaceMarkObjectVisitor, art::gc::collector::SemiSpaceMarkObjectVisitor>(art::gc::collector::SemiSpaceMarkObjectVisitor const&, art::gc::collector::SemiSpaceMarkObjectVisitor const&)+1122)
I/DEBUG ( 299): #18 pc 0013061b /system/lib/libart.so (art::gc::collector::SemiSpace::ProcessMarkStack()+126)
I/DEBUG ( 299): #19 pc 001307a9 /system/lib/libart.so (art::gc::collector::SemiSpace::MarkReachableObjects()+324)
I/DEBUG ( 299): #20 pc 00130beb /system/lib/libart.so (art::gc::collector::SemiSpace::MarkingPhase()+370)
I/DEBUG ( 299): #21 pc 0012e479 /system/lib/libart.so (art::gc::collector::SemiSpace::RunPhases()+480)
I/DEBUG ( 299): #22 pc 00121e37 /system/lib/libart.so (art::gc::collector::GarbageCollector::Run(art::gc::GcCause, bool)+246)
I/DEBUG ( 299): #23 pc 00134657 /system/lib/libart.so (art::gc::Heap::Compact(art::gc::space::ContinuousMemMapAllocSpace*, art::gc::space::ContinuousMemMapAllocSpace*, art::gc::GcCause)+58)
I/DEBUG ( 299): #24 pc 00138fa3 /system/lib/libart.so (art::gc::Heap::PerformHomogeneousSpaceCompact()+1818)
I/DEBUG ( 299): #25 pc 0013fcc7 /system/lib/libart.so (art::gc::Heap::DoPendingTransitionOrTrim()+818)
I/DEBUG ( 299): #26 pc 0001bd93 /system/framework/arm/boot.oat
I/DEBUG ( 299):
I/DEBUG ( 299): Tombstone written to: /data/tombstones/tombstone_05
I/BootReceiver( 972): Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
I/Zygote ( 325): Process 26519 exited due to signal (6)
here is the back trace
********** Crash dump: **********
Build fingerprint: 'lge/w7_tmo_us/w7:5.0.2/LRX22G/150651744a25e:user/release-keys'
pid: 26519, tid: 26533, name: HeapTrimmerDaem >>> com.XXX.ar.XXX <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Stack frame #00 pc 0003b344 /system/lib/libc.so (tgkill+12)
Stack frame #01 pc 000137f1 /system/lib/libc.so (pthread_kill+52)
Stack frame #02 pc 00014403 /system/lib/libc.so (raise+10)
Stack frame #03 pc 00010c55 /system/lib/libc.so (__libc_android_abort+36)
Stack frame #04 pc 0000f3f4 /system/lib/libc.so (abort+4)
Stack frame #05 pc 00226ccf /system/lib/libart.so (art::Runtime::Abort()+170)
Stack frame #06 pc 000a6c59 /system/lib/libart.so (art::LogMessage::~LogMessage()+1360)
Stack frame #07 pc 001efbb3 /system/lib/libart.so (art::mirror::Object::IdentityHashCode() const+390)
Stack frame #08 pc 001f4223 /system/lib/libart.so (art::Monitor::DescribeWait(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Thread const*)+306)
Stack frame #09 pc 00234627 /system/lib/libart.so (art::StackDumpVisitor::VisitFrame()+358)
Stack frame #10 pc 0022e8ad /system/lib/libart.so (art::StackVisitor::WalkStack(bool)+272)
Stack frame #11 pc 00236d69 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+224)
Stack frame #12 pc 0023fc1d /system/lib/libart.so (art::ThreadList::DumpLocked(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+120)
Stack frame #13 pc 00226a2d /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+272)
Stack frame #14 pc 00226c77 /system/lib/libart.so (art::Runtime::Abort()+82)
Stack frame #15 pc 000a6c59 /system/lib/libart.so (art::LogMessage::~LogMessage()+1360)
Stack frame #16 pc 0012d2f1 /system/lib/libart.so (art::gc::collector::BitmapSetSlowPathVisitor::operator()(art::mirror::Object const*) const+160)
Stack frame #17 pc 0012f5cf /system/lib/libart.so (void art::mirror::Object::VisitReferences<true, (art::VerifyObjectFlags)0, art::gc::collector::SemiSpaceMarkObjectVisitor, art::gc::collector::SemiSpaceMarkObjectVisitor>(art::gc::collector::SemiSpaceMarkObjectVisitor const&, art::gc::collector::SemiSpaceMarkObjectVisitor const&)+1122)
Stack frame #18 pc 0013061b /system/lib/libart.so (art::gc::collector::SemiSpace::ProcessMarkStack()+126)
Stack frame #19 pc 001307a9 /system/lib/libart.so (art::gc::collector::SemiSpace::MarkReachableObjects()+324)
Stack frame #20 pc 00130beb /system/lib/libart.so (art::gc::collector::SemiSpace::MarkingPhase()+370)
Stack frame #21 pc 0012e479 /system/lib/libart.so (art::gc::collector::SemiSpace::RunPhases()+480)
Stack frame #22 pc 00121e37 /system/lib/libart.so (art::gc::collector::GarbageCollector::Run(art::gc::GcCause, bool)+246)
Stack frame #23 pc 00134657 /system/lib/libart.so (art::gc::Heap::Compact(art::gc::space::ContinuousMemMapAllocSpace*, art::gc::space::ContinuousMemMapAllocSpace*, art::gc::GcCause)+58)
Stack frame #24 pc 00138fa3 /system/lib/libart.so (art::gc::Heap::PerformHomogeneousSpaceCompact()+1818)
Stack frame #25 pc 0013fcc7 /system/lib/libart.so (art::gc::Heap::DoPendingTransitionOrTrim()+818)
Stack frame #26 pc 0001bd93 /system/framework/arm/boot.oat
I managed to solve my own question. It happens that I have been initializing a texture related code in the XXXActivity.nativeSurfaceCreated();
but somehow XXXActivity.nativeDrawFrame();
where I draw the texture was updating before XXXActivity.nativeSurfaceCreated();
and as that resource was not created it provoked the crash, that's why OpenGL thread was crashing. I moved my code into the nativeDrawFrame
to initialize once. It may not be the must beautiful solution but it works. If anybody have other solution, don't hesitate to post it here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.