Closed Bug 1417135 Opened 7 years ago Closed 6 years ago

[MIPS] js shell fails when built with --with-jemalloc

Categories

(Core :: MFBT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: dragan.mladjenovic, Assigned: dragan.mladjenovic)

Details

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36

Steps to reproduce:

Tried to build js shell: 
cd $BUILD_DIR
../configure --enable-debug --disable-optimize  --target=mipsel-linux-gnu --without-intl-api --with-jemalloc
make
./dist/bin/js 




Actual results:

Assertion failure: Storage<T>::initialized(), at $BUILD_DIR/dist/include/mozilla/ThreadLocal.h:225
Segmentation fault



Expected results:

js shell promt
Attached patch bug1417135.diff (obsolete) — Splinter Review
Since Bug 528687 mips builds without HAVE_THREAD_TLS_KEYWORD and uses ThreadLocalKeyStorage as tls storage policy. The tls variable that asserts is  jemalloc's thread_arena (https://searchfox.org/mozilla-central/source/memory/build/mozjemalloc.cpp#1221)
When run on mips the following initialization sequence occurs: 
(libstdc++.so init -> call into malloc(size_t) ->  malloc_init() -> thread_arena.init(); static constructors in js shell - >  ThreadLocalKeyStorage::ThreadLocalKeyStorage() for thread_arena.

ThreadLocalKeyStorage constructor runs after the thread_arena variable has already been "initalized" as part of malloc_init clearing its state back to zero introducing failure when malloc is called later.

This patch removes user-defined constructor leaving thread_arena to be zero initialized w/o static initializer.
Component: JavaScript Engine → MFBT
Comment on attachment 8928229 [details] [diff] [review]
bug1417135.diff

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

::: mfbt/ThreadLocal.h
@@ -131,5 @@
>  template<typename T>
>  class ThreadLocalKeyStorage
>  {
>  public:
> -  ThreadLocalKeyStorage()

It would be better to keep it but make it constexpr, it should have the same effect.
Marked the constructor as constexpr as per suggestion.
Attachment #8928229 - Attachment is obsolete: true
Attachment #8928455 - Flags: review?(mh+mozilla)
Attachment #8928455 - Flags: review?(mh+mozilla) → review+
Keywords: checkin-needed
Mentor: dragan.mladjenovic
Mentor: dragan.mladjenovic
Assignee: nobody → dragan.mladjenovic
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/4b598561eae5
Mark user-defined default constructor for ThreadLocalKeyStorage as constexpr. r=glandium
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/4b598561eae5
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: