{"record":{"id":"eb807cd8254aca63","repo":"GitoxideLabs/gitoxide","slug":"run-length-word-offset-exceeds-u32-max","errorCode":null,"errorMessage":"run length word offset exceeds u32::MAX","messagePattern":"run length word offset exceeds u32::MAX","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-bitmap/src/ewah.rs","lineNumber":81,"sourceCode":"\n            Some(Vec {\n                num_bits,\n                bits: std::iter::once((literal_words.len() as u64) << (1 + RLW_RUNNING_BITS))\n                    .chain(literal_words)\n                    .collect(),\n                rlw: 0,\n            })\n        }\n\n        /// Write the bitmap as EWAH bytes to `out`.\n        ///\n        /// These bytes can be parsed again with [`decode()`](super::decode()).\n        pub fn write_to(&self, out: &mut impl std::io::Write) -> std::io::Result<()> {\n            let len: u32 = self.bits.len().try_into().map_err(|_| {\n                std::io::Error::new(std::io::ErrorKind::InvalidInput, \"bit word count exceeds u32::MAX\")\n            })?;\n            let rlw: u32 = self.rlw.try_into().map_err(|_| {\n                std::io::Error::new(\n                    std::io::ErrorKind::InvalidInput,\n                    \"run length word offset exceeds u32::MAX\",\n                )\n            })?;\n\n            out.write_all(&self.num_bits.to_be_bytes())?;\n            out.write_all(&len.to_be_bytes())?;\n            for word in &self.bits {\n                out.write_all(&word.to_be_bytes())?;\n            }\n            out.write_all(&rlw.to_be_bytes())\n        }\n\n        /// Call `f(index)` for each bit that is true, given the index of the bit that identifies it uniquely within the bit array.\n        /// If `f` returns `None` the iteration will be stopped and `None` is returned.\n        ///\n        /// The index is sequential like in any other vector.\n        pub fn for_each_set_bit(&self, mut f: impl FnMut(usize) -> Option<()>) -> Option<()> {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-bitmap/src/ewah.rs#L63-L99","documentation":"`EwahBitmap::write_to` stores the run-length-word (RLW) offset as a `u32` in the EWAH format. If the bitmap's `rlw` offset value exceeds `u32::MAX`, it cannot be encoded, so `write_to` returns an `io::Error` of kind `InvalidInput` rather than emitting a structurally invalid stream.","triggerScenarios":"Calling `write_to` on a bitmap whose `rlw` field (position of the run-length word) is greater than `u32::MAX` — implied by a word list of more than ~4.29 billion words.","commonSituations":"Same extreme-scale scenarios as the word-count overflow: a pathologically large bitmap built from unbounded accumulation or a bug that sets an invalid RLW offset.","solutions":["Verify `bitmap.rlw <= u32::MAX as usize` before writing and fail early with a clear error","Keep bitmaps within representable size (chunk them) and recompute the RLW offset per chunk","Audit bitmap construction for bugs that could push the RLW offset out of range"],"exampleFix":"// before\nbitmap.write_to(&mut out)?;\n// after\nassert!(bitmap.rlw <= u32::MAX as usize, \"RLW offset too large for EWAH\");\nbitmap.write_to(&mut out)?;","handlingStrategy":"validation","validationCode":"if bitmap.rlw > u32::MAX as usize {\n    return Err(io::Error::new(io::ErrorKind::InvalidInput, \"RLW offset too large\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the RLW offset invariant when building bitmaps","Chunk oversized bitmaps before writing","Treat extreme RLW offsets as a construction bug"],"tags":["bitmap","serialization","limit"],"backgroundTag":"value-out-of-range","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}