about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-11-10 20:13:42 +0000
committerbors <bors@rust-lang.org>2022-11-10 20:13:42 +0000
commitc1a859b25a95999ba276075bbd8e284ea675b41a (patch)
tree588ad651ec53435469d21b2e488556581f79e38e
parenta3c0a023611fcaf5ae3ec242d7d60e356041d25f (diff)
parentc49e2501bfeb18c1bfc0c6deb1aeb3e59def33a5 (diff)
downloadrust-c1a859b25a95999ba276075bbd8e284ea675b41a.tar.gz
rust-c1a859b25a95999ba276075bbd8e284ea675b41a.zip
Auto merge of #104164 - cjgillot:u64-cache, r=compiler-errors
Use 64 bits for incremental cache in-file positions

We currently use a 32-bit integer to encode byte positions into the incremental cache.
This is not enough when the query chache file is >4GB.

As the overflow check was a `debug_assert`, it was removed in released compilers, making compilation succeed silently.
At the next compilation, cache decoding would try to read unrelated data because of garbled file position, triggering an ICE.

Fixes https://github.com/rust-lang/rust/issues/79786
(I'm closing that bug since it the original report and the subsequent questions are probably different instances. A new bug should be opened for new instances of that ICE.)
-rw-r--r--compiler/rustc_query_impl/src/on_disk_cache.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/compiler/rustc_query_impl/src/on_disk_cache.rs b/compiler/rustc_query_impl/src/on_disk_cache.rs
index a6cb8f7bd55..eaed9aeb850 100644
--- a/compiler/rustc_query_impl/src/on_disk_cache.rs
+++ b/compiler/rustc_query_impl/src/on_disk_cache.rs
@@ -119,12 +119,11 @@ pub type EncodedDepNodeIndex = Vec<(SerializedDepNodeIndex, AbsoluteBytePos)>;
 struct SourceFileIndex(u32);
 
 #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Encodable, Decodable)]
-pub struct AbsoluteBytePos(u32);
+pub struct AbsoluteBytePos(u64);
 
 impl AbsoluteBytePos {
     fn new(pos: usize) -> AbsoluteBytePos {
-        debug_assert!(pos <= u32::MAX as usize);
-        AbsoluteBytePos(pos as u32)
+        AbsoluteBytePos(pos.try_into().expect("Incremental cache file size overflowed u64."))
     }
 
     fn to_usize(self) -> usize {