1
Fork 0

avoid reentrant lock acquire when ThreadIds run out

This commit is contained in:
Ralf Jung 2021-07-09 20:50:08 +02:00
parent 619c27a539
commit 2750d3ac6a

View file

@ -1004,6 +1004,7 @@ impl ThreadId {
// If we somehow use up all our bits, panic so that we're not
// covering up subtle bugs of IDs being reused.
if COUNTER == u64::MAX {
drop(_guard); // in case the panic handler ends up calling `ThreadId::new()`, avoid reentrant lock acquire.
panic!("failed to generate unique thread ID: bitspace exhausted");
}