Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MSan] Mitigate use-after-dtor errors in MediaWebContentsObserver
Use-after-dtor errors can happen as a combination of two factors: 1. Destroying a PlayerInfo can potentially update the state to stopping, which notifies observers. 2. Erasing entries from the player info map destroys the PlayerInfo. If a notified observer calls `GetPlayerInfo()`, this performs a `find()` on `player_info_map_` in the middle of an `erase()` operation. In general, containers do not provide exact guarantees on the sequencing of internal operations (e.g. when the key/value are destroyed, or when the actual map entry is no longer eachable). In the case of `std::map`, this ends up causing a use-after-dtor error when the map internally performs key comparisons, since the key is destroyed before the PlayerInfo is destroyed. The solution is to defer destruction of the PlayerInfo until after the entry is already erased from the map; this guarantees the map's external invariants when external callers try to use the map. Bug: 40222690 Change-Id: I201e503bfcc918882f9d517d76a1f84ebc961e84 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5716248 Reviewed-by: Dale Curtis <[email protected]> Commit-Queue: Daniel Cheng <[email protected]> Cr-Commit-Position: refs/heads/main@{#1328962}
- Loading branch information