<?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>246688</bug_id>
          
          <creation_ts>2022-10-18 08:12:07 -0700</creation_ts>
          <short_desc>ASSERTION FAILED: !is8Bit()</short_desc>
          <delta_ts>2022-10-19 10:00:08 -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>Web Template Framework</component>
          <version>WebKit Nightly 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="Mikhail R. Gadelha">mikhail</reporter>
          <assigned_to name="Darin Adler">darin</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>darin</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1906464</commentid>
    <comment_count>0</comment_count>
      <attachid>463057</attachid>
    <who name="Mikhail R. Gadelha">mikhail</who>
    <bug_when>2022-10-18 08:12:07 -0700</bug_when>
    <thetext>Created attachment 463057
Testcase

Tested on linux intel 64 and ARMv7.

Running the attached test case fails with the following message:

#4  0x0045c58a in WTFCrashWithInfo () at WTF/Headers/wtf/Assertions.h:754
#5  0x0045d33e in WTF::StringImpl::characters16 (this=0x287fe14 &lt;WTF::StringImpl::s_emptyAtomString&gt;) at WTF/Headers/wtf/text/StringImpl.h:312
#6  0x0045dbea in WTF::String::characters16 (this=0xfffee9b4) at WTF/Headers/wtf/text/WTFString.h:106
#7  0x01251920 in JSC::ListFormatInput::ListFormatInput (this=0xfffee9a8, strings=...) at ../../Source/JavaScriptCore/runtime/IntlObjectInlines.h:318
#8  0x01250722 in JSC::IntlListFormat::formatToParts (this=0x2963aa8, globalObject=0x28cafd8, list=...) at ../../Source/JavaScriptCore/runtime/IntlListFormat.cpp:214
#9  0x018a7310 in JSC::intlListFormatPrototypeFuncFormatToParts (globalObject=0x28cafd8, callFrame=0xfffeeb68) at ../../Source/JavaScriptCore/runtime/IntlListFormatPrototype.cpp:101
#10 0xf3dff16a in ?? ()

Found by Igalia Fuzzing Campaign.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1906465</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-10-18 08:12:21 -0700</bug_when>
    <thetext>&lt;rdar://problem/101291623&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1906468</commentid>
    <comment_count>2</comment_count>
    <who name="Mikhail R. Gadelha">mikhail</who>
    <bug_when>2022-10-18 08:18:28 -0700</bug_when>
    <thetext>Bisect shows the regression was introduced by commit 71265755b78a83c1cc5614e3fede36899e4e3a05.

In String::convertTo16Bit(), the following line

auto convertedString = String::createUninitialized(length, destination);

calss:

StringImpl::createUninitializedInternal(unsigned length, CharacterType*&amp; data)
{
    if (!length) {
        data = nullptr;
        return *empty();
    }
    return createUninitializedInternalNonEmpty(length, data);
}

which returns *empty(), i.e., s_emptyAtomString.

Because s_emptyAtomString is always initialized with s_hashFlag8BitBuffer, the ASSERT(!is8Bit()) fails in:

const UChar* characters16() const { ASSERT(!is8Bit()); return m_data16; }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1906619</commentid>
    <comment_count>3</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-10-18 15:04:41 -0700</bug_when>
    <thetext>My mistake: we can work around this by adding an empty string check to ListFormatInput or by changing the assertion in characters16() so it only asserts when length is non-zero. Luckily the problem is only with the assertion. This pointer won’t be used for anything, so it doesn’t matter that it’s a pointer to zero 8-bit characters rather than to zero 16-bit characters.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1906620</commentid>
    <comment_count>4</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-10-18 15:05:07 -0700</bug_when>
    <thetext>This need not be treated as a security bug. There is no vulnerability here. The problem is with the assertion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1906766</commentid>
    <comment_count>5</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-10-19 08:12:53 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/5537</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1906800</commentid>
    <comment_count>6</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-10-19 10:00:05 -0700</bug_when>
    <thetext>Committed 255739@main (a7b9e4efad0c): &lt;https://commits.webkit.org/255739@main&gt;

Reviewed commits have been landed. Closing PR #5537 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>463057</attachid>
            <date>2022-10-18 08:12:07 -0700</date>
            <delta_ts>2022-10-18 08:12:07 -0700</delta_ts>
            <desc>Testcase</desc>
            <filename>bar.js</filename>
            <type>text/javascript</type>
            <size>109</size>
            <attacher name="Mikhail R. Gadelha">mikhail</attacher>
            
              <data encoding="base64">ICBfX3ZfMSA9IFsgIiIgXQogIF9fdl8yID0gbmV3IEludGwuTGlzdEZvcm1hdAogIEludGwuTGlz
dEZvcm1hdC5wcm90b3R5cGUuZm9ybWF0VG9QYXJ0cy5jYWxsKF9fdl8yLCBfX3ZfMSkKCg==
</data>

          </attachment>
      

    </bug>

</bugzilla>