Skip to content

Double free(?) when returning owned self #6682

Closed
@dotdash

Description

@dotdash
trait M {
  fn m(self) -> Self;
}

impl M for ~int {
  fn m(self) -> ~int {
    self
  }
}

fn main() {
  (~1).m();
}

This crashes in free().

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7f85700 (LWP 10508)]
__GI___libc_free (mem=0xffffffffffffffff) at malloc.c:2892
2892    malloc.c: No such file or directory.
(gdb) bt
#0  __GI___libc_free (mem=0xffffffffffffffff) at malloc.c:2892
#1  0x00007ffff7a5b859 in libc::funcs::c95::stdlib::free::_e26c3f5a54e72c6::_07pre () from /home/bs/src/rust/../../rust/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.7-pre.so
#2  0x0000000000404f38 in ?? ()
#3  0x00007ffff7ae8bdc in __morestack () from /home/bs/src/rust/../../rust/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.7-pre.so
#4  0x0000000000000000 in ?? ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions