Skip to content

Starting Rust runtime twice (sequentially) fails #9739

New issue

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

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

Already on GitHub? Sign in to your account

Closed
drrb opened this issue Oct 6, 2013 · 0 comments · Fixed by #9742
Closed

Starting Rust runtime twice (sequentially) fails #9739

drrb opened this issue Oct 6, 2013 · 0 comments · Fixed by #9742

Comments

@drrb
Copy link

drrb commented Oct 6, 2013

Rust Version: 0.8
Platform: OSX

Starting the Rust runtime more than once (sequentially) fails with the following error.

task <unnamed> failed at 'assert_once_ever happened twice: last task exiting', /private/tmp/rust-ZPXh/src/libstd/rt/mod.rs:305
libc++abi.dylib: terminate called throwing an exception

This is a simple example that reproduces the problem.

#[start]
fn start(argc: int, argv: **u8) -> int {
    do std::rt::start(argc, argv) {
        println("First invocation");
    };

    do std::rt::start(argc, argv) {
        println("Second invocation");
    };

    0
}

The actual use-case is to call Rust code from Java (through JNI) multiple times. Calling Rust code this way requires starting the runtime for each call, which works for the first invocation, but not for subsequent ones

bors added a commit that referenced this issue Oct 9, 2013
This changes an `assert_once_ever!` assertion to just a plain old assertion
around an atomic boolean to ensure that one particular runtime doesn't attempt
to exit twice.

Closes #9739
flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 21, 2022
Address issues 9739 and 9782

This PR fixes rust-lang#9739 in the manner I suggested in rust-lang/rust-clippy#9739 (comment).

This PR also fixes the compilation failures in rust-lang#9782 (but doesn't address `@e00E's` other objections).

Fixes rust-lang#9739

r? `@Jarcho`

changelog: Fix two `needless_borrow` false positives, one involving borrows in `if`-`else`s, the other involving qualified function calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant