mesa: Fix tiny race condition in _mesa_debug_get_id
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 30 Jul 2021 17:57:18 +0000 (10:57 -0700)
committerMarge Bot <eric+marge@anholt.net>
Sun, 1 Aug 2021 23:58:08 +0000 (23:58 +0000)
commit5cee8434fd281ddae949883738e58e83cd577bfc
tree21d6193cb4b8ee87c983d42a9d3db60bff7b0f7d
parent5ffbee84a4b9ccfb9ba1cb7d054590cf4030353d
mesa: Fix tiny race condition in _mesa_debug_get_id

Two threads enter and see *id == 0.  Both threads update the value.
Upon returning, one of the threads might see the overwritten value some
of the time and the updated value other times.  Use cmpxchg to ensure
that there's only ever one value written to *id.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12136>
src/mesa/main/debug_output.c