Preventing atomic-context violations in Rust code with klint
Preventing atomic-context violations in Rust code with klint
Posted Nov 21, 2023 15:58 UTC (Tue) by MarcB (subscriber, #101804)In reply to: Preventing atomic-context violations in Rust code with klint by dvrabel
Parent article: Preventing atomic-context violations in Rust code with klint
Something potentially happening at an undefined (better: unpredictable) point in time does not make it undefined behaviour.
Undefined behaviour is generally limited to things that are undefined within a given language specification. Here the specification will most likely say that memory allocations can fail and what happens if they do.
UB does not include things that are influenced by external factors. In this example, it might as well be another program that consumed all memory and causes you program's allocation to fail. So if your program panics or not does not even depend on its own quality.