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-13837] Swift Decimal type crashes on a specific double value #3965

Closed
swift-ci opened this issue Nov 8, 2020 · 6 comments
Closed

[SR-13837] Swift Decimal type crashes on a specific double value #3965

swift-ci opened this issue Nov 8, 2020 · 6 comments

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Nov 8, 2020

Previous ID SR-13837
Radar rdar://problem/71197338
Original Reporter mohsena (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 55011e39127ea36a3fecf9509d128bc7

Issue Description:

(lldb) expr Decimal(1.9446744073709552E19)
(Decimal) $R26 = 19446744073709551616.000000

(lldb) expr Decimal(1.8446744073709552E19)
error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0).
The process has been returned to the state before expression evaluation.

(lldb) expr Decimal(2.8446744073709552E19)
(Decimal) $R28 = 28446744073709551616.000000

The value above in bold crashes Swift 1.8446744073709552E19

All other values are fine, even if I simply replace last 2E+19 with 0E+19

@typesanitizer
Copy link

@swift-ci create

@swift-ci
Copy link
Contributor Author

Comment by Glenn Olsson (JIRA)

It is not true that it is fine for all other values. I tried with a few similar numbers and some failed while some did indeed not. For instance:

1.8446744073709550E19 - OK
1.8446744073709551E19 - Fails
1.8446744073709552E19 - Fails (same as mentioned in bug report)
1.8446744073709553E19 - Fails
1.8446744073709554E19 - OK
1.8446744073709555E19 - OK

1.8446744073709550E18 - OK
1.8446744073709551E18 - OK
1.8446744073709552E18 - Fails
1.8446744073709553E18 - Fails
1.8446744073709554E18 - OK
1.8446744073709555E18 - OK

1.8446744073709550E20 - Fails
1.8446744073709551E20 - Fails
1.8446744073709552E20 - Fails
1.8446744073709553E20 - Fails
1.8446744073709554E20 - OK
1.8446744073709555E20 - OK

It is apparent that it really does not depend on the exponent nor the final digit (the only things I checked). It also seem to fail each time to run it, it is not random. It really depends on the number

@spevans
Copy link
Collaborator

spevans commented Nov 24, 2020

#2926

@xwu
Copy link
Collaborator

xwu commented Aug 21, 2021

For the overlay (i.e., macOS, etc.):
#3056

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
@FreaksOnE
Copy link

I'm still having this issue

Swift version 5.9.2 (swift-5.9.2-RELEASE)
Target: x86_64-unknown-linux-gnu

let x = Decimal(string: "0.000323730024699578384923825161654754178742")!
let y = Decimal(string: "0.000340281878241659205929686457001887171685")!
let result = x / y // crash

@FreaksOnE
Copy link

@xwu @shahmishal

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants