Commit 54bafc0
DOM: Fix 'ref-counted producer' Subscriber crash
This CL fixes a crash in Subscriber, which was introduced in
https://crrev.com/c/6221901, when we implemented ref-counted producers.
With ref-counted producers, Subscriber::next()/error()/complete() have
to iterate over the list of internal observers and call the respective
methods on them. However, because these methods can terminate the
subscription for a given observer, the list of internal observers can
mutate while iterating over it, which is unsafe and causes a crash.
This is essentially the implementation version of
whatwg/infra#396.
This CL fixes this bug by taking a copy of the list of internal
observers before iterating over it in each of these methods, so we can
call the methods on each registered observer, while iterating over a
stable vector that cannot be mutated (since it is a copy).
R=masonf
Bug: 40282760
Change-Id: I9ade96a95370120b4c9f7309a78d3222398aed6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6311209
Commit-Queue: Dominic Farolino <[email protected]>
Reviewed-by: Mason Freed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1426289}1 parent 82057c7 commit 54bafc0
1 file changed
+25
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
0 commit comments