Bug 146807 - SymbolTable::entryFor() should do a bounds check before indexing into the localToEntry vector.
Summary: SymbolTable::entryFor() should do a bounds check before indexing into the loc...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-07-09 14:01 PDT by Mark Lam
Modified: 2015-07-09 16:00 PDT (History)
8 users (show)

See Also:


Attachments
the patch: testing is in progress. (2.38 KB, patch)
2015-07-09 14:11 PDT, Mark Lam
fpizlo: review-
Details | Formatted Diff | Diff
patch 2: fixed bug found by Fil. (2.38 KB, patch)
2015-07-09 14:55 PDT, Mark Lam
fpizlo: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2015-07-09 14:01:58 PDT
When we capture an argument by name and we use "arguments", we put all of the arguments into the scope.  But destructured arguments are put into the scope anonymously i.e. the SymbolTable knows that the scope offset is in use via SymbolTable::m_maxScopeOffset, but that ScopeOffset won't appear in SymbolTable::m_map.

The SymbolTable's m_localToEntry vector is synthesized from its m_map, and will have a size which is based on the largest ScopeOffset in the m_map.  If we have a scenario where the anonymous argument is at a higher ScopeOffset than all the named arguments, then the m_localsToEntry will not have an entry for it i.e. the m_localsToEntry vector will have a size that is <= the ScopeOffset of the anonymous argument.

Hence, SymbolTable::entryFor() should ensure that the requested ScopeOffset is within the bounds of the m_localToEntry vector before indexing into it.
Comment 1 Mark Lam 2015-07-09 14:03:31 PDT
<rdar://problem/20975495>
Comment 2 Mark Lam 2015-07-09 14:11:55 PDT
Created attachment 256516 [details]
the patch: testing is in progress.
Comment 3 Filip Pizlo 2015-07-09 14:21:00 PDT
Comment on attachment 256516 [details]
the patch: testing is in progress.

View in context: https://bugs.webkit.org/attachment.cgi?id=256516&action=review

> Source/JavaScriptCore/runtime/SymbolTable.cpp:133
> +    auto toEntryVector = localToEntry(locker);

This should be auto&
Comment 4 Mark Lam 2015-07-09 14:55:13 PDT
Created attachment 256527 [details]
patch 2: fixed bug found by Fil.
Comment 5 Mark Lam 2015-07-09 16:00:20 PDT
All tests have passed with no new failures.  EWS bot test failures appear to be due to pre-existing conditions.

Patch landed in r186643: <http://trac.webkit.org/r186643>.