rust icon indicating copy to clipboard operation
rust copied to clipboard

libuv/timer - 'Assertion loop_refs == 1i32 failed' when uv_loop exits

Open ttaubert opened this issue 13 years ago • 7 comments

I'm spawning a weak thread that periodically sends messages to a specific channel. While that works, every time I exit the program - e.g. at test suite shut down - there is an assertion:

rust: task failed at 'Assertion loop_refs == 1i32 failed', /home/tim/workspace/rust-trunk/src/libstd/uv_iotask.rs:172
main: /home/tim/workspace/rust-trunk/src/rt/rust_upcall.cpp:81: void upcall_call_shim_on_rust_stack(void*, void*): Assertion `false && "Rust task failed after reentering the Rust stack"' failed.

It's quite easy to reproduce with a test like this:

fn test_foo() {
  let iotask = std::uv_iotask::spawn_iotask(task::task());
  let port = Port::<()>();
  let chan = port.chan();

  do task::spawn() {
    loop {
      chan.send(());
      std::timer::sleep(iotask, 0);
    }
  }

  port.recv();
  std::uv_iotask::exit(iotask);
}

The test reproduces it without the need to exit the program. Just append another long sleep call at the end of it. The same thing happens when using delayed_send().

ttaubert avatar Dec 14 '12 23:12 ttaubert

CC'ing @olsonjeffery because he seems to be the author of most of the libuv code.

ttaubert avatar Dec 14 '12 23:12 ttaubert

This is still relevant, reproduced by this code.

fn test_foo() {
  let iotask1 = std::uv_iotask::spawn_iotask(task::task());
  let iotask2 = iotask1.clone();
  let (port, chan) = comm::stream();

  do task::spawn() {
    loop {
      chan.send(());
      std::timer::sleep(&iotask2, 0);
    }
  }

  port.recv();
  std::uv_iotask::exit(&iotask1);
}

ILyoan avatar Apr 29 '13 12:04 ILyoan

assigning bug; change assignment if you disagree

graydon avatar Apr 30 '13 22:04 graydon

Complete updated test:

extern mod extra;

fn test_foo() {
  let iotask1 = extra::uv_iotask::spawn_iotask(std::task::task());
  let iotask2 = iotask1.clone();
  let (port, chan) = std::comm::stream();

  do std::task::spawn() {
    loop {
      chan.send(());
      extra::timer::sleep(&iotask2, 0);
    }
  }

  port.recv();
  extra::uv_iotask::exit(&iotask1);
}

fn main() {
    test_foo();
}

This fails with:

rust: task failed at 'left: 140597564275144 does not equal right: 140597585244248', /home/philipp/programming/rust/src/libextra/uv_iotask.rs:191
foo: /home/philipp/programming/rust/src/rt/rust_upcall.cpp:98: void upcall_call_shim_on_rust_stack(void*, void*): Assertion `false && "Rust task failed after reentering the Rust stack"' failed.

Blei avatar Jun 13 '13 09:06 Blei

I am not currently maintaining the networking code in libextra. This won't be fixed in 0.7.

brson avatar Jun 20 '13 06:06 brson

Triage 2013-08-05: Seems like this is no longer relevant since extra::uv has been removed, and libuv is integrated much deeper into the new runtime so (1) I have no idea how to write something that might reproduce this, and (2) it is unlikely this applies to newrt.

Could someone how knows what they are talking about (@bblum, @brson, @toddaaro) close this?

huonw avatar Aug 05 '13 11:08 huonw

@huonw yea, that sounds right. I'll mark this closed as old network code has been replaced by newrt functionality. If this is some weird case where the bug persists someone can re-open.

toddaaro avatar Aug 17 '13 04:08 toddaaro