RESOLVED FIXED22531
Stack overflow on PowerPC on fast/workers/use-machine-stack.html
https://bugs.webkit.org/show_bug.cgi?id=22531
Summary Stack overflow on PowerPC on fast/workers/use-machine-stack.html
Alexey Proskuryakov
Reported 2008-11-27 03:50:01 PST
Apparently, non-CTI interpreter uses a lot of stack for native calls, exhausting the whole 512K stack.
Attachments
patch (5.04 KB, patch)
2009-03-19 21:25 PDT, Geoffrey Garen
zwarich: review+
Alexey Proskuryakov
Comment 1 2008-11-27 04:04:46 PST
Also, I'm building with gcc 4.0.1 on Tiger - maybe gcc 4.2 learned to reuse stack space used by scoped variables? There's lots of src and dst variables in privateExecute().
Alexey Proskuryakov
Comment 2 2008-11-27 06:10:52 PST
"A lot" means ~7K per recursive call on this test.
Alexey Proskuryakov
Comment 3 2008-11-28 03:45:06 PST
Alexey Proskuryakov
Comment 4 2008-11-28 03:47:11 PST
This is not specific to worker threads - the same crash would happen for a thread created via JavaScriptCore API (even worse, in that case we don't control stack size of the thread).
Alexey Proskuryakov
Comment 5 2008-12-01 12:05:35 PST
Disabled the test in r38862.
Darin Adler
Comment 6 2009-01-19 14:28:31 PST
7KB per native call? Are you serious? That seems absurd.
Alexey Proskuryakov
Comment 7 2009-01-19 23:05:42 PST
I measured 7K on a debug build - release may be slightly better, but not much better: JSC::Interpreter::privateExecute(JSC::Interpreter::ExecutionFlag, JSC::RegisterFile*, JSC::ExecState*, JSC::JSValuePtr* ): +00000 000cf090 7C0802A6 mflr r0 +00004 000cf094 DBE1FFF8 stfd f31,0xfff8(SP) +00008 000cf098 2F850001 cmpwi cr7,r5,0x1 +0000c 000cf09c BDA1FFAC stmw r13,0xffac(SP) +00010 000cf0a0 429F0005 bcl 20,31,$+4 +00014 000cf0a4 90010008 stw r0,0x8(SP) +00018 000cf0a8 9421ECC0 stwu SP,0xecc0(SP) 0xecc0 is -4928, so privateExecute alone takes about 5K, and there are other methods involved in each call.
Geoffrey Garen
Comment 8 2009-03-19 21:25:33 PDT
Cameron Zwarich (cpst)
Comment 9 2009-03-19 21:27:46 PDT
Comment on attachment 28779 [details] patch r=me
Oliver Hunt
Comment 10 2009-03-19 21:27:51 PDT
Comment on attachment 28779 [details] patch r=me, though i'd like you to compare degree of reentry between ffx and us..
Geoffrey Garen
Comment 11 2009-03-19 21:32:02 PDT
Committed revision 41852. I'm not sure how important it is for JavaScript to work well on threads where the client has artificially shrunk the stack size from the default. If that turns out to be an important use case, I guess we'll want an API for specifying how much stack JS gets to use, or a mechanism for asking the OS what the stack boundary is.
Geoffrey Garen
Comment 12 2009-03-19 21:38:41 PDT
> r=me, though i'd like you to compare degree of reentry between ffx and us.. Firefox allows 400-500 -- far more than both our old 128 and our new 64. If we discover that this is a compatibility problem, we should be able to reduce the stack used by Interpreter::execute and dial up the recursion limit.
Note You need to log in before you can comment on or make changes to this bug.