Skip to content

[Test] Make allocator_sanity.swift more robust on 32-bit. #42346

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

Merged
merged 1 commit into from
Apr 13, 2022

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented Apr 13, 2022

This test attempts to allocate Int.max bytes and asserts that it crashes. However, this can actually succeed in (some) 32-bit environments, since Int.max is only 2^32-1 bytes there. This causes spurious test failures. Ensure the test crashes by making two gargantuan allocations.

rdar://91687691

This test attempts to allocate Int.max bytes and asserts that it crashes. However, this can actually succeed in (some) 32-bit environments, since Int.max is only 2^32-1 bytes there. This causes spurious test failures. Ensure the test crashes by making two gargantuan allocations.

rdar://91687691
@mikeash
Copy link
Contributor Author

mikeash commented Apr 13, 2022

@swift-ci please test and merge

// There is a chance that we'll actually be able to allocate Int.max bytes on
// 32-bit platforms, since they often have 4GB address spaces and Int.max is
// 2GB minus one byte. Allocate twice to ensure failure. That will (attempt
// to) allocate 4GB minus two bytes, and we'll definitely have more than two
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless the platform uses separate address spaces for code and data, in which case…

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we find a situation where the system has less than three bytes allocated when this test runs, we can revisit it then. 😄

@swift-ci swift-ci merged commit f07d000 into swiftlang:main Apr 13, 2022
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