increase JS helper threads stack space when MOZ_TSAN is enabled

RESOLVED FIXED in Firefox 40

Status

()

RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: froydnj, Assigned: froydnj)

Tracking

unspecified
mozilla40
Points:
---

Firefox Tracking Flags

(firefox40 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
TSan enforces a minimum stack size that's just slightly larger than our
default helper stack size.  It does this to store blobs of TSan-specific
data on each thread's stack.  Unfortunately, that means that even though
we'll actually receive a larger stack than we requested, the effective
usable space of that stack is significantly less than what we expect.
To offset TSan stealing our stack space from underneath us, increase the
default when we're running with MOZ_TSAN.
(Assignee)

Comment 1

3 years ago
Created attachment 8590856 [details] [diff] [review]
increase JS helper threads stack space when MOZ_TSAN is enabled

The comment/commit message should explain everything here.  It's not completely
obvious to me why we don't need this for MOZ_ASAN.  The comment makes a stab at
it, but I don't understand why the comments in XPCJSRuntime.cpp about ASan
needing an increased amount of stack space aren't relevant here as well.
Empirically speaking, TSan fails (on modern clang) to run the browser without
this patch, while ASan appears to be OK, so I'm letting reality win this round.
Attachment #8590856 - Flags: review?(luke)
(Assignee)

Comment 2

3 years ago
Christian might be interested in this, especially comment 1.

Comment 3

3 years ago
Comment on attachment 8590856 [details] [diff] [review]
increase JS helper threads stack space when MOZ_TSAN is enabled

Forwarding to bholley to make sure this fits into the general scheme we use for stack sizes which he's reviewed/written in the past.
Attachment #8590856 - Flags: review?(luke) → review?(bobbyholley)
Comment on attachment 8590856 [details] [diff] [review]
increase JS helper threads stack space when MOZ_TSAN is enabled

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

Why is this set here rather than with all the other stack limits on the embedding side in XPCJSRuntime.cpp? Seems like this stuff should all be embedding-controlled in general, and we should try to keep it in one place.
Attachment #8590856 - Flags: review?(bobbyholley)
(Assignee)

Comment 5

3 years ago
(In reply to Bobby Holley (:bholley) from comment #4)
> Why is this set here rather than with all the other stack limits on the
> embedding side in XPCJSRuntime.cpp? Seems like this stuff should all be
> embedding-controlled in general, and we should try to keep it in one place.

I do not know the answer to that.

It looks like bug 942984 added the bits to explicitly set the size of helper threads.  Quoth bug 942984 comment 11: "This patch just uses 512K as trying to figure out what the 'default' setting should be is super baroque, see the XPCJSRuntime constructor."

But at the same time, it's not obvious to me that the XPCJSRuntime bits should necessarily be used wholesale for the helper threads, and I can imagine that trying to say "half of the XPCJSRuntime value" (or some other fraction) might result in problems here.

Brian, since you added the stack size bits, any thoughts here?
Flags: needinfo?(bhackett1024)
The stack size for the helper threads should be independent from the stack size used for the main thread's runtime.  The things the helper threads do don't generally require recursion, except in the JS parser/emitter (which is really a design issue with the parser anyways).  Additionally, the helper threads are used by both the main thread runtime and DOM worker runtimes, which set their stack size in a different place.  It would be fine though to set the JS helper thread stack size somewhere in XPCJSRuntime, rather than in a JS source file.
Flags: needinfo?(bhackett1024)
Ok. That sounds somewhat preferable, but I'm not going to insist that Nathan do it. Nathan, feel free to flag Brian for review on this patch, since I think he's probably a better reviewer for it than I am.
(Assignee)

Comment 8

3 years ago
Comment on attachment 8590856 [details] [diff] [review]
increase JS helper threads stack space when MOZ_TSAN is enabled

Redirecting review per bholley.
Attachment #8590856 - Flags: review?(bhackett1024)
Attachment #8590856 - Flags: review?(bhackett1024) → review+
https://hg.mozilla.org/mozilla-central/rev/b896382f5368
Status: NEW → RESOLVED
Last Resolved: 3 years ago
status-firefox40: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.