Bug 119191 - Regular expressions with ".?" expressions at the start and the end match the entire string
Summary: Regular expressions with ".?" expressions at the start and the end match the ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-07-28 05:12 PDT by Till Schneidereit
Modified: 2018-07-02 18:05 PDT (History)
11 users (show)

See Also:


Attachments
Patch (5.41 KB, patch)
2018-07-02 01:15 PDT, Sukolsak Sakshuwong
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews205 for win-future (12.87 MB, application/zip)
2018-07-02 04:50 PDT, EWS Watchlist
no flags Details
Patch for landing (5.66 KB, patch)
2018-07-02 17:24 PDT, Sukolsak Sakshuwong
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Till Schneidereit 2013-07-28 05:12:09 PDT
STR:

Execute the following code in JSC:

'abcdefghijk'.match('.?e.?')

Expected result:
def

Actual result:
abcdefghijk


This also happens in SpiderMonkey, so it's almost guaranteed to be a Yarr issue.
Comment 1 Till Schneidereit 2013-07-28 05:26:53 PDT
For SpiderMonkey, this regressed between two Yarr imports we did: 86639 was good, 130234 is bad.
Comment 2 Sukolsak Sakshuwong 2018-07-02 01:15:18 PDT
Created attachment 344084 [details]
Patch
Comment 3 Sukolsak Sakshuwong 2018-07-02 01:32:02 PDT
The benchmark results are at https://gist.github.com/sukolsak/da11c94998776a4dfb3340f12f7b7688. The patch doesn't seem to cause a significant slowdown. I can think of a way to optimize these cases (/.?abc.*/, /.*abc.?/, /.{0,4}abc.*/, etc), which involves storing the quantifiers of the leading and trailing dots in the DotStarEnclosure. But I'm not sure if we should do it.
Comment 4 EWS Watchlist 2018-07-02 04:50:15 PDT
Comment on attachment 344084 [details]
Patch

Attachment 344084 [details] did not pass win-ews (win):
Output: https://webkit-queues.webkit.org/results/8410946

New failing tests:
http/tests/security/canvas-remote-read-remote-video-redirect.html
http/tests/security/video-poster-cross-origin-crash2.html
Comment 5 EWS Watchlist 2018-07-02 04:50:27 PDT
Created attachment 344094 [details]
Archive of layout-test-results from ews205 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews205  Port: win-future  Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Comment 6 Michael Saboff 2018-07-02 10:55:15 PDT
Comment on attachment 344084 [details]
Patch

r=me
Comment 7 Sukolsak Sakshuwong 2018-07-02 17:12:03 PDT
Thanks!

I ran some additional benchmark tests. (Thanks rniwa and yusukesuzuki for the help!). Here are the results.

Without the patch:
    RexBench         23.00 +- 1.71ms
    JetStream Score  203.41 +- 37.830

With the patch:
    RexBench         23.19 +- 3.13ms
    JetStream Score  200.63 +- 41.824
Comment 8 Sukolsak Sakshuwong 2018-07-02 17:24:55 PDT
Created attachment 344156 [details]
Patch for landing
Comment 9 WebKit Commit Bot 2018-07-02 18:03:26 PDT
Comment on attachment 344156 [details]
Patch for landing

Clearing flags on attachment: 344156

Committed r233453: <https://trac.webkit.org/changeset/233453>
Comment 10 WebKit Commit Bot 2018-07-02 18:03:27 PDT
All reviewed patches have been landed.  Closing bug.
Comment 11 Radar WebKit Bug Importer 2018-07-02 18:05:47 PDT
<rdar://problem/41750698>