Skip to content

Commit 6f054de

Browse files
committed
[LLDB] Don't cache module sp when Activate() fails. (llvm#95586)
Currently, the instrumentation runtime is caching a library the first time it sees it in the module list. However, in some rare cases on Darwin, the cached pre-run unloaded modules are different from the runtime module that is loaded at runtime. This patch removes the cached module if the plugin fails to activate, ensuring that on subsequent calls we don't try to activate using the unloaded cached module. There are a few related bugs to fix in a follow up: CheckIfRuntimeValid should have a stronger check to ensure the module is loaded and can be activated. Further investigation in UpdateSpecialBinariesFromNewImageInfos calling ModulesDidLoad when the module list may have unloaded modules. I have not included a test for the following reasons: 1. This is an incredibly rare occurance and is only observed in a specific circumstance on Darwin. It is tied to behavior in the DynamicLoader thai is not commonly encountered. 2. It is difficult to reproduce -- this bug requires precise conditions on darwin and it is unclear how we'd reproduce that in a controlled testing environment. rdar://128971453
1 parent 7ca683c commit 6f054de

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lldb/source/Target/InstrumentationRuntime.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ void InstrumentationRuntime::ModulesDidLoad(
6060
if (CheckIfRuntimeIsValid(module_sp)) {
6161
SetRuntimeModuleSP(module_sp);
6262
Activate();
63+
if (!IsActive())
64+
SetRuntimeModuleSP({}); // Don't cache module if activation failed.
6365
return false; // Stop iterating, we're done.
6466
}
6567
}

0 commit comments

Comments
 (0)