FuelLabs/sway · error
Pointer offset must be in data_section
Error message
Pointer offset must be in data_section
What it means
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).
Source
Thrown at sway-core/src/asm_lang/allocated_ops.rs:1066
);
let offset = match imm {
Ok(value) => value,
Err(_) => panic!(
"Unable to offset into the data section more than 2^12 bits. \
Unsupported data section length: {offset_words} words."
),
};
if !has_copy_type {
// Load the pointer itself into the register. `offset_to_data_section` is in bytes.
// The -4 is because $pc is added in the *next* instruction.
let pointer_offset_from_current_instr =
offset_to_data_section - offset_from_instr_start + offset_bytes - 4;
// Insert the pointer as bytes as a new data section entry at the end of the data.
let data_id_for_pointer = data_section
.data_id_of_pointer(pointer_offset_from_current_instr)
.expect("Pointer offset must be in data_section");
// Now load the pointer we just created into the `dest`ination.
let mut buf = Vec::with_capacity(2);
buf.append(&mut realize_load(
dest,
&data_id_for_pointer,
data_section,
offset_to_data_section,
offset_from_instr_start,
));
// Add $pc to the pointer since it is relative to the current instruction.
buf.push(
fuel_asm::op::ADD::new(
dest.to_reg_id(),
dest.to_reg_id(),
ConstantRegister::ProgramCounter.to_reg_id(),
)
.into(),View on GitHub (pinned to dad95cc42b)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at sway-core/src/asm_lang/allocated_ops.rs:1066 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of FuelLabs/sway@dad95cc42b (2026-09-04).
Data as JSON: /api/errors/0150dcaf2d8d7081.
Report an issue: GitHub.