Skip to content

[stdlib] _Int128: fix invalid overflow crash #65703

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

Conversation

theMomax
Copy link
Contributor

@theMomax theMomax commented May 5, 2023

This PR fixes a bug where multiplication of any negative value with zero would result in the overflow precondition being triggered when using _Int128. Duration exposed this bug publicly:

before:

print(Duration.seconds(-1) * 0) //  Swift/Int128.swift:662: Fatal error: Overflow in *

after:

print(Duration.seconds(-1) * 0) // 0.0 seconds

fix bug where multiplication of negative value with zero would result in overflow precondition being triggered
@theMomax
Copy link
Contributor Author

theMomax commented May 5, 2023

@swift-ci Please Build Toolchain macOS Platform

@theMomax theMomax marked this pull request as ready for review May 5, 2023 22:17
@theMomax theMomax changed the title [WIP] [stdlib] _Int128: fix invalid overflow crash [stdlib] _Int128: fix invalid overflow crash May 5, 2023
@theMomax
Copy link
Contributor Author

theMomax commented May 5, 2023

@swift-ci Please smoke test

@theMomax theMomax requested review from phausler and lorentey May 5, 2023 22:18
Copy link
Member

@lorentey lorentey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh. Thanks for finding this! 👍

@lorentey
Copy link
Member

lorentey commented May 8, 2023

@swift-ci test

@theMomax theMomax merged commit 50f3241 into swiftlang:main May 9, 2023
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