Skip to content

Instantly share code, notes, and snippets.

View pftbest's full-sized avatar

Vadzim Dambrouski pftbest

View GitHub Profile
extern crate servo_arc;
use std::thread;
use servo_arc::Arc;
fn main() {
let a1 = Arc::new(0);
let mut a2 = a1.clone();
let t1 = thread::spawn(
move || {
$ RUSTFLAGS="-Z sanitizer=thread" cargo run --target x86_64-apple-darwin
Compiling nodrop v0.1.12
Compiling stable_deref_trait v1.1.0
Compiling servo_arc v0.1.1 (file:///Users/vadzim/Downloads/relay/servo_arc)
Compiling relay v0.1.0 (file:///Users/vadzim/Downloads/relay)
Finished dev [unoptimized + debuginfo] target(s) in 1.38s
Running `target/x86_64-apple-darwin/debug/relay`
==================
WARNING: ThreadSanitizer: data race (pid=19187)
Write of size 4 at 0x7b0400000058 by thread T2:
$ RUSTFLAGS="-Z sanitizer=thread" cargo run --target x86_64-unknown-linux-gnu
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/x86_64-unknown-linux-gnu/debug/race`
==================
WARNING: ThreadSanitizer: data race (pid=10398)
Read of size 8 at 0x560b19db1640 by thread T3:
#0 _$LT$lazy_static..lazy..Lazy$LT$T$GT$$GT$::get::hb48391d610a44618 /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.0.1/src/lazy.rs:27:12 (race+0x8ef95)
#1 _$LT$rayon_core..log..LOG_ENV$u20$as$u20$core..ops..deref..Deref$GT$::deref::__stability::h4e948c2706d5a931 /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.0/<__lazy_static_internal macros>:13 (race+0x8ef95)
#2 _$LT$rayon_core..log..LOG_ENV$u20$as$u20$core..ops..deref..Deref$GT$::deref::hbad064cf5bff338a /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.4.0/<__lazy_static_internal macros>:14 (race+0x8ef95)
#3
use std::sync::Arc;
use std::thread;
fn main() {
let a1 = Arc::new(0);
let mut a2 = a1.clone();
let t1 = thread::spawn(
move || {
let _ : u32 = *a1;
drop(a1);
Dist std stage2 (x86_64-unknown-linux-gnu -> msp430-none-elf)
Building stage2 std artifacts (x86_64-unknown-linux-gnu -> msp430-none-elf)
Compiling core v0.0.0 (file:///checkout/src/libcore)
error: linking with `cc` failed: exit code: 1
note: "cc" "-mcpu=msp430" "-c" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/msp430-none-elf/release/deps/core-333ebd89cff70b31.core0.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/msp430-none-elf/release/deps/core-333ebd89cff70b31.core0.rcgu.s"
note: cc: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/msp430-none-elf/release/deps/core-333ebd89cff70b31.core0.rcgu.s: Assembler messages:
/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/msp430-none-elf/release/deps/core-333ebd89cff70b31.core0.rcgu.s:520: Error: no such instruction: `mov.w r13,r14'
[user@ws-073 llvm-build]$
[user@ws-073 llvm-build]$ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON -DLLVM_USE_SANITIZER=Address -DLLVM_TARGETS_TO_BUILD="MSP430;X86" ../llvm
CMake Deprecation Warning at CMakeLists.txt:14 (cmake_policy):
The OLD behavior for policy CMP0051 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
diff --git a/src/sysroot.rs b/src/sysroot.rs
index 6fba61e..b684154 100644
--- a/src/sysroot.rs
+++ b/src/sysroot.rs
@@ -70,8 +70,9 @@ version = "0.0.0"
}
for (_, stage) in blueprint.stages {
- let td = TempDir::new("xargo").chain_err(|| "couldn't create a temporary directory")?;
- let td = td.path();
// complie with:
// clang++ -O3 -std=c++11 -pthread -fsanitize=thread main.cpp
#include <atomic>
#include <thread>
#include <iostream>
static uint8_t data;
static std::atomic<bool> flag = {false};
@pftbest
pftbest / main.rs
Last active November 9, 2017 13:51
extern crate heapless;
use std::thread;
use heapless::ring_buffer::RingBuffer;
fn main() {
static mut V: RingBuffer<u8, [u8; 512]> = RingBuffer::new();
let (mut tx, mut rx) = unsafe { V.split() };
[user@ws-073 lockfree]$ RUSTFLAGS="-Z sanitizer=thread" cargo run --target x86_64-unknown-linux-gnu --release
Compiling lockfree v0.1.0 (file:///home/user/Downloads/lockfree)
Finished release [optimized] target(s) in 2.69 secs
Running `target/x86_64-unknown-linux-gnu/release/lockfree`
Hello, world!
==================
WARNING: ThreadSanitizer: data race (pid=19847)
Read of size 1 at 0x556297041018 by thread T2:
#0 _$LT$heapless..ring_buffer..spsc..Consumer$LT$$u27$a$C$$u20$T$C$$u20$A$GT$$GT$::dequeue::h31f23327099559ac <null> (lockfree+0xcb7b)
#1 std::sys_common::backtrace::__rust_begin_short_backtrace::hff50da7ea01f1850 <null> (lockfree+0xa6b7)