Skip to content

[LLDB] Don't cache module sp when Activate() fails. (#95586) #8910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

thetruestblue
Copy link

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

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
@JDevlieghere
Copy link

@swift-ci test

@JDevlieghere JDevlieghere merged commit 5f87d6e into swift/release/6.0 Jun 18, 2024
3 checks passed
@JDevlieghere JDevlieghere deleted the instrumention-runtime-activate branch June 18, 2024 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants