Skip to content

Commit f0e7ff6

Browse files
committed
[Backtracing] Add a precondition to protect against problems in future.
Because the cache uses the page addresses as its keys, we should have a precondition to check that we haven't passed an address within a page. The latter would result in confusing behaviour so it's worth diagnosing up front. rdar://117681625
1 parent cf43150 commit f0e7ff6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

stdlib/public/Backtracing/CachingMemoryReader.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class CachingMemoryReader<T: MemoryReader>: MemoryReader {
4141
}
4242

4343
private func getPage(at address: Address) throws -> UnsafeRawBufferPointer {
44+
precondition((address & Address(pageMask)) == 0)
45+
4446
if let page = cache[address] {
4547
return page
4648
}

0 commit comments

Comments
 (0)