Skip to content

Capturing @ in a non-Send ~fn causes memory_region to crash #8983

Closed

Description

@huonw
fn main() {
    fn f(_: ~fn:()) {} // note `fn:` overrides the default `fn:Send`.
    fn eat<T>(_: T) {}

    let x = @1;
    f(|| eat(x));
}

It doesn't fail with e.g. x = 1 or x = &1.

leaked memory in rust main loop (1 objects)
fn-no-send~: /home/huon/rust/src/rt/memory_region.cpp:184: memory_region::~memory_region(): Assertion `false' failed.
#0  0x00007ffff67601e5 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff6763398 in __GI_abort () at abort.c:90
#2  0x00007ffff6759272 in __assert_fail_base (fmt=0x7ffff6896900 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x7ffff744c0f0 "false", file=file@entry=0x7ffff744c078 "/home/huon/rust/src/rt/memory_region.cpp", 
    line=line@entry=184, function=function@entry=0x7ffff744c100 <memory_region::~memory_region()::__PRETTY_FUNCTION__> "memory_region::~memory_region()") at assert.c:92
#3  0x00007ffff6759322 in __GI___assert_fail (assertion=0x7ffff744c0f0 "false", file=0x7ffff744c078 "/home/huon/rust/src/rt/memory_region.cpp", line=184, 
    function=0x7ffff744c100 <memory_region::~memory_region()::__PRETTY_FUNCTION__> "memory_region::~memory_region()") at assert.c:101
#4  0x00007ffff74130d1 in memory_region::~memory_region (this=0x7ffff5820340, __in_chrg=<optimized out>) at /home/huon/rust/src/rt/memory_region.cpp:184
#5  0x00007ffff740b796 in rust_delete_memory_region (region=0x7ffff5820340) at /home/huon/rust/src/rt/rust_builtin.cpp:489
#6  0x00007ffff7732814 in rt..task..Task::_6b635e7e69444e6::glue_drop_16129 () from /home/huon/projects/test-rust/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8-pre.so
#7  0x00007ffff77bb9b5 in rt::sched::__extensions__::terminate_current_task::anon::expr_fn_31804 () from /home/huon/projects/test-rust/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8-pre.so
#8  0x00007ffff77ae737 in rt::sched::__extensions__::meth_30277::run_cleanup_job::_f3525925b944a51::_0$x2e8$x2dpre ()
   from /home/huon/projects/test-rust/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8-pre.so
#9  0x00007ffff77ba65a in rt::sched::__extensions__::meth_31758::change_task_context::_b925bc42bcab506a::_0$x2e8$x2dpre ()
   from /home/huon/projects/test-rust/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8-pre.so
#10 0x00007ffff7774ad3 in rt::sched::__extensions__::meth_23683::bootstrap::_9083d96446a974a::_0$x2e8$x2dpre ()
   from /home/huon/projects/test-rust/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8-pre.so
#11 0x00007ffff77fa7b7 in rt::run_::anon::expr_fn_36781 () from /home/huon/projects/test-rust/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8-pre.so
#12 0x00007ffff740ac8a in rust_thread_start (ptr=<optimized out>) at /home/huon/rust/src/rt/sync/rust_thread.cpp:36
#13 0x00007ffff6fe0e0e in start_thread (arg=0x7ffff7fd3700) at pthread_create.c:311
#14 0x00007ffff681393d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Activity

  1. alexcrichton commented on Mar 18, 2014

    @alexcrichton
    Member

    This appears to no longer fail, flagging as needstest

    #[feature(managed_boxes)];
    fn main() {
        fn f(_: proc:()) {}
        fn eat<T>(_: T) {}
    
        let x = @1;
        f(proc() { eat(x) });
    }
  2. added a commit that references this issue on Apr 28, 2014
    35f295d
  3. added a commit that references this issue on Apr 28, 2014
    7a19a82
  4. added a commit that references this issue on Jun 16, 2022
  5. 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

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-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