Skip to content

rustc generates overlapping memcpy for swap #5041

Closed
@brson

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions