Access to handle table is actually concurrent (and races / corrupts memory / crashes in practice when apps use different security contexts from different threads).
Then, unrelated to races, schan_handle_table can be reallocated and then schan_free_handles chain points to old memory location. Alternatively to patch 2, that could be fixed up on reallocating schan_handle_table, but it seems to me we can as well just scan the handle table for free slots.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/4008
---
I came across this in my attempts to implement nooverwrite maps based on
sysmem staging buffers when buffer storage is not available. My debug
modifications broke the fast path for update_sub_resource and the
wined3d_resource_wait() didn't do its job for the push constant buffers.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/3979