Skip to content

rustc generates overlapping memcpy for swap #5041

Closed

Description

@brson

This is showing up for me under valgrind with any test runner, but the bots aren't seeing it. Here's a reduced test case:

fn main() {
    let mut test = TestDescAndFn {
        desc: TestDesc {
            name: DynTestName(~"test"),
            should_fail: false
        },
        testfn: DynTestFn(|| ()),
    };
    test <-> test;
}

pub enum TestName {
    DynTestName(~str)
}

pub enum TestFn {
    DynTestFn(~fn()),
    DynBenchFn(~fn(&mut int))
}

pub struct TestDesc {
    name: TestName,
    should_fail: bool
}

pub struct TestDescAndFn {
    desc: TestDesc,
    testfn: TestFn,
}
==14043== Source and destination overlap in memcpy(0x65f1378, 0x65f1378, 40)
==14043==    at 0x4C2CC30: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14043==    by 0x400EFE: main::_549c6ab1ca2b3fae::_00 (in /home/brian/dev/rust3/build/x86_64-unknown-linux-gnu/test/run-pass/swap-overlapping.stage1-x86_64-unknown-linux-gnu)
==14043==    by 0x400F9D: _rust_main (in /home/brian/dev/rust3/build/x86_64-unknown-linux-gnu/test/run-pass/swap-overlapping.stage1-x86_64-unknown-linux-gnu)
==14043==    by 0x51AE413: task_start_wrapper(spawn_args*) (rust_task.cpp:162)

Activity

  1. catamorphism commented on Feb 21, 2013

    @catamorphism
    Contributor

    Fixed in 423843e

  2. added a commit that references this issue on May 27, 2020
    182ac89
  3. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegen

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions