Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
huonw opened this issue Sep 4, 2013 · 1 comment
Closed

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

huonw opened this issue Sep 4, 2013 · 1 comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@huonw
Copy link
Member

huonw commented Sep 4, 2013

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
@alexcrichton
Copy link
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) });
}

bors added a commit that referenced this issue Apr 28, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 16, 2022
…iraffate

Add tests for some fixed `redundant_closure` issues

closes rust-lang#7861
closes rust-lang#5939

changelog: none
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants