Bug 199208 - Add HashMap.contains check in SessionStorageNamespace::removeAllowedConnection
Summary: Add HashMap.contains check in SessionStorageNamespace::removeAllowedConnection
Status: RESOLVED DUPLICATE of bug 198966
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-06-25 15:48 PDT by Alex Christensen
Modified: 2019-06-25 16:28 PDT (History)
3 users (show)

See Also:


Attachments
Patch (1.88 KB, patch)
2019-06-25 15:49 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2019-06-25 15:48:02 PDT
Add HashMap.contains check in SessionStorageNamespace::removeAllowedConnection
Comment 1 Alex Christensen 2019-06-25 15:49:56 PDT
Created attachment 372870 [details]
Patch
Comment 2 Alex Christensen 2019-06-25 15:49:58 PDT
<rdar://problem/32106147>
Comment 3 Chris Dumez 2019-06-25 15:55:22 PDT
Comment on attachment 372870 [details]
Patch

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

> Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp:485
> +    if (m_allowedConnections.contains(allowedConnection))

This change is very obscure. Based on the radar, it seems that it is trying to solve some kind of threading issue. However, looking at this code, somebody would be very tempted to refactor it to drop your contains check given that remove() is already a no-op when the key is not present.
Also, it goes against our usual coding practices to do double look-up in the case where the key is actually in the map.

I think we should find a good way to address the crash in the radar, I do not believe this is it.
Comment 4 Chris Dumez 2019-06-25 15:58:41 PDT
Comment on attachment 372870 [details]
Patch

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

>> Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp:485
>> +    if (m_allowedConnections.contains(allowedConnection))
> 
> This change is very obscure. Based on the radar, it seems that it is trying to solve some kind of threading issue. However, looking at this code, somebody would be very tempted to refactor it to drop your contains check given that remove() is already a no-op when the key is not present.
> Also, it goes against our usual coding practices to do double look-up in the case where the key is actually in the map.
> 
> I think we should find a good way to address the crash in the radar, I do not believe this is it.

This seems potentially related to https://bugs.webkit.org/show_bug.cgi?id=198966 BTW.
Comment 5 Alex Christensen 2019-06-25 16:27:31 PDT

*** This bug has been marked as a duplicate of bug 198966 ***
Comment 6 Alex Christensen 2019-06-25 16:28:10 PDT
That's why I couldn't see a missing null check.  All use is on the same serial queue, so adding a mutex wouldn't help here.