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-8989] SBData incorrect for a Decimal from a Dictionary<String, Decimal> #4357
Comments
cc jingham@apple.com (JIRA User) |
I can reproduce the problem if I change the key type from However, if I change the key type to Let's consider the
So there are four bytes of padding somewhere in the tuple's storage.
Later, Checking the actual bytes of an
So the bug apparently stems from the disagreement between The bug doesn't happen with an It also doesn't happen if I use a
I have no idea how Swift chooses where to put the padding… Anyway, it seems to me that |
cc @lorentey |
Thanks for tracking this down! I agree, NativeHashedStorageContainer should go through the Swift runtime for tuple layout. |
@swift-ci create |
Please consider trying on top-of-tree, where this is fixed. I fixed this recently. dtdebugger:bin davide$ ./lldb --repl
Welcome to Swift version 5.0-dev (LLVM 2007ecfbec, Clang 9dad98a2d2, Swift fb8b9e143d).
Type :help for assistance.
1> :command script import decimal.py
registering Decimal type summaries
1> import Foundation
2> let dec: Decimal = 7
dec: Decimal = [00 21 00 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00]
3> let dict: [String: Decimal] = ["x": dec]
dict: [String : Decimal] = 1 key/value pair {
[0] = {
key = "x"
value = [00 21 00 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00]
}
}
4> |
Fixed. |
verified in swift-DEVELOPMENT-SNAPSHOT-2018-12-04-a.xctoolchain Thanks Davide! |
Environment
Xcode 10.0 (10A255) on macOS 10.13.6 (17G65)
Additional Detail from JIRA
md5: b7973f92c29d2fa2f69f42077d6a8032
Issue Description:
Here's a type formatter for
Foundation.Decimal
that returns the bytes of theDecimal
in hex:Put it in a file named
Decimal.py
, then follow along with this Swift REPL transcript:The first debugger output (after input line
2>
) shows the correct bytes for theDecimal
:[00 21 00 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00]
The second debugger output (after input line
3>
) shows incorrect bytes for theDecimal
: [00 00 00 00 00 21 00 00 07 00 00 00 00 00 00 00 00 00 00 00]The incorrect output is for an
SBData
representing a value from aDictionary<String, Decimal>
. It has four incorrect00
bytes at the beginning, and is missing the last four bytes.For more details, please consult this stackoverflow question and answer.
The text was updated successfully, but these errors were encountered: