Nonreentrant
Nonreentrant describes a function or routine that cannot safely be entered again before the first invocation has completed. In practice, if a nonreentrant function is interrupted (by a signal, an interrupt handler, or another thread) and called again, it may corrupt data, return incorrect results, or crash. Reentrancy is closely related to, but not identical to, thread safety; a reentrant function can be safely interrupted and re-entered, whereas a nonreentrant one is not.
Several common causes of nonreentrancy include the use of static or global state that is modified during
Common examples include certain string-tokenization routines, memory allocators, or I/O wrappers that hold internal state. In
Mitigations focus on designing functions to be stateless or to operate on per-call context. Approaches include