Skip to content

BorrowSanitizer/bsan

Repository files navigation

CI docs project chat Open in Dev Containers

BorrowSanitizer BorrowSanitizer

BorrowSanitizer is work-in-progress LLVM instrumentation pass for detecting aliasing violations in multi-language Rust applications. Our project is still in early stages, and it is not functional yet. Our goal is to support detecting the following types of errors:

  • Violations of Rust's Tree Borrows aliasing model.
  • Accesses out-of-bounds
  • Use-after free errors.

This project contains a fork of Miri's borrow tracker (bsan-shared, bsan-rt), as well as several other components from both Miri and the Rust compiler.

Check out our website for more information.

Usage

The easiest way to try BorrowSanitizer is inside a Docker container. Our image supports the following platforms:

Platform Target Description
linux/amd64 aarch64-unknown-linux-gnu ARM64 Linux
linux/arm64 x86_64-unknown-linux-gnu X86 Linux

First, pull our latest image from GitHub's container registry.

docker pull ghcr.io/borrowsanitizer/bsan:latest

Then, launch a container and attach a shell.

docker run -it bsan:latest

Once inside the container, you can use our Cargo plugin to build and test crates using BorrowSanitizer.

cargo bsan test

Our plugin supports most of the same subcommands as Miri. When it's used for the first time, it will perform a one-time setup step of building an instrumented sysroot. You can trigger this step manually using the setup subcommand.

Building from Source

Every single command needed to build, test, and install BorrrowSanitizer can be accessed through xb, our build script. For first-time setup, run:

xb setup

If you only want to install BorrowSanitizer, then run:

xb install

This will install a custom Rust toolchain under the name bsan. You can speed this up by building our dev container, which already has the bsan toolchain installed. We recommend using the container to avoid any environment-specific issues.

You can build and test components of the project using the build and test subcommands. For example, running xb build will build everything, but you can also pass the name of a subdirectory to build just that component, like so:

xb build bsan-rt

Nearly every subcommand can be used this way.

After making a change, you should run all of our CI steps locally using:

xb ci

This will place our binaries into Cargo's home directory ($HOME/.cargo). You will need to have bsan set as the active toolchain (e.g. rustup default bsan) for our tool to work.


BorrowSanitizer is dual-licensed under Apache and MIT, following the Rust project.

Zulip Zulip sponsors free hosting for BorrowSanitizer. Zulip is an organized team chat app designed for efficient communication.

About

Finding ownership bugs at scale.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 3

  •  
  •  
  •  

Languages