{"record":{"id":"5c0df0b9a9a23d5c","repo":"pydantic/monty","slug":"longintid-overflow","errorCode":null,"errorMessage":"LongIntId overflow","messagePattern":"LongIntId overflow","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/monty/src/intern.rs","lineNumber":1422,"sourceCode":"    /// builtin names before the runtime table is built.\n    pub fn get_string_id_by_name(&self, s: &str) -> Option<StringId> {\n        get_string_id_by_name(&self.string_map, s)\n    }\n\n    /// Interns bytes, returning its `BytesId`.\n    ///\n    /// Unlike interns, bytes are not deduplicated (bytes literals are rare).\n    pub fn intern_bytes(&mut self, b: &[u8]) -> BytesId {\n        let id = BytesId(self.bytes.len().try_into().expect(\"BytesId overflow\"));\n        self.bytes.push(WithHash::for_bytes(b.to_vec()));\n        id\n    }\n\n    /// Interns a long integer, returning its `LongIntId`.\n    ///\n    /// Big integers are not deduplicated since literals exceeding i64 are rare.\n    pub fn intern_long_int(&mut self, bi: BigInt) -> LongIntId {\n        let id = LongIntId(self.long_ints.len().try_into().expect(\"LongIntId overflow\"));\n        self.long_ints.push(WithHash::for_long_int(bi));\n        id\n    }\n\n    /// Looks up a string by its `StringId`.\n    #[inline]\n    pub fn get_str(&self, id: StringId) -> &str {\n        get_str(&self.strings, id)\n    }\n}\n\n/// Interns `s` into a `string_map`/`strings` pair, shared by [`InternerBuilder`]\n/// and [`Interns`] so both tables allocate ids identically.\n///\n/// Single-ASCII and [`StaticStrings`] values resolve to their reserved ids\n/// without touching the pool; everything else is deduplicated via `string_map`.\nfn intern_str(string_map: &mut AHashMap<String, StringId>, strings: &mut Vec<WithHash<String>>, s: &str) -> StringId {\n    if s.len() == 1 {","sourceCodeStart":1404,"sourceCodeEnd":1440,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty/src/intern.rs#L1404-L1440","documentation":"`InternTable::intern_long_int` converts the table's length to a `LongIntId` backed by a small unsigned integer; the `expect` panics if there are more interned big integers than the ID type can represent. This is an interpreter-internal invariant, not a catchable error: it only fires after ~4 billion distinct long-int literals are interned in one session.","triggerScenarios":"Calling `intern_long_int` (directly or via compiling/executing code with huge numbers of distinct >i64 integer literals) when `long_ints.len()` exceeds `u32::MAX` (or the backing integer width).","commonSituations":"Practically only hit by generated code containing billions of unique big-int literals, or a bug in table reuse/clearing that lets the table grow unboundedly.","solutions":["Check why so many long integers are being interned without table reuse; recycle or reset the InternTable per compilation unit.","Verify the ID type width (e.g. widen `LongIntId` to u64) if your workload legitimately interns enormous numbers of values.","Report as a bug if reached with a normal workload."],"exampleFix":"// before\nlet id = LongIntId(self.long_ints.len().try_into().expect(\"LongIntId overflow\"));\n// after\nlet id = LongIntId(u32::try_from(self.long_ints.len()).map_err(|_| CompileError::TooManyInternedValues)?);","handlingStrategy":"validation","validationCode":"assert!(intern_table.long_int_count() < u32::MAX as usize, \"LongIntId space exhausted\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Recycle or reset the intern table per compilation unit","Cap generated code size before compiling","Treat any occurrence as an interpreter bug report"],"tags":["rust","panic","interning"],"backgroundTag":"internal-invariant-violation","analyzedSha":"adc986b362e3961f407868cb118a99fe831b9e61","analyzedAt":"2026-09-13T19:19:18.698Z","contentChangedAt":"2026-09-13T19:19:18.698Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}