[PATCH v4 2/2] vkd3d: Don't allow concurrent writes to descriptors.

Conor McCarthy conor.mccarthy.444 at gmail.com
Sun Sep 15 22:22:54 CDT 2019


On Sat, Sep 14, 2019 at 12:20 AM Derek Lesho <dlesho at codeweavers.com> wrote:

> +    pthread_spin_lock(descriptor->lock);
>

I think this isn't thread safe. If a thread tries to lock descriptor->lock
when another thread has memset the descriptor to 0, it will crash if
pthread_spin_lock() doesn't check for null.

For performance reasons I think we need to test the possibility that any
thread which meets a locked descriptor can skip the operation entirely.
This would save spinning on the lock and an extra descriptor write. If two
threads are writing the same descriptor simultaneously, this implies it's
essentially random which thread sets what data, so maybe it will work if
only the first thread writes the descriptor. Skipping can be done with
pthread_spin_trylock(), but InterlockedCompareExchange() would be simpler.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20190916/a9b7b9bf/attachment.htm>


More information about the wine-devel mailing list