WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
184744
Propagate stack overflow and OOM when compiling builtins at runtime
https://bugs.webkit.org/show_bug.cgi?id=184744
Summary
Propagate stack overflow and OOM when compiling builtins at runtime
JF Bastien
Reported
2018-04-18 11:31:08 PDT
Some builtins, such as createDefaultConstructor, can get compiled at runtime and fail because of OOM or stack overflow. We should let that propagate out to JavaScript instead of crashing. Builtins which are generated at VM startup should remain hard errors.
Attachments
patch
(5.91 KB, patch)
2018-04-18 11:42 PDT
,
JF Bastien
mark.lam
: review+
mark.lam
: commit-queue-
Details
Formatted Diff
Diff
Archive of layout-test-results from ews200 for win-future
(12.65 MB, application/zip)
2018-04-18 14:46 PDT
,
EWS Watchlist
no flags
Details
hacky patch, not for landing
(13.58 KB, patch)
2018-04-19 10:10 PDT
,
JF Bastien
no flags
Details
Formatted Diff
Diff
Patch
(9.06 KB, patch)
2018-04-20 05:42 PDT
,
Robin Morisset
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
JF Bastien
Comment 1
2018-04-18 11:31:26 PDT
<
rdar://problem/39260348
>
JF Bastien
Comment 2
2018-04-18 11:42:45 PDT
Created
attachment 338233
[details]
patch
Mark Lam
Comment 3
2018-04-18 11:54:17 PDT
Comment on
attachment 338233
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=338233&action=review
As per our offline discussion, since this issue does not reproduce on Darwin, can you please hack the code to force a StackOverflow error after some N number of recursions, and verify that the fix does work as intended, and that it doesn't result in some unexpected failure condition? r=me with fixes and testing.
> JSTests/ChangeLog:9 > + * stress/create-default-constuctor-near-stack-limit.js: Added.
Please fix the name of this file: /constuctor/constructor/.
> Source/JavaScriptCore/ChangeLog:17 > + done in two ways:
nit: I would say "handled" instead of "done".
> Source/JavaScriptCore/ChangeLog:20 > + users the error type), which then puts a JS error on the execution
typo: /users/uses/?
EWS Watchlist
Comment 4
2018-04-18 14:46:28 PDT
Comment on
attachment 338233
[details]
patch
Attachment 338233
[details]
did not pass win-ews (win): Output:
http://webkit-queues.webkit.org/results/7362415
New failing tests: http/tests/security/contentSecurityPolicy/userAgentShadowDOM/allow-audio.html
EWS Watchlist
Comment 5
2018-04-18 14:46:40 PDT
Created
attachment 338264
[details]
Archive of layout-test-results from ews200 for win-future The attached test failures were seen while running run-webkit-tests on the win-ews. Bot: ews200 Port: win-future Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Saam Barati
Comment 6
2018-04-18 19:59:23 PDT
(In reply to Mark Lam from
comment #3
)
> Comment on
attachment 338233
[details]
> patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=338233&action=review
> > As per our offline discussion, since this issue does not reproduce on > Darwin, can you please hack the code to force a StackOverflow error after > some N number of recursions, and verify that the fix does work as intended, > and that it doesn't result in some unexpected failure condition?
I suggested a way to make a test to JF online. JF any luck?
> > r=me with fixes and testing. > > > JSTests/ChangeLog:9 > > + * stress/create-default-constuctor-near-stack-limit.js: Added. > > Please fix the name of this file: /constuctor/constructor/. > > > Source/JavaScriptCore/ChangeLog:17 > > + done in two ways: > > nit: I would say "handled" instead of "done". > > > Source/JavaScriptCore/ChangeLog:20 > > + users the error type), which then puts a JS error on the execution > > typo: /users/uses/?
Robin Morisset
Comment 7
2018-04-19 08:48:28 PDT
This appears to be an exact duplicate of
https://bugs.webkit.org/show_bug.cgi?id=184074
, in which I solved the exact same bug (but it was reverted due to a mistake in my handling of the exception throw scope). I am not sure exactly why my patch had to be so much larger than yours, maybe because I tried to plumb a js exception all the way through in more cases.
JF Bastien
Comment 8
2018-04-19 10:05:50 PDT
(In reply to Robin Morisset from
comment #7
)
> This appears to be an exact duplicate of >
https://bugs.webkit.org/show_bug.cgi?id=184074
, in which I solved the exact > same bug (but it was reverted due to a mistake in my handling of the > exception throw scope). > > I am not sure exactly why my patch had to be so much larger than yours, > maybe because I tried to plumb a js exception all the way through in more > cases.
Right now I've fixed some of the issues, but I think I'll end up doing almost what you did because of this: frame #1: 0x0000000100766420 JavaScriptCore`JSC::BytecodeGenerator::emitNewDefaultConstructor(this=0x0000000107850b40, dst=0x00000001078c2648, constructorKind=Base, name=0x0000000107cf9000, ecmaName=0x0000000107cf9000, classSource=0x0000000107be6078) at BytecodeGenerator.cpp:3334 frame #2: 0x0000000100791fdb JavaScriptCore`JSC::ClassExprNode::emitBytecode(this=0x0000000107be6010, generator=0x0000000107850b40, dst=0x00000001078c2648) at NodesCodegen.cpp:3987 frame #3: 0x000000010078717d JavaScriptCore`JSC::BytecodeGenerator::emitNodeInTailPosition(this=0x0000000107850b40, dst=0x00000001078c2648, n=0x0000000107be6010) at BytecodeGenerator.h:521 frame #4: 0x000000010075a15e JavaScriptCore`JSC::BytecodeGenerator::emitNode(this=0x0000000107850b40, dst=0x00000001078c2648, n=0x0000000107be6010) at BytecodeGenerator.h:510 frame #5: 0x0000000100791de9 JavaScriptCore`JSC::ClassExprNode::emitBytecode(this=0x0000000107be60b8, generator=0x0000000107850b40, dst=0x0000000000000000) at NodesCodegen.cpp:3973 frame #6: 0x000000010078717d JavaScriptCore`JSC::BytecodeGenerator::emitNodeInTailPosition(this=0x0000000107850b40, dst=0x0000000000000000, n=0x0000000107be60b8) at BytecodeGenerator.h:521 frame #7: 0x000000010075a15e JavaScriptCore`JSC::BytecodeGenerator::emitNode(this=0x0000000107850b40, dst=0x0000000000000000, n=0x0000000107be60b8) at BytecodeGenerator.h:510 frame #8: 0x0000000100772644 JavaScriptCore`JSC::BytecodeGenerator::emitNode(this=0x0000000107850b40, n=0x0000000107be60b8) at BytecodeGenerator.h:526 frame #9: 0x000000010077822a JavaScriptCore`JSC::NewExprNode::emitBytecode(this=0x0000000107be6168, generator=0x0000000107850b40, dst=0x00000001078c263c) at NodesCodegen.cpp:785 frame #10: 0x000000010078717d JavaScriptCore`JSC::BytecodeGenerator::emitNodeInTailPosition(this=0x0000000107850b40, dst=0x00000001078c263c, n=0x0000000107be6168) at BytecodeGenerator.h:521 frame #11: 0x000000010075a15e JavaScriptCore`JSC::BytecodeGenerator::emitNode(this=0x0000000107850b40, dst=0x00000001078c263c, n=0x0000000107be6168) at BytecodeGenerator.h:510 frame #12: 0x000000010078a349 JavaScriptCore`JSC::ExprStatementNode::emitBytecode(this=0x0000000107be61b8, generator=0x0000000107850b40, dst=0x00000001078c263c) at NodesCodegen.cpp:2701 frame #13: 0x000000010078b0ed JavaScriptCore`JSC::BytecodeGenerator::emitNodeInTailPosition(this=0x0000000107850b40, dst=0x00000001078c263c, n=0x0000000107be61b8) at BytecodeGenerator.h:494 frame #14: 0x000000010078a223 JavaScriptCore`JSC::SourceElements::emitBytecode(this=0x0000000107be6000, generator=0x0000000107850b40, dst=0x00000001078c263c) at NodesCodegen.cpp:2667 frame #15: 0x0000000100790277 JavaScriptCore`JSC::ScopeNode::emitStatementsBytecode(this=0x00000001078908d0, generator=0x0000000107850b40, dst=0x00000001078c263c) at NodesCodegen.cpp:3689 frame #16: 0x000000010078ffb5 JavaScriptCore`JSC::emitProgramNodeBytecode(generator=0x0000000107850b40, scopeNode=0x00000001078908d0) at NodesCodegen.cpp:3699 frame #17: 0x000000010078fec4 JavaScriptCore`JSC::ProgramNode::emitBytecode(this=0x00000001078908d0, generator=0x0000000107850b40, (null)=0x0000000000000000) at NodesCodegen.cpp:3709 frame #18: 0x000000010074acbd JavaScriptCore`JSC::BytecodeGenerator::generate(this=0x0000000107850b40) at BytecodeGenerator.cpp:152 frame #19: 0x0000000101362ea0 JavaScriptCore`JSC::ParserError JSC::BytecodeGenerator::generate<JSC::ProgramNode, JSC::UnlinkedProgramCodeBlock>(vm=0x0000000107900000, node=0x00000001078908d0, sourceCode=0x0000000107d88358, unlinkedCodeBlock=0x0000000107d84870, debuggerMode=DebuggerOff, environment=0x00007ffeefbfd050) at BytecodeGenerator.h:390 frame #20: 0x0000000101362803 JavaScriptCore`JSC::UnlinkedProgramCodeBlock* JSC::generateUnlinkedCodeBlock<JSC::UnlinkedProgramCodeBlock, JSC::ProgramExecutable>(vm=0x0000000107900000, executable=0x0000000107d88300, source=0x0000000107d88358, strictMode=NotStrict, scriptMode=Classic, debuggerMode=DebuggerOff, error=0x00007ffeefbfd4d8, evalContextType=None, variablesUnderTDZ=0x00007ffeefbfd050) at CodeCache.h:251 frame #21: 0x0000000101324230 JavaScriptCore`JSC::UnlinkedProgramCodeBlock* JSC::CodeCache::getUnlinkedGlobalCodeBlock<JSC::UnlinkedProgramCodeBlock, JSC::ProgramExecutable>(this=0x00000001078eb058, vm=0x0000000107900000, executable=0x0000000107d88300, source=0x0000000107d88358, strictMode=NotStrict, scriptMode=Classic, debuggerMode=DebuggerOff, error=0x00007ffeefbfd4d8, evalContextType=None) at CodeCache.cpp:75 frame #22: 0x0000000101323e18 JavaScriptCore`JSC::CodeCache::getUnlinkedProgramCodeBlock(this=0x00000001078eb058, vm=0x0000000107900000, executable=0x0000000107d88300, source=0x0000000107d88358, strictMode=NotStrict, debuggerMode=DebuggerOff, error=0x00007ffeefbfd4d8) at CodeCache.cpp:85 frame #23: 0x0000000101533753 JavaScriptCore`JSC::ProgramExecutable::initializeGlobalProperties(this=0x0000000107d88300, vm=0x0000000107900000, callFrame=0x0000000107de0048, scope=0x0000000107dcc000) at ProgramExecutable.cpp:98 frame #24: 0x00000001010a355e JavaScriptCore`JSC::Interpreter::executeProgram(this=0x00000001078fe200, source=0x00007ffeefbfefd0, callFrame=0x0000000107de0048, thisObj=0x0000000107da8080) at Interpreter.cpp:938 Basically, emitNewDefaultConstructor can be taught about stack overflow and OOM, but then I'd need to create a JS exception at that point. We have access to VM there, but it seems pretty icky to just do that and let it just flow upwards tot he CodeCache. Maybe it's better to fix your patch and re-land it?
JF Bastien
Comment 9
2018-04-19 10:10:38 PDT
Created
attachment 338336
[details]
hacky patch, not for landing Here's an updated patch which starts propagating some of the errors, but I think we want to go with Robin's instead since he did the whole piping. My patch also has a hacky thing to stack overflow after the VM initializes and we start interpreting. It's of course a hack for testing.
Robin Morisset
Comment 10
2018-04-20 05:42:40 PDT
Created
attachment 338412
[details]
Patch
Robin Morisset
Comment 11
2018-04-20 05:56:04 PDT
(In reply to Robin Morisset from
comment #10
)
> Created
attachment 338412
[details]
> Patch
This patch relies on the patch I just uploaded for
https://bugs.webkit.org/show_bug.cgi?id=184074
It is also currently missing a testcase (since I have not managed to get a reliable testcase for this on Mac), and a Changelog. I only uploaded it in case JF wants to take a look at it. It is a straightforward extension of my patch for
https://bugs.webkit.org/show_bug.cgi?id=184074
to also cover createDefaultConstructor.
JF Bastien
Comment 12
2018-04-20 10:44:02 PDT
Comment on
attachment 338412
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=338412&action=review
> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:3332 > + emitThrowOutOfMemoryError();
As we discussed offline this isn't quite right: you'll indeed throw the right exception at the right time, but then this code goes in the code cache and you'll throw it again if the user tries to recover! Say you go out of stack, the stack unwinds enough, and you try the same thing, you'll erroneously fail.
Filip Pizlo
Comment 13
2018-05-25 11:45:36 PDT
(In reply to JF Bastien from
comment #12
)
> Comment on
attachment 338412
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=338412&action=review
> > > Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:3332 > > + emitThrowOutOfMemoryError(); > > As we discussed offline this isn't quite right: you'll indeed throw the > right exception at the right time, but then this code goes in the code cache > and you'll throw it again if the user tries to recover! Say you go out of > stack, the stack unwinds enough, and you try the same thing, you'll > erroneously fail.
That's a progression over what we have now, so I don't think this is a reason to not land the patch.
Saam Barati
Comment 14
2018-06-19 16:10:25 PDT
I'm taking this over
Saam Barati
Comment 15
2018-06-19 22:35:26 PDT
I think this will be fixed in:
https://bugs.webkit.org/show_bug.cgi?id=184074
Saam Barati
Comment 16
2018-07-01 12:46:38 PDT
This is fixed now that we don’t use the parser in BuiltinExecutables::createExecutable
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug