<?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>212670</bug_id>
          
          <creation_ts>2020-06-02 16:51:04 -0700</creation_ts>
          <short_desc>[Win] infinite loop in ComplexTextController::indexOfCurrentRun</short_desc>
          <delta_ts>2020-06-09 13:01:14 -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>Text</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=108877</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>212944</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Fujii Hironori">fujii</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>mmaxfield</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1658505</commentid>
    <comment_count>0</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2020-06-02 16:51:04 -0700</bug_when>
    <thetext>[Win] infinite loop in ComplexTextController::indexOfCurrentRun

AppleWin, WinCairo WK1 and WK2

1. Go to https://ima.goo.ne.jp/column/writer/129.html or https://ima.goo.ne.jp/column/article/8431.html
2. The while loop in ComplexTextController::indexOfCurrentRun never quit

Callstack:

&gt; WebKit.dll!WebCore::ComplexTextController::indexOfCurrentRun(unsigned int &amp; leftmostGlyph=0) Line 526	C++
&gt; WebKit.dll!WebCore::ComplexTextController::incrementCurrentRun(unsigned int &amp; leftmostGlyph=0) Line 551	C++
&gt; WebKit.dll!WebCore::ComplexTextController::advance(unsigned int offset=38, WebCore::GlyphBuffer * glyphBuffer=0x0000000000000000, WebCore::GlyphIterationStyle iterationStyle=ByWholeGlyphs, WTF::HashSet&lt;WebCore::Font const *,WTF::PtrHash&lt;WebCore::Font const *&gt;,WTF::HashTraits&lt;WebCore::Font const *&gt;&gt; * fallbackFonts=0x000000fecbcfb068) Line 662	C++
&gt; WebKit.dll!WebCore::TextLayout::width(unsigned int from=0, unsigned int len=38, WTF::HashSet&lt;WebCore::Font const *,WTF::PtrHash&lt;WebCore::Font const *&gt;,WTF::HashTraits&lt;WebCore::Font const *&gt;&gt; * fallbackFonts=0x000000fecbcfb068) Line 69	C++
&gt; WebKit.dll!WebCore::FontCascade::width(WebCore::TextLayout &amp; layout={...}, unsigned int from=0, unsigned int len=38, WTF::HashSet&lt;WebCore::Font const *,WTF::PtrHash&lt;WebCore::Font const *&gt;,WTF::HashTraits&lt;WebCore::Font const *&gt;&gt; * fallbackFonts=0x000000fecbcfb068) Line 102	C++
&gt; WebKit.dll!WebCore::textWidth(WebCore::RenderText &amp; text={...}, unsigned int from=0, unsigned int len=38, const WebCore::FontCascade &amp; font={...}, float xPos=0.000000000, bool isFixedPitch=false, bool collapseWhiteSpace=true, WTF::HashSet&lt;WebCore::Font const *,WTF::PtrHash&lt;WebCore::Font const *&gt;,WTF::HashTraits&lt;WebCore::Font const *&gt;&gt; &amp; fallbackFonts={...}, WebCore::TextLayout * layout=0x00000205730b5f10) Line 562	C++
&gt; WebKit.dll!WebCore::BreakingContext::computeAdditionalBetweenWordsWidth(WebCore::RenderText &amp; renderText={...}, WebCore::TextLayout * textLayout=0x00000205730b5f10, char16_t currentCharacter=u&apos;さ&apos;, WebCore::WordTrailingSpace &amp; wordTrailingSpace={...}, WTF::HashSet&lt;WebCore::Font const *,WTF::PtrHash&lt;WebCore::Font const *&gt;,WTF::HashTraits&lt;WebCore::Font const *&gt;&gt; &amp; fallbackFonts={...}, WTF::Vector&lt;WebCore::WordMeasurement,64,WTF::CrashOnOverflow,16,WTF::FastMalloc&gt; &amp; wordMeasurements={...}, const WebCore::FontCascade &amp; font={...}, bool isFixedPitch=false, unsigned int lastSpace=0, float lastSpaceWordSpacing=0.000000000, float wordSpacingForWordMeasurement=0.000000000, unsigned int offset=38) Line 658	C++
&gt; WebKit.dll!WebCore::BreakingContext::handleText(WTF::Vector&lt;WebCore::WordMeasurement,64,WTF::CrashOnOverflow,16,WTF::FastMalloc&gt; &amp; wordMeasurements={...}, bool &amp; hyphenated=false, unsigned int &amp; consecutiveHyphenatedLines=0) Line 833	C++
&gt; WebKit.dll!WebCore::LineBreaker::nextLineBreak(WebCore::BidiResolverWithIsolate&lt;WebCore::InlineIterator,WebCore::BidiRun,WebCore::BidiIsolatedRun&gt; &amp; resolver={...}, WebCore::LineInfo &amp; lineInfo={...}, WebCore::RenderTextInfo &amp; renderTextInfo={...}, WebCore::FloatingObject * lastFloatFromPreviousLine=0x0000000000000000, unsigned int consecutiveHyphenatedLines=0, WTF::Vector&lt;WebCore::WordMeasurement,64,WTF::CrashOnOverflow,16,WTF::FastMalloc&gt; &amp; wordMeasurements={...}) Line 110	C++
&gt; WebKit.dll!WebCore::ComplexLineLayout::layoutRunsAndFloatsInRange(WebCore::LineLayoutState &amp; layoutState={...}, WebCore::BidiResolverWithIsolate&lt;WebCore::InlineIterator,WebCore::BidiRun,WebCore::BidiIsolatedRun&gt; &amp; resolver={...}, const WebCore::InlineIterator &amp; cleanLineStart={...}, const WebCore::BidiStatus &amp; cleanLineBidiStatus={...}, unsigned int consecutiveHyphenatedLines=0) Line 1385	C++
&gt; WebKit.dll!WebCore::ComplexLineLayout::layoutRunsAndFloats(WebCore::LineLayoutState &amp; layoutState={...}, bool hasInlineChild=true) Line 1339	C++
&gt; WebKit.dll!WebCore::ComplexLineLayout::layoutLineBoxes(bool relayoutChildren=true, WebCore::LayoutUnit &amp; repaintLogicalTop={...}, WebCore::LayoutUnit &amp; repaintLogicalBottom={...}) Line 1748	C++
&gt; WebKit.dll!WebCore::RenderBlockFlow::layoutInlineChildren(bool relayoutChildren=true, WebCore::LayoutUnit &amp; repaintLogicalTop={...}, WebCore::LayoutUnit &amp; repaintLogicalBottom={...}) Line 702	C++
&gt; WebKit.dll!WebCore::RenderBlockFlow::layoutBlock(bool relayoutChildren=true, WebCore::LayoutUnit pageLogicalHeight={...}) Line 511	C++
&gt; WebKit.dll!WebCore::RenderBlock::layout() Line 600	C++
&gt; WebKit.dll!WebCore::RenderBlockFlow::layoutBlockChild(WebCore::RenderBox &amp; child={...}, WebCore::RenderBlockFlow::MarginInfo &amp; marginInfo={...}, WebCore::LayoutUnit &amp; previousFloatLogicalBottom={...}, WebCore::LayoutUnit &amp; maxFloatLogicalBottom={...}) Line 762	C++
&gt; WebKit.dll!WebCore::RenderBlockFlow::layoutBlockChildren(bool relayoutChildren=true, WebCore::LayoutUnit &amp; maxFloatLogicalBottom={...}) Line 662	C++
&gt; WebKit.dll!WebCore::RenderBlockFlow::layoutBlock(bool relayoutChildren=true, WebCore::LayoutUnit pageLogicalHeight={...}) Line 514	C++
&gt; WebKit.dll!WebCore::RenderBlock::layout() Line 600	C++
&gt; WebKit.dll!WebCore::RenderBlockFlow::layoutBlockChild(WebCore::RenderBox &amp; child={...}, WebCore::RenderBlockFlow::MarginInfo &amp; marginInfo={...}, WebCore::LayoutUnit &amp; previousFloatLogicalBottom={...}, WebCore::LayoutUnit &amp; maxFloatLogicalBottom={...}) Line 762	C++
&gt; WebKit.dll!WebCore::RenderBlockFlow::layoutBlockChildren(bool relayoutChildren=true, WebCore::LayoutUnit &amp; maxFloatLogicalBottom={...}) Line 662	C++
&gt; WebKit.dll!WebCore::RenderBlockFlow::layoutBlock(bool relayoutChildren=true, WebCore::LayoutUnit pageLogicalHeight={...}) Line 514	C++
&gt; WebKit.dll!WebCore::RenderBlock::layout() Line 600	C++
&gt; WebKit.dll!WebCore::RenderView::layout() Line 189	C++
&gt; WebKit.dll!WebCore::FrameViewLayoutContext::layout() Line 254	C++
&gt; WebKit.dll!WebCore::Document::implicitClose() Line 3094	C++
&gt; WebKit.dll!WebCore::FrameLoader::checkCallImplicitClose() Line 966	C++
&gt; WebKit.dll!WebCore::FrameLoader::checkCompleted() Line 908	C++
&gt; WebKit.dll!WebCore::FrameLoader::finishedParsing() Line 818	C++
&gt; WebKit.dll!WebCore::Document::finishedParsing() Line 5886	C++
&gt; WebKit.dll!WebCore::HTMLConstructionSite::finishedParsing() Line 420	C++
&gt; WebKit.dll!WebCore::HTMLTreeBuilder::finished() Line 2845	C++
&gt; WebKit.dll!WebCore::HTMLDocumentParser::end() Line 450	C++
&gt; WebKit.dll!WebCore::HTMLDocumentParser::attemptToRunDeferredScriptsAndEnd() Line 459	C++
&gt; WebKit.dll!WebCore::HTMLDocumentParser::prepareToStopParsing() Line 154	C++
&gt; WebKit.dll!WebCore::HTMLDocumentParser::attemptToEnd() Line 471	C++
&gt; WebKit.dll!WebCore::HTMLDocumentParser::finish() Line 499	C++
&gt; WebKit.dll!WebCore::DocumentWriter::end() Line 289	C++
&gt; WebKit.dll!WebCore::DocumentLoader::finishedLoading() Line 453	C++
&gt; WebKit.dll!WebCore::DocumentLoader::notifyFinished(WebCore::CachedResource &amp; resource={...}, const WebCore::NetworkLoadMetrics &amp; __formal={...}) Line 397	C++
&gt; WebKit.dll!WebCore::CachedResource::checkNotify(const WebCore::NetworkLoadMetrics &amp; metrics={...}) Line 376	C++
&gt; WebKit.dll!WebCore::CachedResource::finishLoading(WebCore::SharedBuffer * __formal=0x00000205732a6350, const WebCore::NetworkLoadMetrics &amp; metrics={...}) Line 393	C++
&gt; WebKit.dll!WebCore::CachedRawResource::finishLoading(WebCore::SharedBuffer * data=0x00000205732a6350, const WebCore::NetworkLoadMetrics &amp; metrics={...}) Line 124	C++
&gt; WebKit.dll!WebCore::SubresourceLoader::didFinishLoading(const WebCore::NetworkLoadMetrics &amp; networkLoadMetrics={...}) Line 734	C++
&gt; WebKit.dll!WebCore::ResourceLoader::didFinishLoading(WebCore::ResourceHandle * __formal=0x00000205732b3250) Line 732	C++
&gt; WebKit.dll!WebCore::CurlResourceHandleDelegate::curlDidComplete(WebCore::CurlRequest &amp; __formal={...}, WebCore::NetworkLoadMetrics &amp;&amp; __formal={...}) Line 164	C++
&gt; WebKit.dll!WebCore::CurlRequest::didCompleteTransfer::__l11::&lt;lambda&gt;(WebCore::CurlRequest &amp; request={...}, WebCore::CurlRequestClient &amp; client={...}) Line 466	C++
&gt; WebKit.dll!WTF::Detail::CallableWrapper&lt;void &lt;lambda&gt;(WebCore::CurlRequest &amp;, WebCore::CurlRequestClient &amp;),void,WebCore::CurlRequest &amp;,WebCore::CurlRequestClient &amp;&gt;::call(WebCore::CurlRequest &amp; &lt;in_0&gt;={...}, WebCore::CurlRequestClient &amp; &lt;in_1&gt;={...}) Line 52	C++
&gt; WebKit.dll!WTF::Function&lt;void __cdecl(WebCore::CurlRequest &amp;,WebCore::CurlRequestClient &amp;)&gt;::operator()(WebCore::CurlRequest &amp; &lt;in_0&gt;={...}, WebCore::CurlRequestClient &amp; &lt;in_1&gt;={...}) Line 85	C++
&gt; WebKit.dll!WebCore::CurlRequest::callClient::__l2::&lt;lambda&gt;() Line 184	C++
&gt; WebKit.dll!WTF::Detail::CallableWrapper&lt;void &lt;lambda&gt;(void),void&gt;::call() Line 52	C++
&gt; WTF.dll!WTF::Function&lt;void __cdecl(void)&gt;::operator()() Line 85	C++
&gt; WTF.dll!WTF::dispatchFunctionsFromMainThread() Line 96	C++
&gt; WTF.dll!WTF::ThreadingWindowWndProc(HWND__ * hWnd=0x0000000000302d22, unsigned int message=49943, unsigned __int64 wParam=0, __int64 lParam=0) Line 48	C++
&gt; user32.dll!00007ffba0cc5c0d()	Unknown
&gt; user32.dll!00007ffba0cc5602()	Unknown
&gt; MiniBrowserLib.dll!wWinMain(HINSTANCE__ * hInstance=0x00007ff783b10000, HINSTANCE__ * hPrevInstance=0x0000000000000000, wchar_t * lpstrCmdLine=0x000002056d756814, int nCmdShow=10) Line 120	C++
&gt; MiniBrowserLib.dll!dllLauncherEntryPoint(HINSTANCE__ * hInstance=0x00007ff783b10000, HINSTANCE__ * hPrevInstance=0x0000000000000000, wchar_t * lpstrCmdLine=0x000002056d756814, int nCmdShow=10) Line 140	C++
&gt; MiniBrowser.exe!wWinMain(HINSTANCE__ * hInstance=0x00007ff783b10000, HINSTANCE__ * hPrevInstance=0x0000000000000000, wchar_t * lpstrCmdLine=0x000002056d756814, int nCmdShow=10) Line 224	C++
&gt; [Inline Frame] MiniBrowser.exe!invoke_main() Line 118	C++
&gt; MiniBrowser.exe!__scrt_common_main_seh() Line 288	C++
&gt; kernel32.dll!00007ffb9f227bd4()	Unknown
&gt; ntdll.dll!00007ffba0f0ce51()	Unknown

Mac Safari doesn&apos;t seem to have this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1658506</commentid>
    <comment_count>1</comment_count>
      <attachid>400867</attachid>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2020-06-02 16:51:41 -0700</bug_when>
    <thetext>Created attachment 400867
simplified content</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1658596</commentid>
    <comment_count>2</comment_count>
      <attachid>400888</attachid>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2020-06-02 20:43:37 -0700</bug_when>
    <thetext>Created attachment 400888
reduced content</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1660516</commentid>
    <comment_count>3</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2020-06-08 17:18:32 -0700</bug_when>
    <thetext>Bug 108877 – Chromium: Hang parsing bidi control chars on Mac OS X 10.6

It&apos;s a very similar issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1660816</commentid>
    <comment_count>4</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2020-06-09 13:01:14 -0700</bug_when>
    <thetext>This bug is caused by the following reasons:

1. Windows FontCache::systemFallbackForCharacters returns &quot;Arial Unicode MS&quot; font for some Tibetan characters, but it should be &quot;Microsoft Himalaya&quot;.
   Bug 212688 – [Win] Some Tibetan characters aren&apos;t shown
2. ComplexTextControllerUniscribe simply ignores the complex text run if ScriptShape fails with USP_E_SCRIPT_NOT_IN_FONT
   Bug 212947 – [Win] ComplexTextControllerUniscribe: Retry ScriptShape with SCRIPT_UNDEFINED if it failed as USP_E_SCRIPT_NOT_IN_FONT
3. ComplexTextController::indexOfCurrentRun assumes the complex text runs are consecutive
   Bug 212944 – ComplexTextController: Use std::sort to calculate m_runIndices

Fixed in r262804 and r262803.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="0"
              isprivate="0"
          >
            <attachid>400867</attachid>
            <date>2020-06-02 16:51:41 -0700</date>
            <delta_ts>2020-06-02 20:43:37 -0700</delta_ts>
            <desc>simplified content</desc>
            <filename>b.html</filename>
            <type>text/html</type>
            <size>117</size>
            <attacher name="Fujii Hironori">fujii</attacher>
            
              <data encoding="base64">PG1ldGEgY2hhcnNldD11dGYtOD4KaMibdOC8mc2NzKbMuc2J4LyZzKTMgHDMm8yszJ1z4L29zJvM
mMy84oOWza/ig6E6L82NzIbMkMyD4oOWzIHSiS/MuMyzzKrig5bXnOOBlcym4oOXza3Nks2F4oOf
zLUK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>400888</attachid>
            <date>2020-06-02 20:43:37 -0700</date>
            <delta_ts>2020-06-02 20:43:37 -0700</delta_ts>
            <desc>reduced content</desc>
            <filename>a.html</filename>
            <type>text/html</type>
            <size>18</size>
            <attacher name="Fujii Hironori">fujii</attacher>
            
              <data encoding="base64">YSYjeDBGMTk7JiN4MDVEQzsK
</data>

          </attachment>
      

    </bug>

</bugzilla>