我的Android应用程序崩溃了"发现无效的根:0x2"

时间:2015-09-07 03:57:13

标签: java android crash garbage-collection

我需要一些帮助来解释堆栈跟踪!

我正在为Android编写OpenGL游戏,我差不多完成了。我只是在Nexus 5上更新到Android 5.1.1。 该应用程序使用由LibGDX构建的子弹物理库,它是本机代码。

更新后,我的应用程序间歇性地开始崩溃。 这是崩溃堆栈的顶部:

09-06 23:34:23.664: E/art(1778): Tried to mark 0x2 not contained by any spaces
09-06 23:34:23.664: E/art(1778): Attempting see if it's a bad root
09-06 23:34:23.666: E/art(1778): Found invalid root: 0x2 
09-06 23:34:23.666: E/art(1778): Type=RootJavaFrame thread_id=14 location=Visiting method 'com.spher.cblast.world.Signal com.spher.cblast.activities.BulletLevelScene.updateBoard(float)' at dex PC 0x01a8 (native PC 0xa392ace3) vreg=9
09-06 23:34:23.666: A/art(1778): art/runtime/gc/collector/mark_sweep.cc:381] Can't mark invalid object
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289] Runtime aborting...
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289] Aborting thread:
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289] "GLThread 972" prio=5 tid=14 Runnable
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   | group="" sCount=0 dsCount=0 obj=0x12c22bc0 self=0xb4a26c00
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   | sysTid=1812 nice=0 cgrp=default sched=0/0 handle=0xb491b280
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   | state=R schedstat=( 28691639167 2902450009 24576 ) utm=2811 stm=58 core=0 HZ=100
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   | stack=0xb353e000-0xb3540000 stackSize=1036KB
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   | held mutexes= "abort lock" "mutator lock"(shared held)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #00 pc 00004e64  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #01 pc 00003665  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #02 pc 00256429  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+84)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #03 pc 00238fe7  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+158)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #04 pc 0022881d  /system/lib/libart.so (art::AbortState::DumpThread(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Thread*)+32)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #05 pc 00228a87  /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+354)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #06 pc 00228c7f  /system/lib/libart.so (art::Runtime::Abort()+82)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #07 pc 000a7371  /system/lib/libart.so (art::LogMessage::~LogMessage()+1360)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #08 pc 0012d81b  /system/lib/libart.so (bool art::gc::accounting::HeapBitmap::AtomicTestAndSet<art::gc::collector::MarkSweepMarkObjectSlowPath>(art::mirror::Object const*, art::gc::collector::MarkSweepMarkObjectSlowPath const&)+442)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #09 pc 0012d8ef  /system/lib/libart.so (art::gc::collector::MarkSweep::MarkObjectParallel(art::mirror::Object const*)+142)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #10 pc 0012eaeb  /system/lib/libart.so (art::gc::collector::MarkSweep::MarkRootParallelCallback(art::mirror::Object**, void*, art::RootInfo const&)+26)
09-06 23:34:23.904: A/art(1778): art/runtime/runtime.cc:289]   native: #11 pc 0023d86f  /system/lib/libart.so (art::ReferenceMapVisitor<art::RootCallbackVisitor>::VisitQuickFrame()+806)
09-06 23:34:23.905: A/art(1778): art/runtime/runtime.cc:289]   native: #12 pc 0023dcb9  /system/lib/libart.so (art::ReferenceMapVisitor<art::RootCallbackVisitor>::VisitFrame()+224)
09-06 23:34:23.905: A/art(1778): art/runtime/runtime.cc:289]   native: #13 pc 00231959  /system/lib/libart.so (art::StackVisitor::WalkStack(bool)+276)
09-06 23:34:23.905: A/art(1778): art/runtime/runtime.cc:289]   native: #14 pc 002336b3  /system/lib/libart.so (art::Thread::VisitRoots(void (*)(art::mirror::Object**, void*, art::RootInfo const&), void*)+994)
09-06 23:34:23.905: A/art(1778): art/runtime/runtime.cc:289]   native: #15 pc 0012db67  /system/lib/libart.so (art::gc::collector::CheckpointMarkThreadRoots::Run(art::Thread*)+126)
09-06 23:34:23.905: A/art(1778): art/runtime/runtime.cc:289]   native: #16 pc 00233c2f  /system/lib/libart.so (art::Thread::RunCheckpointFunction()+182)
09-06 23:34:23.905: A/art(1778): art/runtime/runtime.cc:289]   native: #17 pc 0008774f  /system/lib/libart.so (art::JniMethodStart(art::Thread*)+390)
09-06 23:34:23.905: A/art(1778): art/runtime/runtime.cc:289]   native: #18 pc 000c5de3  /data/dalvik-cache/arm/data@app@com.sphericalsoft.cannonblast-2@base.apk@classes.dex (Java_com_badlogic_gdx_physics_bullet_dynamics_DynamicsJNI_btDiscreteDynamicsWorld_1stepSimulation_1_1SWIG_11__JLcom_badlogic_gdx_physics_bullet_dynamics_btDiscreteDynamicsWorld_2FI+78)
09-06 23:34:23.905: A/art(1778): art/runtime/runtime.cc:289]   at com.badlogic.gdx.physics.bullet.dynamics.DynamicsJNI.btDiscreteDynamicsWorld_stepSimulation__SWIG_1(Native method)
09-06 23:34:23.905: A/art(1778): art/runtime/runtime.cc:289]   at com.badlogic.gdx.physics.bullet.dynamics.btDiscreteDynamicsWorld.stepSimulation(btDiscreteDynamicsWorld.java:71)
09-06 23:34:23.905: A/art(1778): art/runtime/runtime.cc:289]   at com.spher.cblast.activities.BulletLevelScene.updateBoard(BulletLevelScene.java:1010)

我称之为原生子弹&#39; stepSimulation&#39;方法。 不知何故,垃圾收集器似乎找到了无效的root,无论这意味着什么。堆栈跟踪始终相同。

任何想法都将不胜感激!

1 个答案:

答案 0 :(得分:0)

我相信我已经消除了我的崩溃。

我的通话流程来自:

updateBoard(Java) - &gt; Bullet :: stepSimulation(native) - &gt; collisionCallback(Java)的

在Java collisionCallback中,我正在取消引用一些对象,导致垃圾。

我修改了代码,不再丢弃collisionCallback中的对象,我从未见过崩溃。