[v5 PATCH 1/3] dwrite: Protect cached fontface list when accessed from multiple threads

Sebastian Lackner sebastian at fds-team.de
Thu Aug 17 07:19:18 CDT 2017


On 15.08.2017 13:40, Nikolay Sivov wrote:
>          if (cached_key_size == key_size && !memcmp(cached_key, key, key_size)) {
> +            if (FAILED(hr = IDWriteFontFace4_QueryInterface(cached->fontface, riid, obj)))
> +                WARN("Failed to get %s from fontface, hr %#x.\n", debugstr_guid(riid), hr);
> +
>              TRACE("returning cached fontface %p\n", cached->fontface);
> -            *font_face = (IDWriteFontFace*)cached->fontface;
> -            return S_OK;
> +            break;
>          }
>      }

There is still a minor problem (no race condition though). Lets assume a fontface is
just about to be destroyed, then the code above will abort enumeration after reaching
the fontface with refcount == 0. Lets assume the newly created fontface is added
after the old one, then all following attempts to get the fontface from the cache
will fail, until the old one has finally be removed. This issue can be avoided by
doing "continue;" instead of "break;" for E_FAIL.



More information about the wine-devel mailing list