• Corentin Wallez's avatar
    WebGPUDecoder: Fix using multiple SharedImages at the same time. · 45b2af30
    Corentin Wallez authored
    The issue when using multiple shared images was that a `ScopedAccess`
    was destroyed after it's `SharedImageRepresentation`.
    The code was similar to the following:
    
      struct Pair {
          unique_ptr<Representation> representation;
          unique_ptr<Access> access;
      };
    
      base::flat_map<Key, Pair> map;
      map.erase(some_iterator);
    
    In the Pair destructor C++ guarantees that `access` is destroyed before
    `representation` but `erase` can move one element over another, causing
    the move-assignment operator to be called. In this case the defaulted
    move-assignment would first move `representation` then `access`. Causing
    incorrect member destruction order for the move-to object.
    
    Thanks to senorblanco@ and amaiorano@ for figuring out this wasn't a
    compiler bug by jumping in the flat_map internals!
    
    Bug: chromium:1038210
    Change-Id: Ida90804a9840d1acba96a37c7cad17cf6bcc46ea
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2014927Reviewed-by: default avatarGeoff Lang <geofflang@chromium.org>
    Commit-Queue: Corentin Wallez <cwallez@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#734956}
    45b2af30
webgpu_mailbox_unittest.cc 11.5 KB