Fatal error on Android

I saw many posts on that issue, but non of them solved my problem…

--------- beginning of crash
F/libc ( 7333): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x8efff774 in tid 7333
E/DEBUG ( 3340): AM write failure (32 / Broken pipe)
E/audio_hw_primary( 326): select_devices: enter and usecase(1)
E/InputDispatcher( 1018): channel ‘393ab38d MainActivity (server)’ ~ Channel is unrecoverably broken and will be disposed!

This happens on random points on the app loading…
Is there anything i can do to get more specific info about why this happens?

The app runs smoothly on html5.

setup is:
lime 2.7.0
openfl 3.4.0
haxe 3.2.1

One thing I noticed is the different behavior in js vs droid is how it behaves with events and async methods…for example…

a = new AnyClass
a.callanAsyncmethod
a.addEventlistener(EventThrowninAsyncmethod).

somthing like that works smooth in js …but in android the “asyncMethod” waits til end throwing the event before the listener was assigned.
More traces maybe will help you to understand whats going on in the loading process

HTH
Regads
Luis

In my experience, segmentation faults are caused most often by null pointer errors. Runtime environments (like JS or Flash) tend to be more forgiving. Have you tried running on the desktop with Neko or C++? Any problems there?

the app is too big for neko i believe…

So i tried debugging on windows target, but i cant understand where do i see any stack traces from windows…?
how do i debug on that platform?

I think in Visual Studio, you can “Open Project” and select your executable. When it runs and crashes, if it was a debug build it will give you a stack trace to get a better idea what was happening when it crashed

Sure, here is the full stack trace as seen on android:
looks like all internal functions in openfl’s display list…
i have no idea how to fix this and, even worse, it happens randomly…

12-11 20:43:22.329 32737 32756 F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x975f79d0 in tid 32756 (SDLThread)
12-11 20:43:22.432  1639  1639 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-11 20:43:22.432  1639  1639 F DEBUG   : Build fingerprint: 'google/shamu/shamu:6.0/MRA58N/2289998:user/release-keys'
12-11 20:43:22.432  1639  1639 F DEBUG   : Revision: '0'
12-11 20:43:22.432  1639  1639 F DEBUG   : ABI: 'arm'
12-11 20:43:22.432  1639  1639 F DEBUG   : pid: 32737, tid: 32756, name: SDLThread  >>> demo <<<
12-11 20:43:22.432  1639  1639 F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x975f79d0
12-11 20:43:22.445  1639  1639 F DEBUG   :     r0 8784a9f0  r1 0000001a  r2 8784a9f0  r3 975f79d0
12-11 20:43:22.445  1639  1639 F DEBUG   :     r4 9f30f42c  r5 aeebcae8  r6 00000000  r7 9978ca04
12-11 20:43:22.445  1639  1639 F DEBUG   :     r8 ffffffff  r9 accbdb00  sl aeebf7ec  fp aeebf6c4
12-11 20:43:22.446  1639  1639 F DEBUG   :     ip b3af9018  sp aeebc860  lr 9e8d6328  pc 975f79d0  cpsr a0000010
12-11 20:43:22.572  1639  1639 F DEBUG   :
12-11 20:43:22.572  1639  1639 F DEBUG   : backtrace:
12-11 20:43:22.572  1639  1639 F DEBUG   :     #00 pc 000379d0  [anon:libc_malloc]
12-11 20:43:22.572  1639  1639 F DEBUG   :     #01 pc 050b9324  /data/app/org.demo-2/lib/arm/libApplicationMain.so (hx::RunFinalizers()+168)
12-11 20:43:22.572  1639  1639 F DEBUG   :     #02 pc 050bb648  /data/app/org.demo-2/lib/arm/libApplicationMain.so (GlobalAllocator::MarkAll()+712)
12-11 20:43:22.572  1639  1639 F DEBUG   :     #03 pc 050bb850  /data/app/org.demo-2/lib/arm/libApplicationMain.so (GlobalAllocator::Collect(bool, bool, bool)+436)
12-11 20:43:22.572  1639  1639 F DEBUG   :     #04 pc 050bb100  /data/app/org.demo-2/lib/arm/libApplicationMain.so (GlobalAllocator::GetFreeBlock(int, int**)+276)
12-11 20:43:22.572  1639  1639 F DEBUG   :     #05 pc 050bd00c  /data/app/org.demo-2/lib/arm/libApplicationMain.so (LocalAllocator::CallAlloc(int, unsigned int)+648)
12-11 20:43:22.572  1639  1639 F DEBUG   :     #06 pc 050bd89c  /data/app/org.demo-2/lib/arm/libApplicationMain.so (hx::InternalNew(int, bool)+360)
12-11 20:43:22.572  1639  1639 F DEBUG   :     #07 pc 0510d44c  /data/app/org.demo-2/lib/arm/libApplicationMain.so (hx::ArrayBase::Realloc(int) const+316)
12-11 20:43:22.573  1639  1639 F DEBUG   :     #08 pc 002b4208  /data/app/org.demo-2/lib/arm/libApplicationMain.so (hx::ArrayBase::EnsureSize(int) const+64)
12-11 20:43:22.573  1639  1639 F DEBUG   :     #09 pc 0510db68  /data/app/org.demo-2/lib/arm/libApplicationMain.so (hx::ArrayBase::__SetSize(int)+176)
12-11 20:43:22.573  1639  1639 F DEBUG   :     #10 pc 0510df20  /data/app/org.demo-2/lib/arm/libApplicationMain.so (hx::ArrayBase::Splice(hx::ArrayBase*, int, int)+180)
12-11 20:43:22.573  1639  1639 F DEBUG   :     #11 pc 01d466e4  /data/app/org.demo-2/lib/arm/libApplicationMain.so (Array_obj<double>::splice(int, int)+96)
12-11 20:43:22.573  1639  1639 F DEBUG   :     #12 pc 036b14ac  /data/app/org.demo-2/lib/arm/libApplicationMain.so (openfl::_internal::renderer::DrawCommandBuffer_obj::clear()+884)
12-11 20:43:22.573  1639  1639 F DEBUG   :     #13 pc 0310ebf4  /data/app/org.demo-2/lib/arm/libApplicationMain.so (openfl::display::Graphics_obj::clear()+308)
12-11 20:43:22.573  1639  1639 F DEBUG   :     #14 pc 0506fbf0  /data/app/org.demo-2/lib/arm/libApplicationMain.so (openfl::display::DisplayObject_obj::__update(bool, bool, hx::ObjectPtr<openfl::display::Graphics_obj>)+7140)
12-11 20:43:22.573  1639  1639 F DEBUG   :     #15 pc 0504257c  /data/app/org.demo-2/lib/arm/libApplicationMain.so (openfl::display::DisplayObjectContainer_obj::__update(bool, bool, hx::ObjectPtr<openfl::display::Graphics_obj>)+660)
12-11 20:43:22.573  1639  1639 F DEBUG   :     #16 pc 05042e98  /data/app/org.demo-2/lib/arm/libApplicationMain.so (openfl::display::DisplayObjectContainer_obj::__update(bool, bool, hx::ObjectPtr<openfl::display::Graphics_obj>)+2992)
12-11 20:43:22.573  1639  1639 F DEBUG   :     #17 pc 05042e98  /data/app/org.demo-2/lib/arm/libApplicationMain.so (openfl::display::DisplayObjectContainer_obj::__update(bool, bool, hx::ObjectPtr<openfl::display::Graphics_obj>)+2992)
12-11 20:43:22.574  1639  1639 F DEBUG   :     #18 pc 05042e98  /data/app/org.demo-2/lib/arm/libApplicationMain.so (openfl::display::DisplayObjectContainer_obj::__update(bool, bool, hx::ObjectPtr<openfl::display::Graphics_obj>)+2992)
12-11 20:43:22.574  1639  1639 F DEBUG   :     #19 pc 05042e98  /data/app/org.demo-2/lib/arm/libApplicationMain.so (openfl::display::DisplayObjectContainer_obj::__update(bool, bool, hx::ObjectPtr<openfl::display::Graphics_obj>)+2992)
12-11 20:43:22.574  1639  1639 F DEBUG   :     #20 pc 05042e98  /data/app/org.demo-2/lib/arm/libApplicationMain.so (openfl::display::DisplayObjectContainer_obj::__update(bool, bool, hx::ObjectPtr<openfl::display::Graphics_obj>)+2992)
12-11 20:43:22.574  1639  1639 F DEBUG   :     #21 pc 030b6d60  /data/app/org.demo-2/lib/arm/libApplicationMain.so (openfl::display::Stage_obj::__update(bool, bool, hx::ObjectPtr<openfl::display::Graphics_obj>)+3024)
12-11 20:43:22.574  1639  1639 F DEBUG   :     #22 pc 030a01fc  /data/app/org.demo-2/lib/arm/libApplicationMain.so (openfl::display::Stage_obj::render(hx::ObjectPtr<lime::graphics::Renderer_obj>)+6172)
12-11 20:43:22.574  1639  1639 F DEBUG   :     #23 pc 030c8314  /data/app/org.demo-2/lib/arm/libApplicationMain.so (lime::app::IModule_delegate_<openfl::display::Stage_obj>::render(hx::ObjectPtr<lime::graphics::Renderer_obj>)+72)
12-11 20:43:22.574  1639  1639 F DEBUG   :     #24 pc 04159760  /data/app/org.demo-2/lib/arm/libApplicationMain.so (lime::app::Application_obj::render(hx::ObjectPtr<lime::graphics::Renderer_obj>)+1204)
12-11 20:43:22.574  1639  1639 F DEBUG   :     #25 pc 04169ef4  /data/app/org.demo-2/lib/arm/libApplicationMain.so (lime::app::__Module_objrender(hx::Object*, Dynamic const&)+72)
12-11 20:43:22.574  1639  1639 F DEBUG   :     #26 pc 05127a68  /data/app/org.demo-2/lib/arm/libApplicationMain.so (hx::CMemberFunction1::__run(Dynamic const&)+64)
12-11 20:43:22.574  1639  1639 F DEBUG   :     #27 pc 002d6920  /data/app/org.demo-2/lib/arm/libApplicationMain.so (Dynamic::operator()(Dynamic const&)+72)
12-11 20:43:22.575  1639  1639 F DEBUG   :     #28 pc 04129ef4  /data/app/org.demo-2/lib/arm/libApplicationMain.so (lime::app::Application_obj::addRenderer(hx::ObjectPtr<lime::graphics::Renderer_obj>)::_Function_2_1::run()+296)
12-11 20:43:22.575  1639  1639 F DEBUG   :     #29 pc 0412a010  /data/app/org.demo-2/lib/arm/libApplicationMain.so (lime::app::Application_obj::addRenderer(hx::ObjectPtr<lime::graphics::Renderer_obj>)::_Function_2_1::__run()+20)
12-11 20:43:22.575  1639  1639 F DEBUG   :     #30 pc 002e613c  /data/app/org.demo-2/lib/arm/libApplicationMain.so (Dynamic::operator()()+64)
12-11 20:43:22.575  1639  1639 F DEBUG   :     #31 pc 041de3f4  /data/app/org.demo-2/lib/arm/libApplicationMain.so (lime::app::Event_Void_Void_obj::dispatch()+1048)
12-11 20:43:22.575  1639  1639 F DEBUG   :     #32 pc 041a96f8  /data/app/org.demo-2/lib/arm/libApplicationMain.so (lime::_backend::native::NativeApplication_obj::handleRenderEvent()+1824)
12-11 20:43:22.575  1639  1639 F DEBUG   :     #33 pc 041a9fd0  /data/app/org.demo-2/lib/arm/libApplicationMain.so (lime::_backend::native::__NativeApplication_objhandleRenderEvent(hx::Object*)+40)
12-11 20:43:22.575  1639  1639 F DEBUG   :     #34 pc 051274c4  /data/app/org.demo-2/lib/arm/libApplicationMain.so (hx::CMemberFunction0::__run()+56)
12-11 20:43:22.575  1639  1639 F DEBUG   :     #35 pc 050b053c  /data/app/org.demo-2/lib/arm/libApplicationMain.so (val_call0+56)
12-11 20:43:22.575  1639  1639 F DEBUG   :     #36 pc 0005fd14  /data/app/org.demo-2/lib/arm/liblime.so
12-11 20:43:22.575  1639  1639 F DEBUG   :     #37 pc 00057650  /data/app/org.demo-2/lib/arm/liblime.so
12-11 20:43:22.576  1639  1639 F DEBUG   :     #38 pc 00055a98  /data/app/org.demo-2/lib/arm/liblime.so
12-11 20:43:22.576  1639  1639 F DEBUG   :     #39 pc 00030cd8  /data/app/org.demo-2/lib/arm/liblime.so
12-11 20:43:22.576  1639  1639 F DEBUG   :     #40 pc 0419f9c8  /data/app/org.demo-2/lib/arm/libApplicationMain.so (lime::_backend::native::NativeApplication_obj::exec()+1548)
12-11 20:43:22.576  1639  1639 F DEBUG   :     #41 pc 0413c1e8  /data/app/org.demo-2/lib/arm/libApplicationMain.so (lime::app::Application_obj::exec()+384)
12-11 20:43:22.576  1639  1639 F DEBUG   :     #42 pc 050a4ec4  /data/app/org.demo-2/lib/arm/libApplicationMain.so (ApplicationMain_obj::create()+1848)
12-11 20:43:22.576  1639  1639 F DEBUG   :     #43 pc 050a6b3c  /data/app/org.demo-2/lib/arm/libApplicationMain.so (ApplicationMain_obj::main()+392)
12-11 20:43:22.576  1639  1639 F DEBUG   :     #44 pc 050ad9d0  /data/app/org.demo-2/lib/arm/libApplicationMain.so (__hxcpp_main+4)
12-11 20:43:22.576  1639  1639 F DEBUG   :     #45 pc 050ad8cc  /data/app/org.demo-2/lib/arm/libApplicationMain.so (hxcpp_main+40)
12-11 20:43:22.576  1639  1639 F DEBUG   :     #46 pc 050ad9c0  /data/app/org.demo-2/lib/arm/libApplicationMain.so (Java_org_haxe_HXCPP_main+12)
12-11 20:43:22.576  1639  1639 F DEBUG   :     #47 pc 00011245  /data/app/org.demo-2/oat/arm/base.odex (offset 0x11000) (void org.haxe.HXCPP.main()+72)
12-11 20:43:22.577  1639  1639 F DEBUG   :     #48 pc 00011315  /data/app/org.demo-2/oat/arm/base.odex (offset 0x11000) (void org.haxe.HXCPP.run(java.lang.String)+136)
12-11 20:43:22.577  1639  1639 F DEBUG   :     #49 pc 0001b137  /data/app/org.demo-2/oat/arm/base.odex (offset 0x11000) (void org.libsdl.app.SDLMain.run()+194)
12-11 20:43:22.577  1639  1639 F DEBUG   :     #50 pc 71a288d1  /data/dalvik-cache/arm/system@[email protected] (offset 0x1eb1000)

Strange, it seems related to garbage collection and finalizers :confused:

anything i can do to try to fix this?
or is there anything i shouldn’t do that i may be doing?

Do you think this might have been related to audio? I found an issue caused by newer Android NDK builds in the OGG decode (and possible PNG/JPEG decode as well) script

This sounds about right. In my case, png encode… Do you have a more detailed description? Maybe a test case?

The basic error was like:

function decode (const char* path) {
    
    uintptr_t ptr = NULL;
    
    if (true) {
    
        Bytes bytes = new Bytes (path);
        ptr = bytes.Data ();
        
    }
    
    // `bytes` is discarded here, before we're done with it
    
    return png_decode (ptr);
    
}

This is pseudo-code, the Android compiler was handling the scope of stack variables differently than other compilers. In the above function, the bytes variable is temporary. After leaving this function, it would be discarded from memory, but on the newer Android compiler, it would fall out of scope and be discarded within the method, before the PNG decode step was completed (since the if was already done).

It is pretty subtle, but it makes sense, but interesting that this never was a problem on other platforms that I am aware.

EDIT: This should be fixed in the current releases, so please feel free to give it a spin :success:

Does that mean this issue is fixed? NDK version was r10e in my case.

Yeah, I think it might be. I’d be happy to hear how things are working, and what modifications you see we may need to have all the functionality you need from the stack :slight_smile: