{"id":13546093,"url":"https://github.com/japaric/rust-san","last_synced_at":"2025-04-07T11:07:52.155Z","repository":{"id":66157411,"uuid":"81164517","full_name":"japaric/rust-san","owner":"japaric","description":"How-to: Sanitize your Rust code!","archived":false,"fork":false,"pushed_at":"2018-02-01T16:47:01.000Z","size":21,"stargazers_count":427,"open_issues_count":12,"forks_count":12,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-31T09:08:53.634Z","etag":null,"topics":["how-to","rust","sanitizer"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/japaric.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-02-07T03:59:21.000Z","updated_at":"2025-03-09T11:43:34.000Z","dependencies_parsed_at":"2023-02-21T02:16:11.697Z","dependency_job_id":null,"html_url":"https://github.com/japaric/rust-san","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/japaric%2Frust-san","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/japaric%2Frust-san/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/japaric%2Frust-san/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/japaric%2Frust-san/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/japaric","download_url":"https://codeload.github.com/japaric/rust-san/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247640463,"owners_count":20971557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["how-to","rust","sanitizer"],"created_at":"2024-08-01T12:00:31.396Z","updated_at":"2025-04-07T11:07:52.137Z","avatar_url":"https://github.com/japaric.png","language":"Rust","funding_links":[],"categories":["Vulnerability Assessment","Rust","Programming Languages"],"sub_categories":["Fuzzing"],"readme":"# `rust-san`\n\n\u003e How-to: Sanitize your Rust code!\n\n- [Intro](#intro)\n- [How to use the sanitizers?](#how-to-use-the-sanitizers)\n- [Examples](#examples)\n  - [AddressSanitizer](#addresssanitizer)\n    - [Out of bounds access](#out-of-bounds-access)\n    - [Use after free](#use-after-free)\n  - [LeakSanitizer](#leaksanitizer)\n    - [Memory leak](#memory-leak)\n    - [Rc cycle](#rc-cycle)\n  - [MemorySanitizer](#memorysanitizer)\n    - [Uninitialized read](#uninitialized-read)\n  - [ThreadSanitizer](#threadsanitizer)\n    - [Data race](#data-race)\n- [Better backtraces](#better-backtraces)\n- [Caveats / known bugs](#caveats--known-bugs)\n  - [Unrealiable LeakSanitizer](#unrealiable-leaksanitizer)\n  - [CARGO_INCREMENTAL](#cargo_incremental)\n  - [MemorySanitizer: Use of uninitialized value in the test runner](#memorysanitizer-use-of-uninitialized-value-in-the-test-runner)\n  - [ThreadSanitizer: Data race in the test runner](#threadsanitizer-data-race-in-the-test-runner)\n  - [Suppression of False Positives](#suppression-of-false-positives)\n- [License](#license)\n  - [Contribution](#contribution)\n\n## Intro\n\nAs of [nightly-2017-02-15](https://github.com/rust-lang/rust/pull/38699),\n`rustc` ships with **experimental** support for the following sanitizers:\n\n- [AddressSanitizer](https://clang.llvm.org/docs/AddressSanitizer.html)\n\n- [LeakSanitizer](https://clang.llvm.org/docs/LeakSanitizer.html)\n\n- [MemorySanitizer](https://clang.llvm.org/docs/MemorySanitizer.html)\n\n- [ThreadSanitizer](https://clang.llvm.org/docs/ThreadSanitizer.html)\n\nNote that sanitizer support is available on x86_64 Linux and on x86_64 macOS\n(ASan and TSan only).\n\n## How to use the sanitizers?\n\nYou have to compile your crate and all its dependencies with the `-Z sanitizer`\nflag. Setting `RUSTFLAGS` does the trick:\n\n```\n# if you have a binary crate (an application) or want to sanitize an example, use `cargo run`\n$ RUSTFLAGS=\"-Z sanitizer=$SAN\" cargo run --target x86_64-unknown-linux-gnu\n\n# if you have a library crate, use `cargo test` to sanitize your unit tests\n$ RUSTFLAGS=\"-Z sanitizer=$SAN\" cargo test --target x86_64-unknown-linux-gnu\n```\n\nWhere `$SAN` is one of `address`, `leak`, `memory` or `thread`.\n\nBe sure to **always** pass `--target x86_64-unknown-linux-gnu` to Cargo or else\nyou'll end up sanitizing the build scripts that Cargo runs or run into\ncompilation error if your crate depends on a dylib.\n\n## Examples\n\nThis section shows what kind of issues can be detected with the sanitizers\nthrough some examples that you can find in this repository\n\n### AddressSanitizer\n\nThis sanitizer can detect, among other things, out of bounds accesses and uses\nof freed memory.\n\n#### Out of bounds access\n\n`asan/examples/out-of-bounds.rs`\n\n``` rust\nfn main() {\n    let xs = [0, 1, 2, 3];\n    let y = unsafe { *xs.as_ptr().offset(4) };\n}\n```\n\n```\n$ ( cd asan \u0026\u0026 \\\n    RUSTFLAGS=\"-Z sanitizer=address\" cargo run --target x86_64-unknown-linux-gnu --example out-of-bounds )\n     Running `target/x86_64-unknown-linux-gnu/debug/examples/out-of-bounds`\n=================================================================\n==821==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffe9808e5f0 at pc 0x56500e096f7e bp 0x7ffe9808e5b0 sp 0x7ffe9808e5a8\nREAD of size 4 at 0x7ffe9808e5f0 thread T0\n    #0 0x56500e096f7d in out_of_bounds::main::h86e0ef2cff62a67d $PWD/examples/out-of-bounds.rs:3\n    #1 0x56500e18b536 in __rust_maybe_catch_panic ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/out-of-bounds+0xfe536)\n    #2 0x56500e183ee9 in std::rt::lang_start::h6954771f55df116b ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/out-of-bounds+0xf6ee9)\n    #3 0x56500e097002 in main ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/out-of-bounds+0xa002)\n    #4 0x7f9e21a46290 in __libc_start_main (/usr/lib/libc.so.6+0x20290)\n    #5 0x56500e096719 in _start ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/out-of-bounds+0x9719)\n\nAddress 0x7ffe9808e5f0 is located in stack of thread T0 at offset 48 in frame\n    #0 0x56500e096d5f in out_of_bounds::main::h86e0ef2cff62a67d $PWD/examples/out-of-bounds.rs:1\n\n  This frame has 1 object(s):\n    [32, 48) 'xs' \u003c== Memory access at offset 48 overflows this variable\nHINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext\n      (longjmp and C++ exceptions *are* supported)\nSUMMARY: AddressSanitizer: stack-buffer-overflow $PWD/examples/out-of-bounds.rs:3 in out_of_bounds::main::h86e0ef2cff62a67d\nShadow bytes around the buggy address:\n  0x100053009c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n  0x100053009c70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n  0x100053009c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n  0x100053009c90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n  0x100053009ca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n=\u003e0x100053009cb0: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 00[f3]f3\n  0x100053009cc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n  0x100053009cd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n  0x100053009ce0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n  0x100053009cf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n  0x100053009d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\nShadow byte legend (one shadow byte represents 8 application bytes):\n  Addressable:           00\n  Partially addressable: 01 02 03 04 05 06 07\n  Heap left redzone:       fa\n  Heap right redzone:      fb\n  Freed heap region:       fd\n  Stack left redzone:      f1\n  Stack mid redzone:       f2\n  Stack right redzone:     f3\n  Stack partial redzone:   f4\n  Stack after return:      f5\n  Stack use after scope:   f8\n  Global redzone:          f9\n  Global init order:       f6\n  Poisoned by user:        f7\n  Container overflow:      fc\n  Array cookie:            ac\n  Intra object redzone:    bb\n  ASan internal:           fe\n  Left alloca redzone:     ca\n  Right alloca redzone:    cb\n==821==ABORTING\n```\n\n#### Use after free\n\n`asan/examples/use-after-free.rs`\n\n``` rust\nfn main() {\n    let xs = vec![0, 1, 2, 3];\n    let y = xs.as_ptr();\n    drop(xs);\n    let z = unsafe { *y };\n}\n```\n\n```\n$ ( cd asan \u0026\u0026 \\\n    RUSTFLAGS=\"-Z sanitizer=address\" cargo run --target x86_64-unknown-linux-gnu --example use-after-free )\n     Running `target/x86_64-unknown-linux-gnu/debug/examples/use-after-free`\n=================================================================\n==8768==ERROR: AddressSanitizer: heap-use-after-free on address 0x60200000efb0 at pc 0x55b0dfb2da24 bp 0x7ffccf297230 sp 0x7ffccf297228\nREAD of size 4 at 0x60200000efb0 thread T0\n    #0 0x55b0dfb2da23 in use_after_free::main::hd24e5b31a91cd260 $PWD/examples/use-after-free.rs:5\n    #1 0x55b0dfc22046 in __rust_maybe_catch_panic ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/use-after-free+0x103046)\n    #2 0x55b0dfc1a9f9 in std::rt::lang_start::h6954771f55df116b ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/use-after-free+0xfb9f9)\n    #3 0x55b0dfb2db12 in main ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/use-after-free+0xeb12)\n    #4 0x7fb186053290 in __libc_start_main (/usr/lib/libc.so.6+0x20290)\n    #5 0x55b0dfb28869 in _start ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/use-after-free+0x9869)\n\n0x60200000efb0 is located 0 bytes inside of 16-byte region [0x60200000efb0,0x60200000efc0)\nfreed by thread T0 here:\n    #0 0x55b0dfbe0290 in __interceptor_cfree.localalias.0 $RUST_SRC/src/compiler-rt/lib/asan/asan_malloc_linux.cc:54\n    #1 0x55b0dfb2c05c in alloc::heap::deallocate::hfc4464969f6c2d6d $RUST_SRC/src/liballoc/heap.rs:113\n    #2 0x55b0dfb2d584 in _$LT$alloc..raw_vec..RawVec$LT$T$GT$$u20$as$u20$core..ops..Drop$GT$::drop::h379e52d625f89e1f $RUST_SRC/src/liballoc/raw_vec.rs:551\n    #3 0x55b0dfb2b780 in drop::h7608d0590516eb20 ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/use-after-free+0xc780)\n    #4 0x55b0dfb29988 in drop_contents::ha8e051e1000be907 ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/use-after-free+0xa988)\n    #5 0x55b0dfb2b7e6 in drop::ha8e051e1000be907 ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/use-after-free+0xc7e6)\n    #6 0x55b0dfb2ac38 in core::mem::drop::h1c3f8290e9a15dc0 $RUST_SRC/src/libcore/mem.rs:614\n    #7 0x55b0dfb2d9e3 in use_after_free::main::hd24e5b31a91cd260 $PWD/examples/use-after-free.rs:4\n    #8 0x55b0dfc22046 in __rust_maybe_catch_panic ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/use-after-free+0x103046)\n\npreviously allocated by thread T0 here:\n    #0 0x55b0dfbe0448 in malloc $RUST_SRC/src/compiler-rt/lib/asan/asan_malloc_linux.cc:64\n    #1 0x55b0dfb2d0af in alloc::heap::allocate::hada3930d4dfed51a $RUST_SRC/src/liballoc/heap.rs:59\n    #2 0x55b0dfb2c0b0 in alloc::heap::exchange_malloc::h1ae17faa3583b58c $RUST_SRC/src/liballoc/heap.rs:138\n    #3 0x55b0dfb2d816 in use_after_free::main::hd24e5b31a91cd260 $PWD/examples/use-after-free.rs:2\n    #4 0x55b0dfc22046 in __rust_maybe_catch_panic ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/use-after-free+0x103046)\n\nSUMMARY: AddressSanitizer: heap-use-after-free $PWD/examples/use-after-free.rs:5 in use_after_free::main::hd24e5b31a91cd260\nShadow bytes around the buggy address:\n  0x0c047fff9da0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n  0x0c047fff9db0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n  0x0c047fff9dc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n  0x0c047fff9dd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n  0x0c047fff9de0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n=\u003e0x0c047fff9df0: fa fa fa fa fa fa[fd]fd fa fa 05 fa fa fa fd fa\n  0x0c047fff9e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n  0x0c047fff9e10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n  0x0c047fff9e20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n  0x0c047fff9e30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n  0x0c047fff9e40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\nShadow byte legend (one shadow byte represents 8 application bytes):\n  Addressable:           00\n  Partially addressable: 01 02 03 04 05 06 07\n  Heap left redzone:       fa\n  Heap right redzone:      fb\n  Freed heap region:       fd\n  Stack left redzone:      f1\n  Stack mid redzone:       f2\n  Stack right redzone:     f3\n  Stack partial redzone:   f4\n  Stack after return:      f5\n  Stack use after scope:   f8\n  Global redzone:          f9\n  Global init order:       f6\n  Poisoned by user:        f7\n  Container overflow:      fc\n  Array cookie:            ac\n  Intra object redzone:    bb\n  ASan internal:           fe\n  Left alloca redzone:     ca\n  Right alloca redzone:    cb\n==8768==ABORTING\n```\n\n### LeakSanitizer\n\nThis sanitizer can detect memory leaks.\n\n#### Memory leak\n\n`lsan/examples/memory-leak.rs`\n\n``` rust\nuse std::mem;\n\nfn main() {\n    let xs = vec![0, 1, 2, 3];\n    mem::forget(xs);\n}\n```\n\n```\n$ ( cd lsan \u0026\u0026 \\\n    RUSTFLAGS=\"-Z sanitizer=leak\" cargo run --target x86_64-unknown-linux-gnu --example memory-leak )\n     Running `target/x86_64-unknown-linux-gnu/debug/examples/memory-leak`\n\n=================================================================\n==16341==ERROR: LeakSanitizer: detected memory leaks\n\nDirect leak of 16 byte(s) in 1 object(s) allocated from:\n    #0 0x56322c0acb1f in __interceptor_malloc $RUST_SRC/src/compiler-rt/lib/lsan/lsan_interceptors.cc:55\n    #1 0x56322c0a7aaa in alloc::heap::exchange_malloc::h1ae17faa3583b58c $RUST_SRC/src/liballoc/heap.rs:138\n    #2 0x56322c0a7afc in memory_leak::main::h0003a08cbe34b70c $PWD/examples/memory-leak.rs:4\n    #3 0x56322c0df896 in __rust_maybe_catch_panic ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/memory-leak+0x3d896)\n\nSUMMARY: LeakSanitizer: 16 byte(s) leaked in 1 allocation(s).\n```\n\n#### Rc cycle\n\n`lsan/examples/rc-cycle.rs`\n\n``` rust\nuse std::cell::RefCell;\nuse std::rc::Rc;\n\n#[derive(Clone)]\nstruct Cycle {\n    cell: RefCell\u003cOption\u003cRc\u003cCycle\u003e\u003e\u003e,\n}\n\nimpl Drop for Cycle {\n    fn drop(\u0026mut self) {\n        println!(\"freed\");\n    }\n}\n\nfn main() {\n    let cycle = Rc::new(Cycle { cell: RefCell::new(None)});\n    *cycle.cell.borrow_mut() = Some(cycle.clone());\n}\n```\n\n```\n$ ( cd lsan \u0026\u0026 \\\n    RUSTFLAGS=\"-Z sanitizer=leak\" cargo run --target x86_64-unknown-linux-gnu --example rc-cycle )\n    Finished dev [optimized + debuginfo] target(s) in 0.0 secs\n     Running `target/x86_64-unknown-linux-gnu/debug/examples/rc-cycle`\n\n=================================================================\n==16344==ERROR: LeakSanitizer: detected memory leaks\n\nDirect leak of 32 byte(s) in 1 object(s) allocated from:\n    #0 0x556812c577ca in __interceptor_malloc $RUST_SRC/src/compiler-rt/lib/lsan/lsan_interceptors.cc:55\n    #1 0x556812c52c3a in alloc::heap::exchange_malloc::h55adee8e9fba9338 $RUST_SRC/src/liballoc/heap.rs:138\n    #2 0x556812c5254e in _$LT$alloc..rc..Rc$LT$T$GT$$GT$::new::h63d403f2e66d1e71 $RUST_SRC/src/liballoc/rc.rs:293\n    #3 0x556812c52d44 in rc_cycle::main::hee2857f96ac2db92 $PWD/examples/rc-cycle.rs:16\n    #4 0x556812c8614a in __rust_maybe_catch_panic $RUST_SRC/src/libpanic_unwind/lib.rs:98\n    #5 0x556812c7ed06 in std::panicking::try\u003c(),fn()\u003e $RUST_SRC/src/libstd/panicking.rs:436\n    #6 0x556812c7ed06 in std::panic::catch_unwind\u003cfn(),()\u003e $RUST_SRC/src/libstd/panic.rs:361\n    #7 0x556812c7ed06 in std::rt::lang_start::hb7fc7ec87b663023 $RUST_SRC/src/libstd/rt.rs:57\n    #8 0x7f9a53e0f290 in __libc_start_main (/usr/lib/libc.so.6+0x20290)\n\nSUMMARY: LeakSanitizer: 32 byte(s) leaked in 1 allocation(s).\n```\n\n### MemorySanitizer\n\nThis sanitizer can detect reads of uninitialized memory.\n\n#### Uninitialized read\n\n`msan/examples/uninitialized-read.rs`\n\n``` rust\nuse std::mem;\n\nfn main() {\n    let xs: [u8; 4] = unsafe { mem::uninitialized() };\n    let y = xs[0] + xs[1];\n}\n```\n\n```\n$ ( cd msan \u0026\u0026 \\\n    RUSTFLAGS=\"-Z sanitizer=memory\" cargo run --target x86_64-unknown-linux-gnu --example uninitialized-read )\n     Running `target/x86_64-unknown-linux-gnu/debug/examples/uninitialized-read`\n==21418==WARNING: MemorySanitizer: use-of-uninitialized-value\n    #0 0x56107230e7da in uninitialized_read::main::h0c073cea3836efc1 $PWD/examples/uninitialized-read.rs:5\n    #1 0x56107238b446 in __rust_maybe_catch_panic ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/uninitialized-read+0x87446)\n    #2 0x561072383df9 in std::rt::lang_start::h6954771f55df116b ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/uninitialized-read+0x7fdf9)\n    #3 0x56107230e8a9 in main ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/uninitialized-read+0xa8a9)\n    #4 0x7f32de0b7290 in __libc_start_main (/usr/lib/libc.so.6+0x20290)\n    #5 0x56107230e4f9 in _start ($PWD/target/x86_64-unknown-linux-gnu/debug/examples/uninitialized-read+0xa4f9)\n\nSUMMARY: MemorySanitizer: use-of-uninitialized-value $PWD/examples/uninitialized-read.rs:5 in uninitialized_read::main::h0c073cea3836efc1\nExiting\n```\n\n### ThreadSanitizer\n\nThis sanitizer can detect data races.\n\n#### Data race\n\n`tsan/examples/data-race.rs`\n\n``` rust\nuse std::thread;\n\nstatic mut ANSWER: i32 = 0;\n\nfn main() {\n    let t1 = thread::spawn(|| unsafe { ANSWER = 42 });\n    unsafe {\n        ANSWER = 24;\n    }\n    t1.join().ok();\n}\n```\n\n```\n$ ( cd tsan \u0026\u0026 \\\n    RUSTFLAGS=\"-Z sanitizer=thread\" cargo run --target x86_64-unknown-linux-gnu --example data-race )\n     Running `target/x86_64-unknown-linux-gnu/debug/examples/data-race`\n==================\nWARNING: ThreadSanitizer: data race (pid=26481)\n  Write of size 4 at 0x55662b8b2bb4 by thread T1:\n    #0 data_race::main::_$u7b$$u7b$closure$u7d$$u7d$::hee96c0dbd110538f $PWD/examples/data-race.rs:6 (data-race+0x000000010e3f)\n    #1 _$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h325b4408e33222b1 $RUST_SRC/src/libstd/panic.rs:296 (data-race+0x000000010cc5)\n    #2 std::panicking::try::do_call::hce66d861a72cf7ad $RUST_SRC/src/libstd/panicking.rs:460 (data-race+0x00000000c942)\n    #3 __rust_maybe_catch_panic \u003cnull\u003e (data-race+0x0000000b4ee6)\n    #4 std::panic::catch_unwind::h8bcbba7f3956edf8 $RUST_SRC/src/libstd/panic.rs:361 (data-race+0x00000000b567)\n    #5 std::thread::Builder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::h59119aee2f2d06bf $RUST_SRC/src/libstd/thread/mod.rs:357 (data-race+0x00000000c276)\n    #6 _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hd916ceba2ff03dbf $RUST_SRC/src/liballoc/boxed.rs:614 (data-race+0x00000000f2ce)\n    #7 std::sys::imp::thread::Thread::new::thread_start::h6a0d1a011a706f06 \u003cnull\u003e (data-race+0x0000000abdd0)\n\n  Previous write of size 4 at 0x55662b8b2bb4 by main thread:\n    #0 data_race::main::h14a8ec63b6689873 $PWD/examples/data-race.rs:8 (data-race+0x000000010d7c)\n    #1 __rust_maybe_catch_panic \u003cnull\u003e (data-race+0x0000000b4ee6)\n    #2 __libc_start_main \u003cnull\u003e (libc.so.6+0x000000020290)\n\n  Location is global 'data_race::ANSWER::hcde8cae2a80d1e5d' of size 4 at 0x55662b8b2bb4 (data-race+0x0000002f8bb4)\n\n  Thread T1 (tid=26574, running) created by main thread at:\n    #0 pthread_create $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (data-race+0x00000001aedb)\n    #1 std::sys::imp::thread::Thread::new::h1a8b710ff34ac90e \u003cnull\u003e (data-race+0x0000000aba3e)\n    #2 std::thread::spawn::hef27947e8b208e27 $RUST_SRC/src/libstd/thread/mod.rs:412 (data-race+0x00000000b5fa)\n    #3 data_race::main::h14a8ec63b6689873 $PWD/examples/data-race.rs:6 (data-race+0x000000010d5c)\n    #4 __rust_maybe_catch_panic \u003cnull\u003e (data-race+0x0000000b4ee6)\n    #5 __libc_start_main \u003cnull\u003e (libc.so.6+0x000000020290)\n\nSUMMARY: ThreadSanitizer: data race $PWD/examples/data-race.rs:6 in data_race::main::_$u7b$$u7b$closure$u7d$$u7d$::hee96c0dbd110538f\n==================\nThreadSanitizer: reported 1 warnings\n```\n\n## Better backtraces\n\nYou can get even more complete backtraces if you recompile the `std` facade with\n`-Z sanitizer`. To do that, you can use [Xargo](https://crates.io/crates/xargo):\n\n```\n# install Xargo and its dependency, the rust-src component\n$ cargo install xargo\n\n$ rustup component add rust-src\n\n# add this file to the root of your Cargo project\n$ edit Xargo.toml \u0026\u0026 cat $_\n```\n\n``` toml\n[dependencies.std]\nfeatures = [\"panic-unwind\", \"asan\", \"lsan\", \"msan\", \"tsan\"]\n\n# if using `cargo test`\n[dependencies.test]\nstage = 1\n```\n\n```\n# Xargo has to rebuild the sanitizer runtimes and that requires `llvm-config`\n# (in a future Xargo version, this will not be necessary)\n$ export LLVM_CONFIG=$(which llvm-config)\n\n# then you can `xargo test` or `xargo run`\n$ RUSTFLAGS=\"-Z sanitizer=address\" xargo test --target x86_64-unknown-linux-gnu\n```\n\nTo make the above command work, you'll likely have to modify your `rust-src`\ncomponent, which should be in `(rustc --print sysroot)/lib/rustlib/src/rust`,\nlike this:\n\n``` diff\ndiff --git a/src/libgetopts/Cargo.toml b/src/libgetopts/Cargo.toml\nindex 99e3b89285..07593229af 100644\n--- a/src/libgetopts/Cargo.toml\n+++ b/src/libgetopts/Cargo.toml\n@@ -6,4 +6,4 @@ version = \"0.0.0\"\n [lib]\n name = \"getopts\"\n path = \"lib.rs\"\n-crate-type = [\"dylib\", \"rlib\"]\n+# crate-type = [\"dylib\", \"rlib\"]\ndiff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml\nindex 8146e7fb1e..c013995255 100644\n--- a/src/libstd/Cargo.toml\n+++ b/src/libstd/Cargo.toml\n@@ -7,7 +7,7 @@ build = \"build.rs\"\n [lib]\n name = \"std\"\n path = \"lib.rs\"\n-crate-type = [\"dylib\", \"rlib\"]\n+# crate-type = [\"dylib\", \"rlib\"]\n\n [dependencies]\n alloc = { path = \"../liballoc\" }\ndiff --git a/src/libterm/Cargo.toml b/src/libterm/Cargo.toml\nindex 8021e814c0..6891e0b912 100644\n--- a/src/libterm/Cargo.toml\n+++ b/src/libterm/Cargo.toml\n@@ -6,4 +6,4 @@ version = \"0.0.0\"\n [lib]\n name = \"term\"\n path = \"lib.rs\"\n-crate-type = [\"dylib\", \"rlib\"]\n+# crate-type = [\"dylib\", \"rlib\"]\ndiff --git a/src/libtest/Cargo.toml b/src/libtest/Cargo.toml\nindex ecbd5a9c0f..553150cdd1 100644\n--- a/src/libtest/Cargo.toml\n+++ b/src/libtest/Cargo.toml\n@@ -6,7 +6,7 @@ version = \"0.0.0\"\n [lib]\n name = \"test\"\n path = \"lib.rs\"\n-crate-type = [\"dylib\", \"rlib\"]\n+# crate-type = [\"dylib\", \"rlib\"]\n\n [dependencies]\n getopts = { path = \"../libgetopts\" }\n\n```\n\n## Caveats / known bugs\n\n### Unrealiable LeakSanitizer\n\nI have found that LeakSanitizer not always catches memory leaks *unless* you\nhave compiled your code with `-C opt-level=1` or better. You can change the\noptimization level of the `dev` profile in your `Cargo.toml` like this:\n\n``` toml\n# Cargo.toml\n[profile.dev]\nopt-level = 1\n```\n\n### CARGO_INCREMENTAL\n\n[rust-lang/rust#39611](https://github.com/rust-lang/rust/issues/39611)\n\nIf you have set `CARGO_INCREMENTAL=1` in your environment to use / test\nincremental compilation then you'll have to remove it as incremental compilation\nbreaks sanitizer support.\n\n### MemorySanitizer: Use of uninitialized value in the test runner\n\n[rust-lang/rust#39610](https://github.com/rust-lang/rust/issues/39610)\n\nThis effectively means you can't really `cargo test` your crate with\nMemorySanitizer as you'll always get errors.\n\n`src/lib.rs`\n\n``` rust\n#[test]\nfn foo() {}\n```\n\n```\n$ RUSTFLAGS=\"-Z sanitizer=memory\" cargo test --target x86_64-unknown-linux-gnu\n     Running target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235\nUninitialized bytes in __interceptor_memchr at offset 13 inside [0x70400000ef60, 23)\n==6915==WARNING: MemorySanitizer: use-of-uninitialized-value\n    #0 0x55aec536a8b5 in std::ffi::c_str::CString::_new::h1600b539eb5d8b8c ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0xc58b5)\n    #1 0x55aec537399a in std::sys::imp::fs::stat::h72120555244bec39 ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0xce99a)\n    #2 0x55aec5355b18 in std::fs::metadata::h4ae9b0fd118f3836 ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0xb0b18)\n    #3 0x55aec535bea8 in term::terminfo::searcher::get_dbpath_for_term::hc53288f466988180 ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0xb6ea8)\n    #4 0x55aec535b3f1 in term::terminfo::TermInfo::from_name::hb95f189f4c99eccf ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0xb63f1)\n    #5 0x55aec535b1a2 in term::terminfo::TermInfo::from_env::h45b8e5476a2a09d7 ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0xb61a2)\n    #6 0x55aec5365c70 in term::stdout::h84d7912730b73cf4 ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0xc0c70)\n    #7 0x55aec52d28bd in _$LT$test..ConsoleTestState$LT$T$GT$$GT$::new::h937954646ef1f1d9 ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0x2d8bd)\n    #8 0x55aec52d481a in test::run_tests_console::h7b41f829f623d5c0 ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0x2f81a)\n    #9 0x55aec52cfdb8 in test::test_main::hae140f91361b0544 ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0x2adb8)\n    #10 0x55aec52d06ce in test::test_main_static::h9b2aae5d6f64eac6 ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0x2b6ce)\n    #11 0x55aec52be9a3 in test_runner::__test::main::h164d7dfa966cbb3f $PWD/src/lib.rs:1\n    #12 0x55aec537d5d6 in __rust_maybe_catch_panic ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0xd85d6)\n    #13 0x55aec5376bc9 in std::rt::lang_start::h6954771f55df116b ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0xd1bc9)\n    #14 0x55aec52bea19 in main ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0x19a19)\n    #15 0x7fc24cf2f290 in __libc_start_main (/usr/lib/libc.so.6+0x20290)\n    #16 0x55aec52be839 in _start ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0x19839)\n\nSUMMARY: MemorySanitizer: use-of-uninitialized-value ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/test_runner-d861d6557762b235+0xc58b5) in std::ffi::c_str::CString::_new::h1600b539eb5d8b8c\nExiting\nerror: test failed\n```\n\n### ThreadSanitizer: Data race in the test runner\n\n[rust-lang/rust#39608](https://github.com/rust-lang/rust/issues/39608)\n\nUsing ThreadSanitizer to test any library crate with more that one unit test\nresults in data race reports unrelated to the tests themselves.\n\n`src/lib.rs`\n\n``` rust\n#[test]\nfn foo() {}\n\n#[test]\nfn bar() {}\n```\n\n```\n$ RUSTFLAGS=\"-Z sanitizer=thread\" cargo test --target x86_64-unknown-linux-gnu\n     Running target/x86_64-unknown-linux-gnu/debug/deps/foo-aacd724200d968b7\n\nrunning 2 tests\n==================\nWARNING: ThreadSanitizer: data race (pid=3733)\n  Read of size 8 at 0x7c7800006f28 by main thread:\n    #0 memcpy $RUST_SRC/src/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:598 (foo-aacd724200d968b7+0x000000056009)\n    #1 memcpy $RUST_SRC/src/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:590 (foo-aacd724200d968b7+0x000000056009)\n    #2 core::mem::swap\u003ccore::option::Option\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e\u003e $RUST_SRC/src/libcore/mem.rs:454 (foo-aacd724200d968b7+0x00000001adfe)\n    #3 core::mem::replace\u003ccore::option::Option\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e\u003e $RUST_SRC/src/libcore/mem.rs:518 (foo-aacd724200d968b7+0x00000001adfe)\n    #4 core::option::{{impl}}::take\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libcore/option.rs:725 (foo-aacd724200d968b7+0x00000001adfe)\n    #5 _$LT$std..sync..mpsc..mpsc_queue..Queue$LT$T$GT$$GT$::pop::hd044437806ca7d86 $RUST_SRC/src/libstd/sync/mpsc/mpsc_queue.rs:126 (foo-aacd724200d968b7+0x00000001adfe)\n    #6 __rust_maybe_catch_panic $RUST_SRC/src/libpanic_unwind/lib.rs:98 (foo-aacd724200d968b7+0x0000000d8b0a)\n    #7 __libc_start_main \u003cnull\u003e (libc.so.6+0x000000020290)\n\n  Previous write of size 8 at 0x7c7800006f28 by thread T1:\n    #0 malloc $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:591 (foo-aacd724200d968b7+0x000000061e1f)\n    #1 alloc::heap::allocate $RUST_SRC/src/liballoc/heap.rs:59 (foo-aacd724200d968b7+0x000000014bb2)\n    #2 alloc::heap::exchange_malloc $RUST_SRC/src/liballoc/heap.rs:138 (foo-aacd724200d968b7+0x000000014bb2)\n    #3 std::sync::mpsc::mpsc_queue::{{impl}}::new\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/mpsc_queue.rs:80 (foo-aacd724200d968b7+0x000000014bb2)\n    #4 std::sync::mpsc::mpsc_queue::{{impl}}::push\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/mpsc_queue.rs:101 (foo-aacd724200d968b7+0x000000014bb2)\n    #5 std::sync::mpsc::shared::{{impl}}::send\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/shared.rs:171 (foo-aacd724200d968b7+0x000000014bb2)\n    #6 _$LT$std..sync..mpsc..Sender$LT$T$GT$$GT$::send::h1f83562f10dffde2 $RUST_SRC/src/libstd/sync/mpsc/mod.rs:607 (foo-aacd724200d968b7+0x000000014bb2)\n\n  Location is heap block of size 224 at 0x7c7800006f20 allocated by thread T1:\n    #0 malloc $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:591 (foo-aacd724200d968b7+0x000000061e1f)\n    #1 alloc::heap::allocate $RUST_SRC/src/liballoc/heap.rs:59 (foo-aacd724200d968b7+0x000000014bb2)\n    #2 alloc::heap::exchange_malloc $RUST_SRC/src/liballoc/heap.rs:138 (foo-aacd724200d968b7+0x000000014bb2)\n    #3 std::sync::mpsc::mpsc_queue::{{impl}}::new\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/mpsc_queue.rs:80 (foo-aacd724200d968b7+0x000000014bb2)\n    #4 std::sync::mpsc::mpsc_queue::{{impl}}::push\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/mpsc_queue.rs:101 (foo-aacd724200d968b7+0x000000014bb2)\n    #5 std::sync::mpsc::shared::{{impl}}::send\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/shared.rs:171 (foo-aacd724200d968b7+0x000000014bb2)\n    #6 _$LT$std..sync..mpsc..Sender$LT$T$GT$$GT$::send::h1f83562f10dffde2 $RUST_SRC/src/libstd/sync/mpsc/mod.rs:607 (foo-aacd724200d968b7+0x000000014bb2)\n\n  Thread T1 'bar' (tid=3735, finished) created by main thread at:\n    #0 pthread_create $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (foo-aacd724200d968b7+0x00000003b9a7)\n    #1 std::sys::imp::thread::Thread::new::h13e24a45e97a3e79 $RUST_SRC/src/libstd/sys/unix/thread.rs:72 (foo-aacd724200d968b7+0x0000000d0765)\n    #2 __rust_maybe_catch_panic $RUST_SRC/src/libpanic_unwind/lib.rs:98 (foo-aacd724200d968b7+0x0000000d8b0a)\n    #3 __libc_start_main \u003cnull\u003e (libc.so.6+0x000000020290)\n\nSUMMARY: ThreadSanitizer: data race $RUST_SRC/src/libcore/mem.rs:454 in core::mem::swap\u003ccore::option::Option\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e\u003e\n==================\ntest bar ... ok\n==================\nWARNING: ThreadSanitizer: data race (pid=3733)\n  Write of size 8 at 0x7c7800006f20 by main thread:\n    #0 free $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:634 (foo-aacd724200d968b7+0x00000003cf06)\n    #1 free $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:628 (foo-aacd724200d968b7+0x00000003cf06)\n    #2 _$LT$std..sync..mpsc..mpsc_queue..Queue$LT$T$GT$$GT$::pop::hd044437806ca7d86 $RUST_SRC/src/libstd/sync/mpsc/mpsc_queue.rs:127 (foo-aacd724200d968b7+0x00000001ae56)\n    #3 __rust_maybe_catch_panic $RUST_SRC/src/libpanic_unwind/lib.rs:98 (foo-aacd724200d968b7+0x0000000d8b0a)\n    #4 __libc_start_main \u003cnull\u003e (libc.so.6+0x000000020290)\n\n  Previous write of size 8 at 0x7c7800006f20 by thread T1:\n    #0 malloc $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:591 (foo-aacd724200d968b7+0x000000061e1f)\n    #1 alloc::heap::allocate $RUST_SRC/src/liballoc/heap.rs:59 (foo-aacd724200d968b7+0x000000014bb2)\n    #2 alloc::heap::exchange_malloc $RUST_SRC/src/liballoc/heap.rs:138 (foo-aacd724200d968b7+0x000000014bb2)\n    #3 std::sync::mpsc::mpsc_queue::{{impl}}::new\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/mpsc_queue.rs:80 (foo-aacd724200d968b7+0x000000014bb2)\n    #4 std::sync::mpsc::mpsc_queue::{{impl}}::push\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/mpsc_queue.rs:101 (foo-aacd724200d968b7+0x000000014bb2)\n    #5 std::sync::mpsc::shared::{{impl}}::send\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/shared.rs:171 (foo-aacd724200d968b7+0x000000014bb2)\n    #6 _$LT$std..sync..mpsc..Sender$LT$T$GT$$GT$::send::h1f83562f10dffde2 $RUST_SRC/src/libstd/sync/mpsc/mod.rs:607 (foo-aacd724200d968b7+0x000000014bb2)\n\n  Thread T1 'bar' (tid=3735, finished) created by main thread at:\n    #0 pthread_create $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (foo-aacd724200d968b7+0x00000003b9a7)\n    #1 std::sys::imp::thread::Thread::new::h13e24a45e97a3e79 $RUST_SRC/src/libstd/sys/unix/thread.rs:72 (foo-aacd724200d968b7+0x0000000d0765)\n    #2 __rust_maybe_catch_panic $RUST_SRC/src/libpanic_unwind/lib.rs:98 (foo-aacd724200d968b7+0x0000000d8b0a)\n    #3 __libc_start_main \u003cnull\u003e (libc.so.6+0x000000020290)\n\nSUMMARY: ThreadSanitizer: data race $RUST_SRC/src/libstd/sync/mpsc/mpsc_queue.rs:127 in _$LT$std..sync..mpsc..mpsc_queue..Queue$LT$T$GT$$GT$::pop::hd044437806ca7d86\n==================\ntest foo ... ok\n==================\nWARNING: ThreadSanitizer: data race (pid=3733)\n  Write of size 8 at 0x7c7800006e40 by main thread:\n    #0 free $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:634 (foo-aacd724200d968b7+0x00000003cf06)\n    #1 free $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:628 (foo-aacd724200d968b7+0x00000003cf06)\n    #2 drop::hf0d57a221ac19123 \u003cnull\u003e (foo-aacd724200d968b7+0x000000019fb1)\n    #3 __rust_maybe_catch_panic $RUST_SRC/src/libpanic_unwind/lib.rs:98 (foo-aacd724200d968b7+0x0000000d8b0a)\n    #4 __libc_start_main \u003cnull\u003e (libc.so.6+0x000000020290)\n\n  Previous write of size 8 at 0x7c7800006e40 by thread T2:\n    #0 malloc $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:591 (foo-aacd724200d968b7+0x000000061e1f)\n    #1 alloc::heap::allocate $RUST_SRC/src/liballoc/heap.rs:59 (foo-aacd724200d968b7+0x000000014bb2)\n    #2 alloc::heap::exchange_malloc $RUST_SRC/src/liballoc/heap.rs:138 (foo-aacd724200d968b7+0x000000014bb2)\n    #3 std::sync::mpsc::mpsc_queue::{{impl}}::new\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/mpsc_queue.rs:80 (foo-aacd724200d968b7+0x000000014bb2)\n    #4 std::sync::mpsc::mpsc_queue::{{impl}}::push\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/mpsc_queue.rs:101 (foo-aacd724200d968b7+0x000000014bb2)\n    #5 std::sync::mpsc::shared::{{impl}}::send\u003c(test::TestDesc, test::TestResult, collections::vec::Vec\u003cu8\u003e)\u003e $RUST_SRC/src/libstd/sync/mpsc/shared.rs:171 (foo-aacd724200d968b7+0x000000014bb2)\n    #6 _$LT$std..sync..mpsc..Sender$LT$T$GT$$GT$::send::h1f83562f10dffde2 $RUST_SRC/src/libstd/sync/mpsc/mod.rs:607 (foo-aacd724200d968b7+0x000000014bb2)\n\n  Thread T2 'foo' (tid=3736, finished) created by main thread at:\n    #0 pthread_create $RUST_SRC/src/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (foo-aacd724200d968b7+0x00000003b9a7)\n    #1 std::sys::imp::thread::Thread::new::h13e24a45e97a3e79 $RUST_SRC/src/libstd/sys/unix/thread.rs:72 (foo-aacd724200d968b7+0x0000000d0765)\n    #2 __rust_maybe_catch_panic $RUST_SRC/src/libpanic_unwind/lib.rs:98 (foo-aacd724200d968b7+0x0000000d8b0a)\n    #3 __libc_start_main \u003cnull\u003e (libc.so.6+0x000000020290)\n\nSUMMARY: ThreadSanitizer: data race ($PWD/target/x86_64-unknown-linux-gnu/debug/deps/foo-aacd724200d968b7+0x19fb1) in drop::hf0d57a221ac19123\n==================\n\ntest result: ok. 2 passed; 0 failed; 0 ignored; 0 measured\n\nThreadSanitizer: reported 3 warnings\nerror: test failed\n```\n\nWorkaround: `export RUST_TEST_THREADS=1` to run your test suite sequentially.\n\n### Suppression of False Positives\n\nThere are some cases where the sanitizers will generate false positives, such as reporting data races in code that uses `std::sync::atomic::fence`, or unsafe pointer usage while relying on the ordering semantics of adjacent barriers. This can generate a ton of noise, as popular libraries like `lazy_static` can trigger this.\n\n```\nWARNING: ThreadSanitizer: data race (pid=30975)                                                                                      \n  Read of size 8 at 0x55ddb40e5418 by thread T2:                                                                                                                         \n    #0 _$LT$lazy_static..lazy..Lazy$LT$T$GT$$GT$::get::hb947a249eaade5b0 /home/t/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-0.2.8/src/lazy.rs:26 (stress+0x279323)\n    #1 rayon_core::log::{{impl}}::deref::__stability /home/t/src/rsdb/\u003c__lazy_static_internal macros\u003e:20 (stress+0x2a8520)\n    #2 _$LT$rayon_core..log..LOG_ENV$u20$as$u20$core..ops..deref..Deref$GT$::deref::h995f5b423216fc8c /home/t/src/rsdb/\u003c__lazy_static_internal macros\u003e:21 (stress+0x2a8520)                      \n    #3 rayon_core::registry::WorkerThread::wait_until::h14e38df285736ca7 /home/t/src/rsdb/rayon/rayon-core/src/registry.rs:434 (stress+0x2a0ac1)\n    #4 rayon_core::registry::WorkerThread::wait_until::h14e38df285736ca7 /home/t/src/rsdb/rayon/rayon-core/src/registry.rs:434 (stress+0x2a0ac1)                                                      \n    #5 rayon_core::registry::main_loop::h120d26ee2b06f3e1 /home/t/src/rsdb/rayon/rayon-core/src/registry.rs:559 (stress+0x2a2ba3)\n    #6 rayon_core::registry::Registry::new::_$u7b$$u7b$closure$u7d$$u7d$::h73e776a16b1aafcd /home/t/src/rsdb/rayon/rayon-core/src/registry.rs:145 (stress+0x2a87fa)\n    #7 std::sys_common::backtrace::__rust_begin_short_backtrace::h70e0fa277eccaded /checkout/src/libstd/sys_common/backtrace.rs:136 (stress+0x274b63)\n    #8 std::thread::Builder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h73f1afe39e3f5d92 /checkout/src/libstd/thread/mod.rs:364 (stress+0x2772e9)\n    #9 _$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h0fef211ea8e53025 /checkout/src/libstd/panic.rs:296 (stress+0x269582)\n    #10 std::panicking::try::do_call::h0164d0443475d14d /checkout/src/libstd/panicking.rs:479 (stress+0x277ab3)                                      \n    #11 __rust_maybe_catch_panic /checkout/src/libpanic_unwind/lib.rs:98 (stress+0x30999c)                                                                                \n    #12 std::panic::catch_unwind::h0f7a13324f48e132 /checkout/src/libstd/panic.rs:361 (stress+0x2761bb)                                                                                       \n    #13 std::thread::Builder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::h8fabb47bf4134341 /checkout/src/libstd/thread/mod.rs:363 (stress+0x277091)                                                         \n    #14 _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::h34535139aa115aa0 /checkout/src/liballoc/boxed.rs:652 (stress+0x29081f)\n    #15 alloc::boxed::{{impl}}::call_once\u003c(),()\u003e /checkout/src/liballoc/boxed.rs:662 (stress+0x30169b)      \n    #16 std::sys_common::thread::start_thread /checkout/src/libstd/sys_common/thread.rs:21 (stress+0x30169b)                                    \n    #17 std::sys::imp::thread::Thread::new::thread_start::h3eac17b79d7b9487 /checkout/src/libstd/sys/unix/thread.rs:84 (stress+0x30169b)     \n                                                                                                                                                                   \n  Previous write of size 8 at 0x55ddb40e5418 by thread T1:                                                                                           \n    #0 _$LT$lazy_static..lazy..Lazy$LT$T$GT$$GT$::get::_$u7b$$u7b$closure$u7d$$u7d$::he4e15a492cb08e5f /home/t/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-0.2.8/src/lazy.rs:23 (stress+0x27946f)\n    #1 std::sync::once::Once::call_once::_$u7b$$u7b$closure$u7d$$u7d$::hecb03b941ecc49ae /checkout/src/libstd/sync/once.rs:227 (stress+0x2755f3)                                              \n    #2 std::sync::once::Once::call_inner::h7a6867e4a5c8eee6 /checkout/src/libstd/sync/once.rs:307 (stress+0x2fbe2c)\n    #3 _$LT$lazy_static..lazy..Lazy$LT$T$GT$$GT$::get::hb947a249eaade5b0 /home/t/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-0.2.8/src/lazy.rs:22 (stress+0x27930e)\n    #4 rayon_core::log::{{impl}}::deref::__stability /home/t/src/rsdb/\u003c__lazy_static_internal macros\u003e:20 (stress+0x2a8520)\n    #5 _$LT$rayon_core..log..LOG_ENV$u20$as$u20$core..ops..deref..Deref$GT$::deref::h995f5b423216fc8c /home/t/src/rsdb/\u003c__lazy_static_internal macros\u003e:21 (stress+0x2a8520)\n    #6 rayon_core::registry::WorkerThread::wait_until::h14e38df285736ca7 /home/t/src/rsdb/rayon/rayon-core/src/registry.rs:434 (stress+0x2a0ac1)\n    #7 rayon_core::registry::WorkerThread::wait_until::h14e38df285736ca7 /home/t/src/rsdb/rayon/rayon-core/src/registry.rs:434 (stress+0x2a0ac1)\n    #8 rayon_core::registry::main_loop::h120d26ee2b06f3e1 /home/t/src/rsdb/rayon/rayon-core/src/registry.rs:559 (stress+0x2a2ba3)\n    #9 rayon_core::registry::Registry::new::_$u7b$$u7b$closure$u7d$$u7d$::h73e776a16b1aafcd /home/t/src/rsdb/rayon/rayon-core/src/registry.rs:145 (stress+0x2a87fa)\n    #10 std::sys_common::backtrace::__rust_begin_short_backtrace::h70e0fa277eccaded /checkout/src/libstd/sys_common/backtrace.rs:136 (stress+0x274b63)\n    #11 std::thread::Builder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h73f1afe39e3f5d92 /checkout/src/libstd/thread/mod.rs:364 (stress+0x2772e9)\n    #12 _$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h0fef211ea8e53025 /checkout/src/libstd/panic.rs:296 (stress+0x269582)\n    #13 std::panicking::try::do_call::h0164d0443475d14d /checkout/src/libstd/panicking.rs:479 (stress+0x277ab3)\n    #14 __rust_maybe_catch_panic /checkout/src/libpanic_unwind/lib.rs:98 (stress+0x30999c)\n    #15 std::panic::catch_unwind::h0f7a13324f48e132 /checkout/src/libstd/panic.rs:361 (stress+0x2761bb)\n    #16 std::thread::Builder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::h8fabb47bf4134341 /checkout/src/libstd/thread/mod.rs:363 (stress+0x277091)\n    #17 _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::h34535139aa115aa0 /checkout/src/liballoc/boxed.rs:652 (stress+0x29081f)\n    #18 alloc::boxed::{{impl}}::call_once\u003c(),()\u003e /checkout/src/liballoc/boxed.rs:662 (stress+0x30169b)\n    #19 std::sys_common::thread::start_thread /checkout/src/libstd/sys_common/thread.rs:21 (stress+0x30169b)\n    #20 std::sys::imp::thread::Thread::new::thread_start::h3eac17b79d7b9487 /checkout/src/libstd/sys/unix/thread.rs:84 (stress+0x30169b)\n\n  Location is global '_$LT$rayon_core..log..LOG_ENV$u20$as$u20$core..ops..deref..Deref$GT$::deref::__stability::LAZY::h79a6f8f41963a1dd' of size 16 at 0x55ddb40e5418 (stress+0x0000013d5418)\n```\n\nThese errors can be suppressed by setting the `TSAN_OPTIONS` environment variable, and providing a suppressions configuration file:\n\n```\nexport TSAN_OPTIONS=\"suppressions=blacklist.txt\"\n```\n\nWhere the configuration file looks something like this:\n\n```\n# Library foobar is full of races.\n# Filed bug 123, but do not want to deal with it now.\nrace:foobar\n\n# The function turns to be racy. Bug 345.\nrace:NuclearRocket::Launch\n\n# The race is introduced in patch 456. Bug 567.\nrace:src/surgery/laser_scalpel.cc\n\n# Global var global_var is racy. Bug 568.\nrace:global_var\n\n# short() function is racy, but not match any other functions containing \"short\". Bug 569.\nrace:^short$\n\n# The following thread leaks. Bug 678.\nthread:MonitoringThread\n\n# Uninstrumented library.\ncalled_from_lib:libzmq.so\n```\n\nYou can find additional documentation for the LLVM suppression file [here](https://github.com/google/sanitizers/wiki/ThreadSanitizerSuppressions).\n\n# License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n  http://www.apache.org/licenses/LICENSE-2.0)\n\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaparic%2Frust-san","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaparic%2Frust-san","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaparic%2Frust-san/lists"}