Skip to content

Commit 2750d3a

Browse files
committed
avoid reentrant lock acquire when ThreadIds run out
1 parent 619c27a commit 2750d3a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

library/std/src/thread/mod.rs

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

0 commit comments

Comments
 (0)