Bug 163955 - Explore increasing max JSString::m_length to UINT_MAX.
Summary: Explore increasing max JSString::m_length to UINT_MAX.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Keith Miller
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-10-25 10:59 PDT by Mark Lam
Modified: 2017-08-25 14:53 PDT (History)
9 users (show)

See Also:


Attachments
Patch (2.87 KB, patch)
2017-08-25 09:33 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (2.90 KB, patch)
2017-08-25 09:36 PDT, Keith Miller
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2016-10-25 10:59:53 PDT
If there's no perf implications, we should increase max JSString::m_length to UINT_MAX to match the max StringImpl length.
Comment 1 Keith Miller 2017-08-25 09:33:09 PDT
Created attachment 319083 [details]
Patch
Comment 2 Keith Miller 2017-08-25 09:36:33 PDT
Created attachment 319085 [details]
Patch
Comment 3 Keith Miller 2017-08-25 09:37:15 PDT
rdar://problem/32001499
Comment 4 Keith Miller 2017-08-25 09:38:33 PDT
I'll watch the bots for perf changes. I doubt this should make a difference to perf
Comment 5 JF Bastien 2017-08-25 09:40:12 PDT
Comment on attachment 319085 [details]
Patch

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

What prevents size overflow without this check? Don't you want to check UINT_MAX instead of INT_MAX?

> Source/JavaScriptCore/ChangeLog:3
> +        Explore increasing max JSString::m_length to UINT_MAX.

Weird to still be "exploring" here :)
Comment 6 JF Bastien 2017-08-25 09:43:36 PDT
Comment on attachment 319085 [details]
Patch

OK Keith pointed out that size_t is misleading because string's .length returns unsigned. The assumption I have now is that tryMakeString will fail on its own, so this patch is OK. Please confirm that's the case before committing. r=me if so. Maybe needs a test?
Comment 7 WebKit Commit Bot 2017-08-25 10:27:50 PDT
Comment on attachment 319085 [details]
Patch

Clearing flags on attachment: 319085

Committed r221192: <http://trac.webkit.org/changeset/221192>
Comment 8 WebKit Commit Bot 2017-08-25 10:27:52 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Geoffrey Garen 2017-08-25 13:18:54 PDT
I don't think this patch can be right. It deletes an ASSERT and a comment explaining a problem, but it doesn't fix the problem.

Consider ThunkGenerators.cpp::stringCharLoad and similar functions:

    // load index
    jit.loadInt32Argument(0, SpecializedThunkJIT::regT1); // regT1 contains the index

    // Do an unsigned compare to simultaneously filter negative indices as well as indices that are too large
    jit.appendFailure(jit.branch32(MacroAssembler::AboveOrEqual, SpecializedThunkJIT::regT1, SpecializedThunkJIT::regT2));

    ...
Comment 10 Keith Miller 2017-08-25 13:44:22 PDT
(In reply to Geoffrey Garen from comment #9)
> I don't think this patch can be right. It deletes an ASSERT and a comment
> explaining a problem, but it doesn't fix the problem.
> 
> Consider ThunkGenerators.cpp::stringCharLoad and similar functions:
> 
>     // load index
>     jit.loadInt32Argument(0, SpecializedThunkJIT::regT1); // regT1 contains
> the index
> 
>     // Do an unsigned compare to simultaneously filter negative indices as
> well as indices that are too large
>     jit.appendFailure(jit.branch32(MacroAssembler::AboveOrEqual,
> SpecializedThunkJIT::regT1, SpecializedThunkJIT::regT2));
> 
>     ...

I think this is fine. That thunk calls the slow path (the C++ code) if it fails that check. The C++ code does the right thing for positive offsets. It will only fail if the unsigned offset they are looking for is > 2GB, which is also exceedingly unlikely. It also doesn't seem like any of the other code does the wrong thing.
Comment 11 Saam Barati 2017-08-25 14:53:26 PDT
(In reply to Keith Miller from comment #10)
> (In reply to Geoffrey Garen from comment #9)
> > I don't think this patch can be right. It deletes an ASSERT and a comment
> > explaining a problem, but it doesn't fix the problem.
> > 
> > Consider ThunkGenerators.cpp::stringCharLoad and similar functions:
> > 
> >     // load index
> >     jit.loadInt32Argument(0, SpecializedThunkJIT::regT1); // regT1 contains
> > the index
> > 
> >     // Do an unsigned compare to simultaneously filter negative indices as
> > well as indices that are too large
> >     jit.appendFailure(jit.branch32(MacroAssembler::AboveOrEqual,
> > SpecializedThunkJIT::regT1, SpecializedThunkJIT::regT2));
> > 
> >     ...
> 
> I think this is fine. That thunk calls the slow path (the C++ code) if it
> fails that check. The C++ code does the right thing for positive offsets. It
> will only fail if the unsigned offset they are looking for is > 2GB, which
> is also exceedingly unlikely. It also doesn't seem like any of the other
> code does the wrong thing.

What's "any of the other code" in this context?