Closed wangjwchn closed 1 month ago
Doesn't mi_atomic_cas_weak_release
update tfree
in the failure case.
E.g. it is based on: https://en.cppreference.com/w/c/atomic/atomic_compare_exchange
Have you actually observed this execution hanging execution? On what platform as it could be the atomics are not implemented correctly in that case?
Just double-check the result. I believe you are correct. I mapped the mi_atomic_xxx
instructions to a different atomic library, which doesn't have the failure update feature that causes the issue.
I believe that there are concurrency bugs in function
mi_free_block_delayed_mt
that cause hanging.The above code segment attempts to push a node,
tfreex
, to the beginning of the concurrent linked-list-based stack, referred to asxthread_free
.If
xthread_free
is modified by other threads during the do-while loop, the program will hang becausexthread_free
has been changed ( !=tfree
), causingmi_atomic_cas_weak_release
to always fail.Moving the first line into the do-while loop can fix this issue.
The same issue occurred in another code segment of this function:
The solution is similar to the one above.