[lldb][ObjC] Fix method list entry offset calculation (#115571) #9570
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
relative_list_list_entry_t
offset field in the Objective-C runtime is of typeint64_t
. There are cases where these offsets are negative values. For negative offsets, LLDB would currently incorrectly zero-extend the offset (dropping the fact that the offset was negative), instead producing large offsets that, when added to them_baseMethods_ptr
result in addresses that had their upper bits set (e.g.,0x00017ff81b3241b0
). We then would try toGetMethodList
from such an address but fail to read it (because it's an invalid address). This would manifest in Objective-C decls not getting completed correctly (and formatters not working). We noticed this in CI failures on our Intel bots. This happened to work fine on arm64 because we strip the upper bits when callingClassDescriptorV2::method_list_t::Read
using theFixCodeAddress
ABI plugin API (which doesn't do that on Intel).The fix is to sign-extend the offset calculation.
Example failure before this patch: