<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>254582</bug_id>
          
          <creation_ts>2023-03-28 06:28:47 -0700</creation_ts>
          <short_desc>[JSC] CrashOnOverflow in CharacterClassConstructor::unicodeOpSorted()</short_desc>
          <delta_ts>2023-03-29 14:42:56 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Local Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Samuel Groß">saelo</reporter>
          <assigned_to name="Michael Saboff">msaboff</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>msaboff</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1944591</commentid>
    <comment_count>0</comment_count>
    <who name="Samuel Groß">saelo</who>
    <bug_when>2023-03-28 06:28:47 -0700</bug_when>
    <thetext>The following code triggers a crash on JSC builds from current HEAD:

    const v0 = `
        const v2 = /(?:(?=a)b){5}abcde/;
        [v0,&quot;var \u1234 = 42;&quot;,[v0,&quot;var \u1234 = 42;&quot;]];
        const t3 = v2.constructor;
        const v6 = new t3(v0, ...&quot;var \u1234 = 42;&quot;);
    `;
    eval(v0);
    // CRASH INFO
    // ==========
    // TERMSIG: 6
    // EXECUTION TIME: 16ms

Here is the backtrace from gdb:

    #0  __pthread_kill_implementation (threadid=&lt;optimized out&gt;, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
    #1  0x00007ffff16add2f in __pthread_kill_internal (signo=6, threadid=&lt;optimized out&gt;) at ./nptl/pthread_kill.c:78
    #2  0x00007ffff165eef2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
    #3  0x00007ffff1649472 in __GI_abort () at ./stdlib/abort.c:79
    #4  0x00007ffff52083f9 in WTF::CrashOnOverflow::crash () at WTF/Headers/wtf/CheckedArithmetic.h:109
    #5  0x00007ffff52083e9 in WTF::CrashOnOverflow::overflowed () at WTF/Headers/wtf/CheckedArithmetic.h:102
    #6  0x00007ffff53077e8 in WTF::Vector&lt;int, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt;::at (this=0x7fffe705d408, i=1) at WTF/Headers/wtf/Vector.h:781
    #7  0x00007ffff73a973d in WTF::Vector&lt;int, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt;::operator[] (this=0x7fffe705d408, i=1) at WTF/Headers/wtf/Vector.h:786
    #8  0x00007ffff749c45a in JSC::Yarr::CharacterClassConstructor::unicodeOpSorted (this=0x7fffffffb308, rhsMatchesUnicode=..., rhsRangesUnicode=...) at Source/JavaScriptCore/yarr/YarrPattern.cpp:786
    #9  0x00007ffff749bb25 in JSC::Yarr::CharacterClassConstructor::performSetOpWithMatches (this=0x7fffffffb308, rhsMatches=..., rhsRanges=..., rhsMatchesUnicode=..., rhsRangesUnicode=...) at Source/JavaScriptCore/yarr/YarrPattern.cpp:404
    #10 0x00007ffff74a018e in JSC::Yarr::CharacterClassConstructor::performSetOpWith (this=0x7fffffffb308, rhs=0x7fffe705d3d0) at Source/JavaScriptCore/yarr/YarrPattern.cpp:368
    #11 0x00007ffff749b00c in JSC::Yarr::YarrPatternConstructor::atomCharacterClassPopNested (this=0x7fffffffb2f8) at Source/JavaScriptCore/yarr/YarrPattern.cpp:1219
    #12 0x00007ffff74adf74 in JSC::Yarr::Parser&lt;JSC::Yarr::YarrPatternConstructor, char16_t&gt;::ClassSetParserDelegate::nestedClassEnd (this=0x7fffffffaff8) at Source/JavaScriptCore/yarr/YarrParser.h:364
    #13 0x00007ffff74ac11f in JSC::Yarr::Parser&lt;JSC::Yarr::YarrPatternConstructor, char16_t&gt;::parseClassSet (this=0x7fffffffb0f8) at Source/JavaScriptCore/yarr/YarrParser.h:1229
    #14 0x00007ffff74ab3b2 in JSC::Yarr::Parser&lt;JSC::Yarr::YarrPatternConstructor, char16_t&gt;::parseTokens (this=0x7fffffffb0f8) at Source/JavaScriptCore/yarr/YarrParser.h:1539
    #15 0x00007ffff748ffa3 in JSC::Yarr::Parser&lt;JSC::Yarr::YarrPatternConstructor, char16_t&gt;::parse (this=0x7fffffffb0f8) at Source/JavaScriptCore/yarr/YarrParser.h:1632
    #16 0x00007ffff748716e in JSC::Yarr::parse&lt;JSC::Yarr::YarrPatternConstructor&gt; (delegate=..., pattern=..., compileMode=JSC::Yarr::CompileMode::UnicodeSets, backReferenceLimit=4294967295, isNamedForwardReferenceAllowed=true) at Source/JavaScriptCore/yarr/YarrParser.h:2083
    #17 0x00007ffff73e9ded in JSC::Yarr::YarrPattern::compile (this=0x7fffffffb498, patternString=...) at Source/JavaScriptCore/yarr/YarrPattern.cpp:2053
    #18 0x00007ffff73ea1bd in JSC::Yarr::YarrPattern::YarrPattern (this=0x7fffffffb498, pattern=..., flags=..., error=@0x7fffe702103c: JSC::Yarr::ErrorCode::NoError) at Source/JavaScriptCore/yarr/YarrPattern.cpp:2093
    #19 0x00007ffff6da3e5e in JSC::RegExp::finishCreation (this=0x7fffe7021028, vm=...) at Source/JavaScriptCore/runtime/RegExp.cpp:159
    #20 0x00007ffff6da4009 in JSC::RegExp::createWithoutCaching (vm=..., patternString=..., flags=...) at Source/JavaScriptCore/runtime/RegExp.cpp:197
    #21 0x00007ffff6da40ec in JSC::RegExpCache::lookupOrCreate (this=0x7fffe704c0c0, patternString=..., flags=...) at Source/JavaScriptCore/runtime/RegExpCache.cpp:42
    #22 0x00007ffff6da4058 in JSC::RegExp::create (vm=..., patternString=..., flags=...) at Source/JavaScriptCore/runtime/RegExp.cpp:203
    #23 0x00007ffff6db9383 in JSC::regExpCreate (globalObject=0x7fffa541a068, newTarget=..., patternArg=..., flagsArg=...) at Source/JavaScriptCore/runtime/RegExpConstructor.cpp:234
    #24 0x00007ffff6db8fb3 in JSC::constructRegExp (globalObject=0x7fffa541a068, args=..., callee=0x7fffa54c8130, newTarget=...) at Source/JavaScriptCore/runtime/RegExpConstructor.cpp:294
    #25 0x00007ffff6db6a34 in JSC::constructWithRegExpConstructor (globalObject=0x7fffa541a068, callFrame=0x7fffffffba60) at Source/JavaScriptCore/runtime/RegExpConstructor.cpp:313
    #26 0x00007fffa6c000c7 in ?? ()
    #27 0x00007fffffffbb60 in ?? ()
    #28 0x00007ffff51e1d59 in js_trampoline_op_construct_varargs () from WebKitBuild/Debug/lib/libJavaScriptCore.so.1
    #29 0x0000000000000000 in ?? ()

It looks like a hard crash to me that is not exploitable in any way, but I&apos;m still filing this as a security issue as a precaution. Please downgrade to a non-security bug if appropriate. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1944592</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-03-28 06:28:59 -0700</bug_when>
    <thetext>&lt;rdar://problem/107314153&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1944769</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2023-03-28 15:35:49 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/12079</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1945122</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-03-29 14:42:53 -0700</bug_when>
    <thetext>Committed 262290@main (d85eafff7c3d): &lt;https://commits.webkit.org/262290@main&gt;

Reviewed commits have been landed. Closing PR #12079 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>