libcn can abort while holding a heap locks when an assertion fails. In a simple, single thread application when _assert calls abort while holding
such a lock, the process can usually shut down cleanly.
However, in a more complicated multi-thread application this often results in the application hung in the exit list because some other thread is waiting on the lock.
We have seen this occur a number of times in _um_crumb_free_maybe_lock, but it has occurred for other assertion failures as well.
This feature request requests that libc implement an assert_locked macro and an _assert_locked function which passes a pointer to the lock handle that will be freed before abort is called if the assertion fails. A NULL pointer will indicate that there is no lock handle to be freed.
This assert_locked would replace the existing assert calls where the code knows if a lock is held, such as _um_crumb_free_maybe_lock.
Functions such as_um_lump_free_maybe_lock will pass assert_lock a NULL lock handle pointer if it was not requested to acquire the lock.
These enhancements will give that application a vastly better chance of shutting down without hanging in the exit list.
Rather than implementing the assert variants, it might be simpier to modify the existing assert and _assert to always pass a pointer to a lock handle or a NULL pointer if there is no lock handle. This will no effect on execution time if the assertion succeeds.
libcn can abort while holding a heap locks when an assertion fails. In a simple, single thread application when _assert calls abort while holding such a lock, the process can usually shut down cleanly.
However, in a more complicated multi-thread application this often results in the application hung in the exit list because some other thread is waiting on the lock.
We have seen this occur a number of times in _um_crumb_free_maybe_lock, but it has occurred for other assertion failures as well.
This feature request requests that libc implement an assert_locked macro and an _assert_locked function which passes a pointer to the lock handle that will be freed before abort is called if the assertion fails. A NULL pointer will indicate that there is no lock handle to be freed.
This assert_locked would replace the existing assert calls where the code knows if a lock is held, such as _um_crumb_free_maybe_lock.
Functions such as_um_lump_free_maybe_lock will pass assert_lock a NULL lock handle pointer if it was not requested to acquire the lock.
These enhancements will give that application a vastly better chance of shutting down without hanging in the exit list.
Rather than implementing the assert variants, it might be simpier to modify the existing assert and _assert to always pass a pointer to a lock handle or a NULL pointer if there is no lock handle. This will no effect on execution time if the assertion succeeds.