From 2750d3ac6a4f6015a7a9720b8fbcb3610aa691e1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 9 Jul 2021 20:50:08 +0200 Subject: avoid reentrant lock acquire when ThreadIds run out --- library/std/src/thread/mod.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'library/std/src/thread') diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index da2d1160493..5630904da77 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -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"); } -- cgit 1.4.1-3-g733a5