Skip to content

fix: the MLOAD opcode can modify memory#3266

Merged
rakita merged 1 commit intobluealloy:mainfrom
Wodann:fix/mload-modifies-memory
Dec 31, 2025
Merged

fix: the MLOAD opcode can modify memory#3266
rakita merged 1 commit intobluealloy:mainfrom
Wodann:fix/mload-modifies-memory

Conversation

@Wodann
Copy link
Contributor

@Wodann Wodann commented Dec 31, 2025

This occurs if the MLOAD opcode needs to be resize the memory to read from the requested memory offset.

pub fn mload<WIRE: InterpreterTypes, H: ?Sized>(context: InstructionContext<'_, H, WIRE>) {
    popn_top!([], top, context.interpreter);
    let offset = as_usize_or_fail!(context.interpreter, top);
    resize_memory!(context.interpreter, offset, 32); // <-- This can modify the memory!!
    *top =
        U256::try_from_be_slice(context.interpreter.memory.slice_len(offset, 32).as_ref()).unwrap()
}

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 31, 2025

CodSpeed Performance Report

Merging #3266 will not alter performance

Comparing Wodann:fix/mload-modifies-memory (b830d0c) with main (2c1153b)

Summary

✅ 173 untouched

@rakita rakita merged commit 27664ca into bluealloy:main Dec 31, 2025
31 checks passed
@github-actions github-actions bot mentioned this pull request Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants