{"record":{"id":"0150dcaf2d8d7081","repo":"FuelLabs/sway","slug":"pointer-offset-must-be-in-data-section","errorCode":null,"errorMessage":"Pointer offset must be in data_section","messagePattern":"Pointer offset must be in data_section","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sway-core/src/asm_lang/allocated_ops.rs","lineNumber":1066,"sourceCode":"    );\n    let offset = match imm {\n        Ok(value) => value,\n        Err(_) => panic!(\n            \"Unable to offset into the data section more than 2^12 bits. \\\n                                Unsupported data section length: {offset_words} words.\"\n        ),\n    };\n\n    if !has_copy_type {\n        // Load the pointer itself into the register. `offset_to_data_section` is in bytes.\n        // The -4 is because $pc is added in the *next* instruction.\n        let pointer_offset_from_current_instr =\n            offset_to_data_section - offset_from_instr_start + offset_bytes - 4;\n\n        // Insert the pointer as bytes as a new data section entry at the end of the data.\n        let data_id_for_pointer = data_section\n            .data_id_of_pointer(pointer_offset_from_current_instr)\n            .expect(\"Pointer offset must be in data_section\");\n\n        // Now load the pointer we just created into the `dest`ination.\n        let mut buf = Vec::with_capacity(2);\n        buf.append(&mut realize_load(\n            dest,\n            &data_id_for_pointer,\n            data_section,\n            offset_to_data_section,\n            offset_from_instr_start,\n        ));\n        // Add $pc to the pointer since it is relative to the current instruction.\n        buf.push(\n            fuel_asm::op::ADD::new(\n                dest.to_reg_id(),\n                dest.to_reg_id(),\n                ConstantRegister::ProgramCounter.to_reg_id(),\n            )\n            .into(),","sourceCodeStart":1048,"sourceCodeEnd":1084,"githubUrl":"https://github.com/FuelLabs/sway/blob/dad95cc42b0383b4e3bacdeda9766565aa584a92/sway-core/src/asm_lang/allocated_ops.rs#L1048-L1084","documentation":"In realize_load, for a non-copy-type load the compiler synthesizes a pointer entry (the byte offset of the target relative to the load instruction) and appends it at the end of the data section via data_id_of_pointer. That lookup is expected to always succeed because the pointer was just appended; if it returns None, the newly created pointer entry is not found in the data section, meaning an internal miscalculation in data-section bookkeeping (e.g. the append failed or offsets/ids are out of sync).","triggerScenarios":"Thrown at sway-core/src/asm_lang/allocated_ops.rs:1066 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify data_id_of_pointer appends-and-returns atomically so the just-inserted pointer is always found","Check that pointer_offset_from_current_instr arithmetic matches what data_id_of_pointer uses as its key","Inspect data section insertion for silent failures or id/offset desynchronization between append and lookup"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"dad95cc42b0383b4e3bacdeda9766565aa584a92","analyzedAt":"2026-09-04T20:02:14.068Z","contentChangedAt":"2026-09-04T20:02:14.068Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}