Skip to content
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

[SR-6290] Bad Int values shown in Xcode variable view when viewing Dictionary with enum keys #4502

Closed
swift-ci opened this issue Nov 3, 2017 · 6 comments
Assignees
Labels
bug Something isn't working LLDB for Swift

Comments

@swift-ci
Copy link

swift-ci commented Nov 3, 2017

Previous ID SR-6290
Radar rdar://problem/35337096
Original Reporter igz (JIRA User)
Type Bug
Status Closed
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug
Assignee @keith
Priority Medium

md5: ea795ebb805bae527b2ecf72fb3ccfc7

Issue Description:

Bad integer values are shown in Xcode's variable view when inspecting dictionaries with string-based enum keys. Correct values are shown when the keys are created with the enum cases' rawValues.

Contrary to what the variable view shows, the actual values do match the input.

@belkadan
Copy link

belkadan commented Nov 3, 2017

@swift-ci create

@keith
Copy link

keith commented Nov 22, 2017

The root of this issue appears to be that the byte offsets that are calculated here https://github.com/apple/swift-lldb/blob/stable/source/Symbol/SwiftASTContext.cpp#L501-L521 are wrong. In this repro case where we have an enum for the dictionary keys, and an int for the values, the tuple created by SwiftHashedContainer has 9 bytes, the first 1 for the enum, and the other 8 for the int. Yet the offsets calculated here are 0, and 8 instead of 0 and 1. This leads us to print this garbage data instead. I'm still not entirely sure why this only affects the dictionary case, and not just any tuple with an enum and an int (the offsets in that case are also 0 and 8, but it prints correctly), but I'm still looking into that.

@keith
Copy link

keith commented Nov 22, 2017

Ok so this appears to be the case because the bytes for the key of the tuple are padded in the case of defining a tuple by itself, but they're not padded in the case they're in a dictionary. This results in the expected size of the tuple type generated by lldb to be 16 bytes, yet the data given to it is only 9 bytes. It actually seems like the solution here should be padding the key, instead of getting a different offset for the type.

@keith
Copy link

keith commented Nov 22, 2017

I've submitted a fix for this and would love feedback on it! apple/swift-lldb#259

@keith
Copy link

keith commented Dec 6, 2017

I'm still trying to debug the test failure that seems to be caused by my fix. In the meantime I've submitted a separate PR to add some tests around this use case. Currently this specific bug's test is disabled (until a fix is merged), but some related cases have been added. apple/swift-lldb#262

@keith
Copy link

keith commented Dec 14, 2017

Fixed in apple/swift-lldb#259

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 7, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LLDB for Swift
Projects
None yet
Development

No branches or pull requests

3 participants