Skip to content

Commit f07d000

Browse files
authored
Merge pull request #42346 from mikeash/fix-allocator-sanity-32-bit
[Test] Make allocator_sanity.swift more robust on 32-bit.
2 parents 06cbc7e + e0d0af8 commit f07d000

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/Runtime/allocator_sanity.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ AllocationsTestSuite.test("absurd.allocation.misaligned") {
1818

1919
AllocationsTestSuite.test("absurd.allocation.gargantuan") {
2020
expectCrashLater()
21+
// There is a chance that we'll actually be able to allocate Int.max bytes on
22+
// 32-bit platforms, since they often have 4GB address spaces and Int.max is
23+
// 2GB minus one byte. Allocate twice to ensure failure. That will (attempt
24+
// to) allocate 4GB minus two bytes, and we'll definitely have more than two
25+
// bytes of other stuff in the process.
2126
let mustFail = UnsafeMutableRawPointer.allocate(byteCount: Int.max,
2227
alignment: 0)
28+
let mustFail2 = UnsafeMutableRawPointer.allocate(byteCount: Int.max,
29+
alignment: 0)
2330
expectUnreachable()
2431
_ = mustFail
32+
_ = mustFail2
2533
}
2634

2735
runAllTests()

0 commit comments

Comments
 (0)