Bug 216934 - CrashTracer: com.apple.WebKit.Networking in NetworkSession::firstPartyHostCNAMEDomain() code
Summary: CrashTracer: com.apple.WebKit.Networking in NetworkSession::firstPartyHostCNA...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kate Cheney
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-09-24 10:10 PDT by Kate Cheney
Modified: 2020-09-24 13:16 PDT (History)
4 users (show)

See Also:


Attachments
Patch (1.57 KB, patch)
2020-09-24 10:27 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff
Patch for landing (1.62 KB, patch)
2020-09-24 10:55 PDT, Kate Cheney
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kate Cheney 2020-09-24 10:10:47 PDT
This seems to be crashing at auto iterator = m_firstPartyHostCNAMEDomains.find(firstPartyHost);
Comment 1 Kate Cheney 2020-09-24 10:12:32 PDT
<rdar://problem/69216768>
Comment 2 Kate Cheney 2020-09-24 10:27:14 PDT
Created attachment 409593 [details]
Patch
Comment 3 Alex Christensen 2020-09-24 10:40:49 PDT
Comment on attachment 409593 [details]
Patch

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

> Source/WebKit/NetworkProcess/NetworkSession.cpp:300
> +    if (firstPartyHost.isNull())

Alternatively you could use decltype(m_firstPartyHostCNAMEDomains)::isValidKey
Comment 4 Kate Cheney 2020-09-24 10:55:34 PDT
Created attachment 409599 [details]
Patch for landing
Comment 5 Kate Cheney 2020-09-24 10:55:56 PDT
(In reply to Alex Christensen from comment #3)
> Comment on attachment 409593 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=409593&action=review
> 
> > Source/WebKit/NetworkProcess/NetworkSession.cpp:300
> > +    if (firstPartyHost.isNull())
> 
> Alternatively you could use
> decltype(m_firstPartyHostCNAMEDomains)::isValidKey

fancy!!
Comment 6 EWS 2020-09-24 11:29:27 PDT
Committed r267540: <https://trac.webkit.org/changeset/267540>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 409599 [details].
Comment 7 Darin Adler 2020-09-24 12:19:09 PDT
Comment on attachment 409599 [details]
Patch for landing

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

> Source/WebKit/NetworkProcess/NetworkSession.cpp:303
> +    if (!decltype(m_firstPartyHostCNAMEDomains)::isValidKey(firstPartyHost))
> +        return WTF::nullopt;
> +
>      auto iterator = m_firstPartyHostCNAMEDomains.find(firstPartyHost);

I think our HashTable design is working against us here (and elsewhere) we should add a safeFind function that does this. Or rename cpntains/find/get/take/remove to fastContains/fastFind/fastGet/fastTake/fastRemove and make this check a part of the slower ones. Not sure about "fast" and "safe" in the naming, but I think there are many cases we’d be wiling to spend the extra branches checking for reserved hash table key values.

It’s a trickier design question if we could do this for add/set/ensure, since we’d have to define failure behavior.
Comment 8 Kate Cheney 2020-09-24 13:16:42 PDT
(In reply to Darin Adler from comment #7)
> Comment on attachment 409599 [details]
> Patch for landing
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=409599&action=review
> 
> > Source/WebKit/NetworkProcess/NetworkSession.cpp:303
> > +    if (!decltype(m_firstPartyHostCNAMEDomains)::isValidKey(firstPartyHost))
> > +        return WTF::nullopt;
> > +
> >      auto iterator = m_firstPartyHostCNAMEDomains.find(firstPartyHost);
> 
> I think our HashTable design is working against us here (and elsewhere) we
> should add a safeFind function that does this. Or rename
> cpntains/find/get/take/remove to
> fastContains/fastFind/fastGet/fastTake/fastRemove and make this check a part
> of the slower ones. Not sure about "fast" and "safe" in the naming, but I
> think there are many cases we’d be wiling to spend the extra branches
> checking for reserved hash table key values.
> 
> It’s a trickier design question if we could do this for add/set/ensure,
> since we’d have to define failure behavior.

Good idea, we can at least do the find() case to start. Tracking in rdar://problem/69521312.