Skip to content

Offset calculation bug in copy_forward_misaligned_words #146643

@uris-genlabs

Description

@uris-genlabs

There's a bug in the function copy_forward_misaligned_words under library/compiler-builtins/compiler-builtins/src/mem/impls.rs (line 153), with the mem-unaligned feature not enabled.

The code calculates src_aligned incorrectly - instead of adding the missing alignment to src, it subtracts. This causes the wrong bytes to be read by load_aligned_end_partial, and may potentially access invalid memory. Compare this with copy_backward_misaligned_words, where the alignment is correctly calculated by subtraction.

This bug is probably the cause of this issue:
#145769

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions