Skip to content
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

Don't crash on lazy_static init race #128

Merged
merged 3 commits into from
Apr 13, 2020
Merged

Conversation

jonhoo
Copy link
Contributor

@jonhoo jonhoo commented Apr 12, 2020

The real lazy_static uses a lock to avoid races in initialization. We
don't implement that lock yet, so our initialization can race. If we do,
we should not crash like we did before.

Fixes #126.

The real lazy_static uses a lock to avoid races in initialization. We
don't implement that lock yet, so our initialization can race. If we do,
we should not crash like we did before.

Fixes tokio-rs#126.
@jonhoo jonhoo requested a review from carllerche April 12, 2020 15:44
jonhoo added a commit to jonhoo/crossbeam that referenced this pull request Apr 12, 2020
With this change, loom runs to completion on the treiber test!
I ran it with `LOOM_MAX_PREEMPTIONS=3`, and it took _forever_ (well, it
took 2h), but eventually finished with:

     ================== Iteration 112280000 ==================

    Completed in 112291514 iterations
    ok

With `LOOM_MAX_PREEMPTIONS=2` it "only" took 13 minutes, and finished
with:

     ================== Iteration 9680000 ==================

    Completed in 9690926 iterations
    ok

I updated the CI script to run with `LOOM_MAX_PREEMPTIONS=2`.

Note that this change depends on
tokio-rs/loom#125 and
tokio-rs/loom#128. The `patch` in the root
`Cargo.toml` should be removed once a new loom release is made.
@jonhoo jonhoo merged commit 4321fd6 into tokio-rs:master Apr 13, 2020
@jonhoo jonhoo deleted the lazy_static-race branch April 13, 2020 23:23
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 this pull request may close these issues.

lazy_static: very rare (?) BorrowMut panic
2 participants