https://github.com/daniilavdeev created 
https://github.com/llvm/llvm-project/pull/176884

Recent test executions exhibited sporadic failures due to the assert 
GetNumberAllocatedModules() != 0 in the tearDown phase. The underlying cause 
was identified as the invocation of GarbageCollectAllocatedModules() with the 
parameter mandatory=false. In this mode, the function attempts to acquire a 
lock using try_lock() and, if unsuccessful, silently returns without removing 
orphaned modules. Consequently, this behavior introduced a race condition, as 
background threads could retain the lock during test teardown.

To address this issue, the parameter was changed to mandatory=true, thereby 
enforcing a blocking lock. This modification guarantees that orphaned modules 
are consistently removed during test cleanup.

>From 26724887436fe0c7566d145a3d4f8d3485a25543 Mon Sep 17 00:00:00 2001
From: Daniil Avdeev <[email protected]>
Date: Mon, 19 Jan 2026 14:37:46 +0000
Subject: [PATCH] [lldb][test] fix sporadic failures with
 NumberAllocatedModules assert

Recent test executions exhibited sporadic failures due to the assert
GetNumberAllocatedModules() != 0 in the tearDown phase. The underlying
cause was identified as the invocation of GarbageCollectAllocatedModules()
with the parameter mandatory=false. In this mode, the function attempts
to acquire a lock using try_lock() and, if unsuccessful, silently returns
without removing orphaned modules. Consequently, this behavior introduced
a race condition, as background threads could retain the lock during test
teardown.

To address this issue, the parameter was changed to mandatory=true,
thereby enforcing a blocking lock. This modification guarantees that
orphaned modules are consistently removed during test cleanup.
---
 lldb/source/API/SBModule.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 32067ac1c650f..5775ed54f2c4c 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -668,7 +668,7 @@ uint32_t SBModule::GetNumberAllocatedModules() {
 void SBModule::GarbageCollectAllocatedModules() {
   LLDB_INSTRUMENT();
 
-  const bool mandatory = false;
+  const bool mandatory = true;
   ModuleList::RemoveOrphanSharedModules(mandatory);
 }
 

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to