[Safe Browsing] Fix crash in token fetching logic
When SafeBrowsingTokenFetchTracker is destroyed, it runs all of its outstanding client callbacks. However, when an access token is fetched SafeBrowsingTokenFetchTracker calls the corresponding client callback (which is a base::OnceCallback) *before* it removes that callback from the set of outstanding callbacks. The combination of these facts means that if the SafeBrowsingTokenFetchTracker is destroyed from within a client callback, a crash will occur. This indeed occurs in production (see crashes linked in bug, and note that this is behavior that dates back from the introduction of this code in SafeBrowsingTokenFetcher). This CL adds a test that exhibits the problematic flow and fixes the crash by removing the callback from the set of outstanding callbacks *before* running that callback on access token fetch. The test crashes without the fix. Bug: 1168599 Change-Id: I006bde8e48531b9912fa779a5c6c6a27acaf6fa1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2640375Reviewed-by:Xinghui Lu <xinghuilu@chromium.org> Commit-Queue: Colin Blundell <blundell@chromium.org> Cr-Commit-Position: refs/heads/master@{#846022}
Showing
Please register or sign in to comment