Skip to content

data race with example_hyper #98

@bbigras

Description

@bbigras

To reproduce, run example_hyper with RUSTFLAGS="-Z sanitizer=thread" cargo run on a recent nightly. Then run curl localhost:9898/metrics twice.

The sanitizer is a new cool feature. See [HowTo] Sanitize your Rust code!

listening addr "127.0.0.1:9898"
==================
WARNING: ThreadSanitizer: data race (pid=18085)
  Read of size 8 at 0x55e64c39ac08 by thread T3:
    #0 lazy_static::lazy::{{impl}}::get<prometheus::counter::Counter,fn() -> prometheus::counter::Counter> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-0.2.2/src/lazy.rs:19 (prometheus-race+0x00000010a744)
    #1 prometheus_race::{{impl}}::deref::__stability /home/bbigras/dev/rust/bugs/prometheus-race/<lazy_static macros>:21 (prometheus-race+0x00000010a744)
    #2 prometheus_race::{{impl}}::deref /home/bbigras/dev/rust/bugs/prometheus-race/<lazy_static macros>:22 (prometheus-race+0x00000010a744)
    #3 prometheus_race::main::{{closure}} /home/bbigras/dev/rust/bugs/prometheus-race/src/main.rs:44 (prometheus-race+0x00000010a212)
    #4 prometheus_race::main::{{closure}} /home/bbigras/dev/rust/bugs/prometheus-race/src/main.rs:44 (prometheus-race+0x00000010a212)
    #5 prometheus_race::main::{{closure}} /home/bbigras/dev/rust/bugs/prometheus-race/src/main.rs:44 (prometheus-race+0x00000010a212)
    #6 hyper::server::{{impl}}::handle<closure> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.4/src/server/mod.rs:434 (prometheus-race+0x0000000956a0)
    #7 hyper::server::{{impl}}::keep_alive_loop<closure,std::io::buffered::BufWriter<&mut hyper::net::HttpStream>> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.4/src/server/mod.rs:341 (prometheus-race+0x00000007c3a5)
    #8 hyper::server::{{impl}}::handle_connection<closure,hyper::net::HttpStream> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.4/src/server/mod.rs:287 (prometheus-race+0x00000007d25e)
    #9 hyper::server::handle::{{closure}}<closure,hyper::net::HttpListener> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.4/src/server/mod.rs:246 (prometheus-race+0x0000000d10cf)
    #10 hyper::server::listener::spawn_with::{{closure}}<hyper::net::HttpListener,closure> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.4/src/server/listener.rs:50 (prometheus-race+0x0000000d1814)
    #11 std::panic::{{impl}}::call_once<(),closure> /checkout/src/libstd/panic.rs:296 (prometheus-race+0x000000103fb8)
    #12 std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,()> /checkout/src/libstd/panicking.rs:450 (prometheus-race+0x00000008deb5)
    #13 panic_unwind::__rust_maybe_catch_panic /checkout/src/libpanic_unwind/lib.rs:98 (prometheus-race+0x000000584c4a)
    #14 std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,()> /checkout/src/libstd/panic.rs:361 (prometheus-race+0x00000008b253)
    #15 std::thread::{{impl}}::spawn::{{closure}}<closure,()> /checkout/src/libstd/thread/mod.rs:357 (prometheus-race+0x00000008d2ca)
    #16 alloc::boxed::{{impl}}::call_box<(),closure> /checkout/src/liballoc/boxed.rs:638 (prometheus-race+0x0000000c16b6)
    #17 alloc::boxed::{{impl}}::call_once<(),()> /checkout/src/liballoc/boxed.rs:648 (prometheus-race+0x00000057cc14)
    #18 std::sys_common::thread::start_thread /checkout/src/libstd/sys_common/thread.rs:21 (prometheus-race+0x00000057cc14)
    #19 std::sys::imp::thread::{{impl}}::new::thread_start /checkout/src/libstd/sys/unix/thread.rs:84 (prometheus-race+0x00000057cc14)

  Previous write of size 8 at 0x55e64c39ac08 by thread T2:
    [failed to restore the stack]

  Location is global '<null>' at 0x000000000000 (prometheus-race+0x0000009b9c08)

  Thread T3 (tid=18279, running) created by thread T1 at:
    #0 pthread_create /checkout/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (prometheus-race+0x0000004903c7)
    #1 std::sys::imp::thread::{{impl}}::new /checkout/src/libstd/sys/unix/thread.rs:72 (prometheus-race+0x00000057c915)
    #2 std::thread::spawn<closure,()> /checkout/src/libstd/thread/mod.rs:412 (prometheus-race+0x00000008b372)
    #3 hyper::server::listener::spawn_with<hyper::net::HttpListener,closure> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.4/src/server/listener.rs:45 (prometheus-race+0x0000000d15a8)
    #4 hyper::server::listener::{{impl}}::accept<hyper::net::HttpListener,closure> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.4/src/server/listener.rs:31 (prometheus-race+0x0000000c9258)
    #5 hyper::server::handle::{{closure}}<closure,hyper::net::HttpListener> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.4/src/server/mod.rs:248 (prometheus-race+0x0000000d1026)
    #6 std::panic::{{impl}}::call_once<(),closure> /checkout/src/libstd/panic.rs:296 (prometheus-race+0x0000001040ab)
    #7 std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,()> /checkout/src/libstd/panicking.rs:450 (prometheus-race+0x00000008dccb)
    #8 panic_unwind::__rust_maybe_catch_panic /checkout/src/libpanic_unwind/lib.rs:98 (prometheus-race+0x000000584c4a)
    #9 std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,()> /checkout/src/libstd/panic.rs:361 (prometheus-race+0x00000008b153)
    #10 std::thread::{{impl}}::spawn::{{closure}}<closure,()> /checkout/src/libstd/thread/mod.rs:357 (prometheus-race+0x00000008cf4a)
    #11 alloc::boxed::{{impl}}::call_box<(),closure> /checkout/src/liballoc/boxed.rs:638 (prometheus-race+0x0000000c176c)
    #12 alloc::boxed::{{impl}}::call_once<(),()> /checkout/src/liballoc/boxed.rs:648 (prometheus-race+0x00000057cc14)
    #13 std::sys_common::thread::start_thread /checkout/src/libstd/sys_common/thread.rs:21 (prometheus-race+0x00000057cc14)
    #14 std::sys::imp::thread::{{impl}}::new::thread_start /checkout/src/libstd/sys/unix/thread.rs:84 (prometheus-race+0x00000057cc14)

  Thread T2 (tid=18278, running) created by thread T1 at:
    #0 pthread_create /checkout/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (prometheus-race+0x0000004903c7)
    #1 std::sys::imp::thread::{{impl}}::new /checkout/src/libstd/sys/unix/thread.rs:72 (prometheus-race+0x00000057c915)
    #2 std::thread::spawn<closure,()> /checkout/src/libstd/thread/mod.rs:412 (prometheus-race+0x00000008b372)
    #3 hyper::server::listener::spawn_with<hyper::net::HttpListener,closure> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.4/src/server/listener.rs:45 (prometheus-race+0x0000000d15a8)
    #4 hyper::server::listener::{{impl}}::accept<hyper::net::HttpListener,closure> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.4/src/server/listener.rs:31 (prometheus-race+0x0000000c9258)
    #5 hyper::server::handle::{{closure}}<closure,hyper::net::HttpListener> /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.4/src/server/mod.rs:248 (prometheus-race+0x0000000d1026)
    #6 std::panic::{{impl}}::call_once<(),closure> /checkout/src/libstd/panic.rs:296 (prometheus-race+0x0000001040ab)
    #7 std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,()> /checkout/src/libstd/panicking.rs:450 (prometheus-race+0x00000008dccb)
    #8 panic_unwind::__rust_maybe_catch_panic /checkout/src/libpanic_unwind/lib.rs:98 (prometheus-race+0x000000584c4a)
    #9 std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,()> /checkout/src/libstd/panic.rs:361 (prometheus-race+0x00000008b153)
    #10 std::thread::{{impl}}::spawn::{{closure}}<closure,()> /checkout/src/libstd/thread/mod.rs:357 (prometheus-race+0x00000008cf4a)
    #11 alloc::boxed::{{impl}}::call_box<(),closure> /checkout/src/liballoc/boxed.rs:638 (prometheus-race+0x0000000c176c)
    #12 alloc::boxed::{{impl}}::call_once<(),()> /checkout/src/liballoc/boxed.rs:648 (prometheus-race+0x00000057cc14)
    #13 std::sys_common::thread::start_thread /checkout/src/libstd/sys_common/thread.rs:21 (prometheus-race+0x00000057cc14)
    #14 std::sys::imp::thread::{{impl}}::new::thread_start /checkout/src/libstd/sys/unix/thread.rs:84 (prometheus-race+0x00000057cc14)

SUMMARY: ThreadSanitizer: data race /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-0.2.2/src/lazy.rs:19 in lazy_static::lazy::{{impl}}::get<prometheus::counter::Counter,fn() -> prometheus::counter::Counter>
==================
[...]

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions