Closed Bug 969498 Opened 6 years ago Closed 6 years ago

[Qt] ICU usage conflict, ABORT: JS_SetICUMemoryFunctions failed.:

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla30

People

(Reporter: romaxa, Assigned: romaxa)

Details

Attachments

(1 file, 1 obsolete file)

FF with Qt Widget Backend crashes on startup:
#0  mozalloc_abort (
    msg=msg@entry=0x7fffffffc844 "[32021] ###!!! ABORT: JS_SetICUMemoryFunctions failed.: file /xpcom/build/nsXPComInit.cpp, line 559") at /memory/mozalloc/mozalloc_abort.cpp:30
#1  0x00007ffff1758d07 in Abort (
    aMsg=0x7fffffffc844 "[32021] ###!!! ABORT: JS_SetICUMemoryFunctions failed.: file /xpcom/build/nsXPComInit.cpp, line 559") at /xpcom/base/nsDebugImpl.cpp:427
#2  NS_DebugBreak (aSeverity=<optimized out>, aStr=0x7ffff39390f3 "JS_SetICUMemoryFunctions failed.", aExpr=0x0,
    aFile=0x7ffff3938b43 "/xpcom/build/nsXPComInit.cpp", aLine=559)
    at /xpcom/base/nsDebugImpl.cpp:414
#3  0x00007ffff174ec17 in NS_InitXPCOM2 (result=0x7fffffffcd98, binDirectory=<optimized out>, appFileLocationProvider=<optimized out>)
    at /xpcom/build/nsXPComInit.cpp:559
#4  0x00007ffff2e2f481 in ScopedXPCOMStartup::Initialize (this=this@entry=0x7fffffffcd98)
    at /toolkit/xre/nsAppRunner.cpp:1220
#5  0x00007ffff16fc34d in ShowProfileManager (aProfileSvc=aProfileSvc@entry=0x7fffe06bdb50, aNative=aNative@entry=0x7fffe06fff50)
    at /toolkit/xre/nsAppRunner.cpp:1920
#6  0x00007ffff2e32c4e in SelectProfile (aProfileName=0x7fffffffd1a8, aStartOffline=0x7fffffffd268, aNative=0x7fffe06fff50,
    aProfileSvc=0x7fffe06bdb50, aResult=0x7fffffffd130) at /toolkit/xre/nsAppRunner.cpp:2294
#7  XREMain::XRE_mainStartup (this=this@entry=0x7fffffffd110, aExitFlag=aExitFlag@entry=0x7fffffffd0c7)
    at /toolkit/xre/nsAppRunner.cpp:3712
#8  0x00007ffff2e349e1 in XREMain::XRE_main (this=this@entry=0x7fffffffd110, argc=argc@entry=3, argv=argv@entry=0x7fffffffe588,
    aAppData=aAppData@entry=0x7fffffffd300) at /toolkit/xre/nsAppRunner.cpp:4139
#9  0x00007ffff2e34c80 in XRE_main (argc=3, argv=0x7fffffffe588, aAppData=0x7fffffffd300, aFlags=<optimized out>)
    at /toolkit/xre/nsAppRunner.cpp:4364
#10 0x0000000000403eb0 in do_main (argc=argc@entry=3, argv=argv@entry=0x7fffffffe588, xreDirectory=0x7ffff6c2c6c0)
    at /browser/app/nsBrowserApp.cpp:282

gHeapInUse == true in there and set by

#0  uprv_malloc_52 (s=56) at /intl/icu/source/common/cmemory.c:81
#1  0x00007ffff37d22c9 in UDataMemory_createNewInstance_52 (pErr=0x7fffffffbf80)
    at /intl/icu/source/common/udatamem.c:45
#2  0x00007ffff37d09d8 in setCommonICUData (pErr=0x7fffffffbf80, warn=0 '\000', pData=0x7fffffffbdf0)
    at /intl/icu/source/common/udata.cpp:165
#3  setCommonICUDataPointer (pData=<optimized out>, pErrorCode=0x7fffffffbf80)
    at /intl/icu/source/common/udata.cpp:206
#4  openCommonData (pErrorCode=0x7fffffffbf80, commonDataIndex=0, path=0x7ffff3c4453b "icudt52l")
    at /intl/icu/source/common/udata.cpp:689
#5  doLoadFromCommonData (isICUData=isICUData@entry=1 '\001', tocEntryName=0x7fffffffbfdd "icudt52l/cnvalias.icu",
    path=path@entry=0x7ffff3c4453b "icudt52l", type=type@entry=0x7ffff4a45be4 <DATA_TYPE> "icu",
    name=name@entry=0x7ffff4a45be8 <DATA_NAME> "cnvalias",
    isAcceptable=isAcceptable@entry=0x7ffff38eaf20 <isAcceptable(void*, char const*, char const*, UDataInfo const*)>, context=context@entry=0x0,
    subErrorCode=subErrorCode@entry=0x7fffffffbf80, pErrorCode=pErrorCode@entry=0x7fffffffc26c)
    at /intl/icu/source/common/udata.cpp:1027
#6  0x00007ffff37d1753 in doOpenChoice (path=0x7ffff3c4453b "icudt52l", type=0x7ffff4a45be4 <DATA_TYPE> "icu",
    name=0x7ffff4a45be8 <DATA_NAME> "cnvalias", isAcceptable=0x7ffff38eaf20 <isAcceptable(void*, char const*, char const*, UDataInfo const*)>,
    context=0x0, pErrorCode=0x7fffffffc26c) at /intl/icu/source/common/udata.cpp:1274
#7  0x00007ffff38eb10a in initAliasData (errCode=@0x7fffffffc26c: U_ZERO_ERROR)
    at /intl/icu/source/common/ucnv_io.cpp:240
#8  0x00007ffff38ebe4a in umtx_initOnce (uio=..., fp=<optimized out>, errCode=<optimized out>)
    at /intl/icu/source/common/umutex.h:235
#9  haveAliasData (pErrorCode=<optimized out>) at /intl/icu/source/common/ucnv_io.cpp:312
#10 ucnv_getStandardName_52 (alias=0x7fffea9a5024 "UTF-8", standard=0x7fffffffbf80 "", pErrorCode=0x7ffff3c4453b)
    at /intl/icu/source/common/ucnv_io.cpp:956
#11 0x00007fffee55b00c in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#12 0x00007fffee55bb1d in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#13 0x00007fffee5578d7 in QTextCodec::codecForLocale() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#14 0x00007fffee3d7531 in QString::toLocal8Bit() const () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#15 0x00007fffee4acef9 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x00007fffee4acfb4 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#17 0x00007fffee4b17f0 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#18 0x00007fffee45d556 in QFileInfo::exists() const () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#19 0x00007fffee50fec4 in QCoreApplication::applicationFilePath() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#20 0x00007fffee511610 in QCoreApplication::applicationDirPath() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#21 0x00007fffee3492b9 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#22 0x00007fffee349612 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#23 0x00007fffee3498b0 in QLibraryInfo::location(QLibraryInfo::LibraryLocation) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#24 0x00007fffee510da9 in QCoreApplication::libraryPaths() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#25 0x00007fffee4fe35a in QFactoryLoader::update() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#26 0x00007fffee5003ed in QFactoryLoader::QFactoryLoader(char const*, QString const&, Qt::CaseSensitivity) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#27 0x00007fffef1d443d in QPlatformIntegrationFactory::create(QString const&, QStringList const&, QString const&) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#28 0x00007fffef1dc35a in QGuiApplicationPrivate::createPlatformIntegration() () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#29 0x00007fffef1dcd25 in QGuiApplicationPrivate::createEventDispatcher() () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#30 0x00007fffee510a01 in QCoreApplication::init() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#31 0x00007fffee510a76 in QCoreApplication::QCoreApplication(QCoreApplicationPrivate&) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#32 0x00007fffef1dd87d in QGuiApplication::QGuiApplication(int&, char**, int) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
So it looks like the Qt start-up code calls into ICU before we reach NS_InitXPCom2(). So we'd need to find somewhere earlier to call SetICUMemoryFunctions(). I don't know where that might be.

How important is "FF with Qt Widget Backend"? It's taken a while for anyone to hit this problem, so I guess it's a rare configuration?
> SetICUMemoryFunctions(). I don't know where that might be.

I can find that place for sure. if that is right way to fix this problem.

> 
> How important is "FF with Qt Widget Backend"? It's taken a while for anyone
> to hit this problem, so I guess it's a rare configuration?

Yep, it is rare configuration. but regardless Widget backend what if tomorrow gtk_init will start calling some icu function.... will it be broken too?
Attachment #8373358 - Flags: review?(n.nethercote)
Attachment #8373358 - Attachment is obsolete: true
Attachment #8373358 - Flags: review?(n.nethercote)
Attachment #8373379 - Flags: review?(n.nethercote)
Comment on attachment 8373379 [details] [diff] [review]
Initialize ICU reporter before QApplicationicu_fix.diff

Review of attachment 8373379 [details] [diff] [review]:
-----------------------------------------------------------------

This seems reasonable, though I'd like a second opinion from an XPCOM expert...

::: xpcom/build/nsXPComInit.cpp
@@ +402,4 @@
>  NS_IMPL_ISUPPORTS1(ICUReporter, nsIMemoryReporter)
>  
>  /* static */ Atomic<size_t> ICUReporter::sAmount;
> +static bool sICUReporterInititialized = false;

Move this inside SetICUMemoryFunction(), to minimize its exposure.
Attachment #8373379 - Flags: review?(nfroyd)
Attachment #8373379 - Flags: review?(n.nethercote)
Attachment #8373379 - Flags: review+
Comment on attachment 8373379 [details] [diff] [review]
Initialize ICU reporter before QApplicationicu_fix.diff

Review of attachment 8373379 [details] [diff] [review]:
-----------------------------------------------------------------

::: xpcom/build/nsXPCOMPrivate.h
@@ +193,4 @@
>   */
>  nsresult
>  ShutdownXPCOM(nsIServiceManager* servMgr);
> +void SetICUMemoryFunctions();

Nit: can you add a newline before this to visually separate it from ShutdownXPCOM?

::: xpcom/build/nsXPComInit.cpp
@@ +663,5 @@
> +        !JS_SetICUMemoryFunctions(ICUReporter::Alloc, ICUReporter::Realloc,
> +                                  ICUReporter::Free)) {
> +        NS_RUNTIMEABORT("JS_SetICUMemoryFunctions failed.");
> +    }
> +    sICUReporterInititialized = true;

Please restructure like so:

if (!sICUReporterInitialized) {
    if (!JS_SetICUMemoryFunctions(...)) {
    }
    sICUReporterInitialized = true;
}
Attachment #8373379 - Flags: review?(nfroyd) → review+
https://hg.mozilla.org/mozilla-central/rev/e546255a1368
Assignee: nobody → romaxa
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
You need to log in before you can comment on or make changes to this bug.