RESOLVED FIXED 187256
Allow to remove MediaStreamPrivate observers when iterating over observers
https://bugs.webkit.org/show_bug.cgi?id=187256
Summary Allow to remove MediaStreamPrivate observers when iterating over observers
youenn fablet
Reported 2018-07-02 10:28:53 PDT
This will make code clearer to understand
Attachments
Patch (5.82 KB, patch)
2018-11-14 07:15 PST, youenn fablet
no flags
Patch for landing (5.98 KB, patch)
2018-11-14 09:11 PST, youenn fablet
no flags
youenn fablet
Comment 1 2018-11-14 07:15:57 PST
Eric Carlson
Comment 2 2018-11-14 09:05:41 PST
Comment on attachment 354806 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=354806&action=review > Source/WebCore/ChangeLog:8 > + Copy the set of observers in a vector before iterating over it. Nit: s/in a vector/to a vector/
youenn fablet
Comment 3 2018-11-14 09:11:55 PST
Created attachment 354815 [details] Patch for landing
Darin Adler
Comment 4 2018-11-14 09:25:06 PST
Comment on attachment 354806 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=354806&action=review > Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp:99 > + if (!m_observers.contains(observer)) > + continue; This technique is not guaranteed to work. Code could delete an Observer, then allocate a new Observer and the two might coincidentally use the same memory and have the same address. So checking "contains" on a set of weak pointers doesn’t give a guaranteed accurate answer.
WebKit Commit Bot
Comment 5 2018-11-14 09:50:45 PST
Comment on attachment 354815 [details] Patch for landing Clearing flags on attachment: 354815 Committed r238181: <https://trac.webkit.org/changeset/238181>
WebKit Commit Bot
Comment 6 2018-11-14 09:50:47 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 7 2018-11-14 09:51:27 PST
youenn fablet
Comment 8 2018-11-14 11:48:54 PST
(In reply to Darin Adler from comment #4) > Comment on attachment 354806 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=354806&action=review > > > Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp:99 > > + if (!m_observers.contains(observer)) > > + continue; > > This technique is not guaranteed to work. Code could delete an Observer, > then allocate a new Observer and the two might coincidentally use the same > memory and have the same address. So checking "contains" on a set of weak > pointers doesn’t give a guaranteed accurate answer. True, this adds some potential uncertainty when such collision happens. I guess we could have a HashSet<WeakPtr<Observer>> to fix this issue. That would add some additional count churning but maybe this is ok since we are creating a Vector already whenever iterating over observers. I am unsure whether we should fix this uncertainty.
Note You need to log in before you can comment on or make changes to this bug.