Skip to content

open-s4c/dice-rs

Repository files navigation

dicers

rust wrapper for dice

Note

Dice is a lightweight, extensible C framework for capturing and distributing execution events in multithreaded programs. Designed for low overhead and high flexibility, Dice enables powerful tooling for runtime monitoring, concurrency testing, and deterministic replay using a modular publish-subscribe (pubsub) architecture.

Warning

might require: #106 Memory Alignment Patch

use

  1. build dice
  2. build crate
  3. run

build and run the replay example

gcc -std=c11 -O1 -g -pthread -fsanitize=thread tests/atomic_stable.c -o tests/atomic_stable

cargo build && clear && TSANO_LIBDIR=dice/build/deps/tsano/ ./dice/deps/tsano/tsano LD_PRELOAD=dice/build/src/dice/libdice.so:dice/build/src/mod/dice-malloc.so:dice/build/src/mod/dice-pthread_create.so:dice/build/src/mod/dice-self.so:dice/build/src/mod/dice
-tsan.so:target/debug/libreplay.so ./tests/atomic_stable

build dice

note: this is automatic, but for debugging its easier to not use the mangled modules for preload but from dice. TODO: this should be completely autogenerated and linked statically where modules should be feature flags.

cd dice
cmake -S . -B build \
    -DCMAKE_BUILD_TYPE=Release \
    -DDICE_TESTS=OFF \
    -DDICE_BENCHMARKS=OFF \
    -DDICE_LTO=ON \
    -DDICE_INTERPOSE_MEMCPY=OFF \
    -DDICE_ALLOC_STRICT_ALIGN8=ON

cmake --build build -j

run examples:

Warning

when compiling with clang, we additionally require -shared-libsan

for llvm these flags may also be nice if only atomics are of focus for interception

-mllvm -tsan-instrument-memory-accesses=0

malloc_exmaple:

simplest malloc test case

gcc -std=c11 -O1 -g tests/malloc_example.c -o tests/malloc_example

LD_PRELOAD=dice/build/src/dice/libdice.so:dice/build/src/mod/dice-malloc.so:dice/build/src/mod/dice-self.so:target/debug/libdicers.so ./tests/malloc_example

atomic_racecon

race condition

g++ -std=c++17 -O1 -g -fsanitize=thread -fno-omit-frame-pointer -pthread tests/atomic_racecon.cc -o tests/atomic_racecon

atomic_stable

tests atomic operations and thread shedules while keeping the result stable

gcc -std=c11 -O1 -g -pthread -fsanitize=thread tests/atomic_stable.c -o tests/atomic_stable

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published