Fix race condition when clearing thumbnail
ConvertJPEGDataToImageSkiaAndNotifyObservers() copies ThumbnailImage::data_ (which is a scoped_refptr) and posts a task referring to it to another thread. ThumbnailImage::ClearData() cleared the data behind the pointer before resetting the pointer. This led to a race condition where the data was being cleared on the UI thread and read on a background thread without synchronization. This CL simply resets the pointer in ThumbnailImage::ClearData() without modifying the wrapped data. As long as the data inside is treated as immutable, this is safe: updating ThumbnailImage::data_ does not change data that outstanding tasks see. Fixed: 1160146 Change-Id: I5ef9e1712cc5935f85d1b8d9226588cc43921b67 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611174Reviewed-by:Dana Fried <dfried@chromium.org> Commit-Queue: Collin Baker <collinbaker@chromium.org> Cr-Commit-Position: refs/heads/master@{#840776}
Showing
Please register or sign in to comment