Closed Bug 730229 Opened 8 years ago Closed 2 years ago

debug builds failure at startup


(Firefox OS Graveyard :: General, defect)

Not set


(Not tracked)



(Reporter: fabrice, Unassigned)


We're on the main thread but we don't know it early enough.

Error while mapping shared library sections: No such file or directory.
###!!! ASSERTION: invalid array index: 'i < Length()', file ../dist/include/nsTArray.h, line 576
###!!! ASSERTION: invalid array index: 'i < Length()', file ../dist/include/nsTArray.h, line 576
###!!! ASSERTION: invalid array index: 'i < Length()', file ../dist/include/nsTArray.h, line 576
Assertion failure: NS_IsMainThread_P(), at /home/fabrice/dev/b2g/inbound/hal/Hal.cpp:53

Program received signal SIGABRT, Aborted.
nanosleep () at bionic/libc/arch-arm/syscalls/nanosleep.S:15
15	    ldmfd   sp!, {r4, r7}
(gdb) bt
#0  nanosleep () at bionic/libc/arch-arm/syscalls/nanosleep.S:15
#1  0xafd18248 in sleep (seconds=<value optimized out>) at bionic/libc/unistd/sleep.c:45
#2  0xa8217f6c in android::BpServiceManager::getService (this=0x1fd08, name=<value optimized out>)
    at frameworks/base/libs/binder/IServiceManager.cpp:147
#3  0x80a0d3cc in android::BatteryService::BatteryService (this=0xebc0)
    at frameworks/base/services/sensorservice/SensorDevice.cpp:47
#4  0x80a0d436 in android::Singleton<android::BatteryService>::getInstance ()
    at frameworks/base/include/utils/Singleton.h:35
#5  0x80a0d8d0 in android::SensorDevice::activate (this=0x40bebd80, ident=<value optimized out>, handle=3, enabled=1)
    at frameworks/base/services/sensorservice/SensorDevice.cpp:193
#6  0x82d7873c in mozilla::hal_impl::SensorSwitch (aSensor=<value optimized out>, activate=true)
    at /home/fabrice/dev/b2g/inbound/hal/gonk/GonkSensor.cpp:128
#7  0x82d787e6 in mozilla::hal_impl::EnableSensorNotifications (aSensor=mozilla::hal::SENSOR_ORIENTATION)
    at /home/fabrice/dev/b2g/inbound/hal/gonk/GonkSensor.cpp:141
#8  0x82d74fb2 in mozilla::hal::EnableSensorNotifications (aSensor=mozilla::hal::SENSOR_ORIENTATION)
    at /home/fabrice/dev/b2g/inbound/hal/Hal.cpp:344
#9  0x82d7584c in mozilla::hal::RegisterSensorObserver (aSensor=mozilla::hal::SENSOR_ORIENTATION, aObserver=0x40497680)
    at /home/fabrice/dev/b2g/inbound/hal/Hal.cpp:373
#10 0x82c3af0e in nsAppShell::nsAppShell (this=0x4040d320) at /home/fabrice/dev/b2g/inbound/widget/gonk/nsAppShell.cpp:735
#11 0x82c3c908 in nsAppShellInit () at /home/fabrice/dev/b2g/inbound/widget/xpwidgets/nsAppShellSingleton.h:69
#12 0x82dae286 in nsComponentManagerImpl::KnownModule::Load (this=0x40413a20)
    at /home/fabrice/dev/b2g/inbound/xpcom/components/nsComponentManager.cpp:732
#13 0x82dae2ca in nsFactoryEntry::GetFactory (this=0x40473350)
    at /home/fabrice/dev/b2g/inbound/xpcom/components/nsComponentManager.cpp:1738
#14 0x82dae4f2 in nsComponentManagerImpl::CreateInstance (this=<value optimized out>, aClass=..., aDelegate=0x0, aIID=..., 
    aResult=0xbeac44d8) at /home/fabrice/dev/b2g/inbound/xpcom/components/nsComponentManager.cpp:974
#15 0x82dafa6a in nsComponentManagerImpl::GetService (this=0x4042c200, aClass=..., aIID=<value optimized out>, 
    result=<value optimized out>) at /home/fabrice/dev/b2g/inbound/xpcom/components/nsComponentManager.cpp:1270
#16 0x82d7b466 in CallGetService (aCID=..., aIID=..., aResult=0x0)
    at /home/fabrice/dev/b2g/inbound/objdir-prof-gonk/xpcom/build/nsComponentManagerUtils.cpp:83
#17 0x82d7b492 in nsGetServiceByCIDWithError::operator() (this=0xbeac4544, aIID=..., aInstancePtr=0x0)
    at /home/fabrice/dev/b2g/inbound/objdir-prof-gonk/xpcom/build/nsComponentManagerUtils.cpp:266
#18 0x82b10e0a in assign_from_gs_cid_with_error (this=0x40498730) at ../../../dist/include/nsCOMPtr.h:1202
#19 operator= (this=0x40498730) at ../../../dist/include/nsCOMPtr.h:693
#20 nsAppStartup::Init (this=0x40498730) at /home/fabrice/dev/b2g/inbound/toolkit/components/startup/nsAppStartup.cpp:186
#21 0x82b0b76c in nsAppStartupConstructor (aOuter=<value optimized out>, aIID=..., aResult=0xbeac45f8)
---Type <return> to continue, or q <return> to quit---
    at /home/fabrice/dev/b2g/inbound/toolkit/components/build/nsToolkitCompsModule.cpp:75
#22 0x82d811ba in mozilla::GenericFactory::CreateInstance (this=<value optimized out>, aOuter=<value optimized out>, 
    aIID=<value optimized out>, aResult=0x0)
    at /home/fabrice/dev/b2g/inbound/objdir-prof-gonk/xpcom/build/GenericFactory.cpp:48
#23 0x82dae424 in nsComponentManagerImpl::CreateInstanceByContractID (this=0x4042c200, 
    aContractID=0x832628d6 ";1", aDelegate=0x0, aIID=..., aResult=0xbeac45f8)
    at /home/fabrice/dev/b2g/inbound/xpcom/components/nsComponentManager.cpp:1064
#24 0x82daf7e6 in nsComponentManagerImpl::GetServiceByContractID (this=0x4042c200, aContractID=<value optimized out>, 
    aIID=<value optimized out>, result=<value optimized out>)
    at /home/fabrice/dev/b2g/inbound/xpcom/components/nsComponentManager.cpp:1466
#25 0x82d7b3da in CallGetService (aContractID=0x832628d6 ";1", aIID=..., aResult=0x0)
    at /home/fabrice/dev/b2g/inbound/objdir-prof-gonk/xpcom/build/nsComponentManagerUtils.cpp:94
#26 0x82d7b424 in nsGetServiceByContractID::operator() (this=<value optimized out>, aIID=..., aInstancePtr=0x0)
    at /home/fabrice/dev/b2g/inbound/objdir-prof-gonk/xpcom/build/nsComponentManagerUtils.cpp:278
#27 0x82217c36 in assign_from_gs_contractid (this=<value optimized out>, native=<value optimized out>)
    at ../../dist/include/nsCOMPtr.h:1212
#28 nsCOMPtr (this=<value optimized out>, native=<value optimized out>) at ../../dist/include/nsCOMPtr.h:615
#29 ScopedXPCOMStartup::SetWindowCreator (this=<value optimized out>, native=<value optimized out>)
    at /home/fabrice/dev/b2g/inbound/toolkit/xre/nsAppRunner.cpp:1260
#30 0x8221b9e0 in XRE_main (argc=<value optimized out>, argv=<value optimized out>, aAppData=<value optimized out>)
    at /home/fabrice/dev/b2g/inbound/toolkit/xre/nsAppRunner.cpp:3359
#31 0x00008a8a in do_main (argc=1, argv=0xbeac6cc4) at /home/fabrice/dev/b2g/inbound/b2g/app/nsBrowserApp.cpp:186
#32 main (argc=1, argv=0xbeac6cc4) at /home/fabrice/dev/b2g/inbound/b2g/app/nsBrowserApp.cpp:269
(gdb) No such file or directory.

That's a bit worrying ....
We discussed a couple of fixes for this.

But thinking again, hal is supposed to be lower-level than xpcom, so maybe the right fix for now is to just remove these assertions.
nanosleep() interrupted by SIGABRT, this may be the result of bionic libc's incorrect implementation of raise() for multithreaded programs.
The following patch should should correct the problem and provide a correct backtrace in gdb:

diff --git a/libc/unistd/raise.c b/libc/unistd/raise.c
index de099da..b7ab35a 100644
--- a/libc/unistd/raise.c
+++ b/libc/unistd/raise.c
@@ -30,5 +30,5 @@
 int raise(int signum)
-    return kill(getpid(), signum);
+    return tkill(gettid(), signum); 
Cervantes, can you file an issue for this in the B2G repo? We should probably patch the vendor bionic tree we import with repo.

Also, really nice debugging & diagnosis work.
This bug reminds me there is already one that I almost forget:
This following also shows warning in Hal.cpp:
Assertion failure: NS_IsMainThread_P(), at /home/fabrice/dev/b2g/inbound/hal/Hal.cpp:53

I bug lurking in Hal.cpp. Or there is some incorrect assertion. appears to have a landed patch but is not closed.
github issue in #7 was closed with the fix to bug 741272.  Maybe this should be duped there?
This bug is opened for assertion failure in debug build, but another problem in bionic libc is found from the backtrace. Bug 741272 is forked for the libc problem. The original assertion failure still doesn't have any clue.

If the problem is not reproducible in current debug build, the assertion failure might have already been fixed as a byproduct in some changes after the bug is opened. Then we may consider closing this bug.
Firefox OS is not being worked on
Closed: 2 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.