OSDN Git Service

st/nine: Protect dtors with mutex
authorAxel Davy <axel.davy@ens.fr>
Thu, 5 Jan 2017 22:04:09 +0000 (23:04 +0100)
committerAxel Davy <axel.davy@ens.fr>
Thu, 12 Jan 2017 19:33:11 +0000 (20:33 +0100)
commit970556292b37fb9f7a64460a964e7a88503dcab6
treee5d998d46f2ac87b49dc76638f578ef5fa173099
parent5f4359ea0ed54b06d443e0ba040eb73406fc3e34
st/nine: Protect dtors with mutex

When the flag D3DCREATE_MULTITHREAD is set, a global mutex is used
to protect nine calls.
However for performance reasons, AddRef and Release didn't hold the mutex,
and instead used atomics.

Unfortunately at item release, the item can be destroyed, and that
destruction path should be protected by a mutex (at least for
some objects).

Without this patch, it is possible an app thread is in a dtor
while another thread is making gallium nine calls. It is possible
that two threads are using the same gallium pipe, which is forbiden.
The problem has been made worse with csmt, because it can cause hang,
since nine_csmt_process is not threadsafe.

Fixes Hitman hang, and possibly others.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/iunknown.c
src/gallium/state_trackers/nine/iunknown.h
src/gallium/state_trackers/nine/nine_lock.c
src/gallium/state_trackers/nine/nine_lock.h