Bug 188032

Summary: [WIN] Crash when trying to access store pages
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: New BugsAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, ews-watchlist, jnlehner, mitz, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=188099
https://bugs.webkit.org/show_bug.cgi?id=188168
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews206 for win-future
none
Patch
none
Patch
none
Patch
ews-watchlist: commit-queue-
Archive of layout-test-results from ews204 for win-future none

Description Myles C. Maxfield 2018-07-25 17:39:08 PDT
[WIN] Regression(r213614): Crash when trying to access store pages
Comment 1 Myles C. Maxfield 2018-07-25 17:39:57 PDT
Created attachment 345806 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2018-07-25 18:01:24 PDT
<rdar://problem/42606175>
Comment 3 Brent Fulgham 2018-07-25 18:01:53 PDT
Comment on attachment 345806 [details]
Patch

R=me if the boys are happy.
Comment 4 Brent Fulgham 2018-07-25 18:03:24 PDT
S/boys/bots/
Comment 5 Myles C. Maxfield 2018-07-25 18:39:19 PDT
<rdar://problem/42467016>
Comment 6 John N. Lehner 2018-07-25 21:47:07 PDT
This won't fix rdar://problem/42467016; WebKit!WebCore::FontCascade::widthOfTextRange() is not called prior to the overflow in WebCore::GlyphBuffer::offsetAt().

Because WebCore::DisplayList::Replayer::replay() is on the stack at the time of overflow I compared WebCore::TextPainter::paintTextOrEmphasisMarks() in our previous release with today and 

 m_context.drawEmphasisMarks(font, textRun, emphasisMark, textOrigin + FloatSize(0, emphasisMarkOffset), startOffset, endOffset);

was changed to

// Replaying back a whole cached glyph run to the GraphicsContext.
m_context.translate(textOrigin);
DisplayList::Replayer replayer(m_context, *m_glyphDisplayList);
replayer.replay();
m_context.translate(-textOrigin);

If I patch out the DisplayList::Replayer::replay() call with a 5-byte NOP, the crash goes away.
Comment 7 Myles C. Maxfield 2018-07-25 22:21:38 PDT
(In reply to John N. Lehner from comment #6)
> This won't fix rdar://problem/42467016;
> WebKit!WebCore::FontCascade::widthOfTextRange() is not called prior to the
> overflow in WebCore::GlyphBuffer::offsetAt().
> 
> Because WebCore::DisplayList::Replayer::replay() is on the stack at the time
> of overflow I compared WebCore::TextPainter::paintTextOrEmphasisMarks() in
> our previous release with today and 
> 
>  m_context.drawEmphasisMarks(font, textRun, emphasisMark, textOrigin +
> FloatSize(0, emphasisMarkOffset), startOffset, endOffset);
> 
> was changed to
> 
> // Replaying back a whole cached glyph run to the GraphicsContext.
> m_context.translate(textOrigin);
> DisplayList::Replayer replayer(m_context, *m_glyphDisplayList);
> replayer.replay();
> m_context.translate(-textOrigin);
> 
> If I patch out the DisplayList::Replayer::replay() call with a 5-byte NOP,
> the crash goes away.

Ah, okay! That definitely helps.
Comment 8 Myles C. Maxfield 2018-07-25 22:26:38 PDT
Looks like https://bugs.webkit.org/show_bug.cgi?id=178750 enabled display list usage without an easy way to disable it on Windows
Comment 9 John N. Lehner 2018-07-25 22:29:09 PDT
To clarify for open source, the generateGlyphBuffer() call in WebCore::DisplayList::DrawGlyphs::apply() uses the GlyphBufferAdvance overload of GlyphBuffer::add() (!USE(WINGDI)) and that doesn't update m_offsets like 

void add(Glyph glyph, const Font* font, float width, unsigned offsetInString = noOffset, const FloatSize* offset = 0)

does, so WebCore::GlyphBuffer::offsetAt() generates the CrashOnOverflow
Comment 10 Myles C. Maxfield 2018-07-25 22:30:35 PDT
(In reply to Myles C. Maxfield from comment #8)
> Looks like https://bugs.webkit.org/show_bug.cgi?id=178750 enabled display
> list usage without an easy way to disable it on Windows

Fixing display lists to work on Windows requires either getting rid of the offsets member of GlyphBuffer or recording all the offsets in the DrawGlyphs object.
Comment 11 Myles C. Maxfield 2018-07-25 22:31:31 PDT
Tomorrow I'll get rid of the offsets member of GlyphBuffer.
Comment 12 EWS Watchlist 2018-07-26 04:35:25 PDT
Comment on attachment 345806 [details]
Patch

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

New failing tests:
http/tests/security/canvas-remote-read-remote-video-localhost.html
Comment 13 EWS Watchlist 2018-07-26 04:35:37 PDT
Created attachment 345838 [details]
Archive of layout-test-results from ews206 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews206  Port: win-future  Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Comment 14 Myles C. Maxfield 2018-07-26 19:40:12 PDT
Created attachment 345897 [details]
Patch
Comment 15 Myles C. Maxfield 2018-07-26 23:46:13 PDT
Created attachment 345902 [details]
Patch
Comment 16 Myles C. Maxfield 2018-07-27 09:16:28 PDT
Created attachment 345917 [details]
Patch
Comment 17 EWS Watchlist 2018-07-27 11:12:20 PDT
Comment on attachment 345917 [details]
Patch

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

New failing tests:
fast/text/initial-advance-in-intermediate-run-complex.html
fast/text/complex-first-glyph-with-initial-advance.html
Comment 18 EWS Watchlist 2018-07-27 11:12:32 PDT
Created attachment 345930 [details]
Archive of layout-test-results from ews204 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews204  Port: win-future  Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Comment 19 Myles C. Maxfield 2018-07-27 11:19:00 PDT
Landing despite test failures because this will fix the crash; looking into the failures today.
Comment 20 Myles C. Maxfield 2018-07-27 11:21:29 PDT
Committed r234318: <https://trac.webkit.org/changeset/234318>
Comment 21 mitz 2018-07-30 09:37:10 PDT
(In reply to Myles C. Maxfield from comment #20)
> Committed r234318: <https://trac.webkit.org/changeset/234318>

This appears to have caused bug 188168.
Comment 22 mitz 2018-07-30 09:37:56 PDT
(In reply to mitz from comment #21)
> (In reply to Myles C. Maxfield from comment #20)
> > Committed r234318: <https://trac.webkit.org/changeset/234318>
> 
> This appears to have caused bug 188168.

Oh, I guess EWS has warned of this in comment 17.