Bug 18649

Summary: SQUIRRELFISH: correctly handle exceptions in eval code
Product: WebKit Reporter: Cameron Zwarich (cpst) <zwarich>
Component: JavaScriptCoreAssignee: Oliver Hunt <oliver>
Status: RESOLVED FIXED    
Severity: Normal CC: oliver
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 18624    
Attachments:
Description Flags
Make eval setup a "native" callframe ggaren: review+

Description Cameron Zwarich (cpst) 2008-04-20 18:27:10 PDT
Exceptions are broken in eval code. This leads to assertion failures of the following form when running JavaScriptCore tests:

ASSERTION FAILED: it != end
(./VM/Machine.cpp:431 bool KJS::Machine::unwindCallFrame(KJS::Register**, const KJS::Instruction*&, KJS::CodeBlock*&, KJS::JSValue**&, KJS::ScopeChainNode*&, KJS::Register*&))

ASSERTION FAILED: addressOffset < instructions.size()
(/Users/Cameron/sf/JavaScriptCore/VM/CodeBlock.cpp:541 bool KJS::CodeBlock::getHandlerForVPC(const KJS::Instruction*, KJS::Instruction*&, int&))
Comment 1 Cameron Zwarich (cpst) 2008-04-20 19:13:59 PDT
The it != end assertion failure is hit when throwing an exception from eval in a global context. Global code is a special case at the beginning, because no unwind is necessary, and the rest of the function deals with the case of function code. If the eval is in a global context, then the end of the scope chain is also the top, hitting the assertion.

The addressOffset < instructions.size() assertion failure is hit when throwing an exception from eval in a function context. The top of the scope chain is an activation object, so Machine::unwindCallFrame() thinks it has succeeded when it really hasn't, passing the buck onto CodeBlock::getHandlerForVPC().
Comment 2 Oliver Hunt 2008-04-21 11:55:32 PDT
Partial fix Committed r32331
Comment 3 Oliver Hunt 2008-04-21 17:16:48 PDT
Created attachment 20743 [details]
Make eval setup a "native" callframe
Comment 4 Geoffrey Garen 2008-04-21 17:23:44 PDT
Comment on attachment 20743 [details]
Make eval setup a "native" callframe

Need to fix the other eval case. Otherwise, code looks good. Clearing review flag.
Comment 5 Geoffrey Garen 2008-04-21 17:26:47 PDT
Comment on attachment 20743 [details]
Make eval setup a "native" callframe

Sorry, the second version just calls the first, so this looks good.
Comment 6 Oliver Hunt 2008-04-21 17:45:33 PDT
Committed r32361