Skip to content

Tracking issue for sanitizer support #39699

Open
@japaric

Description

@japaric

Currently we have:

  • A rustc flag, -Z sanitizer, to sanitize rlibs (it adds an extra LLVM pass/attribute) and executables (it links to the sanitizer runtime). Added in LeakSanitizer, ThreadSanitizer, AddressSanitizer and MemorySanitizer support #38699.

  • An attribute #[no_sanitize] to disable sanitization on specific functions. Also lints if those functions are marked as requesting inlining. Added in Selectively disable sanitizer instrumentation #68164.

    • #[no_sanitize] suppresses #[inline] hints. A lint is issued if combined with #[inline(always)].
  • A few violations (false positives?) in the test runner

  • Known issues

    • Incremental compilation breaks sanitizers Incremental compilation breaks sanitizers #39611
  • Unresolved questions:

    • Should we call the attribute #[no_sanitize] or perhaps something like #[sanitize(never)] or some other variation? In particular, might we at some point want "positive options" like #[sanitize(miri(aggressive))]? There is much back and forth in Selectively disable sanitizer instrumentation #68164.
      What should the user experience be to enable sanitizers, particularly when using cargo? Should cargo have first-class support? Is that blocked on build-std stabilizing?

Activity

added
B-unstableBlocker: Implemented in the nightly compiler and unstable.
on Feb 9, 2017
kennytm

kennytm commented on Apr 27, 2017

@kennytm
Member

Just for record. Currently only 4 sanitizers are enabled (asan, lsan, msan, tsan), and only in x86_64-unknown-linux-gnu (#38699) and x86_64-apple-darwin (#41352).

As of the LLVM 4.0 merge (rust-lang/compiler-rt@c8a8767c5), compiler-rt actually supports much more targets than rustc do, and also some additional sanitizers (e.g. esan) can be enabled in the future.

Architecture x86 x86_64 ppc64 arm32 arm64 mips32 mips64 s390x
asan
dfsan
lsan
msan
tsan
ubsan
esan
cfi
profile
safestack
scudo
xray
Platform linux android darwin & ios windows-msvc freebsd
asan
dfsan
lsan
msan
tsan
ubsan
esan
cfi
profile
safestack
scudo
xray

(not all of these are sanitizers, some of them are just tools or libraries that depend on the common sanitizer runtime)

cuviper

cuviper commented on May 5, 2017

@cuviper
Member

Is there any plan for stabilization here? Even if it remains x86_64-only for now, with only a few of the available sanitizers, it will still be quite useful to have. I have users that want this (rhbz1447423), but now that -Z is forbidden I want to wait for properly-supported sanitizer options.

Firstyear

Firstyear commented on May 9, 2017

@Firstyear
Contributor

Hi,

If I understand this issue, you would like to block certain -Z features from coming to stable rust. Sanitisers seems to be one of these. We have a very good use case for them though. When you have a C + Rust with FFI, and the C code is linked to libasan, the rust component will fail to link as it's missing libasan. For us it's important to get sanitisers into rust stable as we have an extensive C code based (that is well sanitised), and having this option available to us will help to determine if our Rust + C integration is behaving correctly.

I hope this helps explain our use case, as for us this is a blocker to our project adopting Rust today.

Thanks you!

cuviper

cuviper commented on May 9, 2017

@cuviper
Member

FWIW, it's not just certain -Z features, but -Z as a whole being blocked as unstable now.

added
T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.
and removed on May 22, 2017
Firstyear

Firstyear commented on Jun 17, 2017

@Firstyear
Contributor

#42711 PR for dylib asan support.

added
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
on Jul 22, 2017

94 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-CLIArea: Command-line interface (CLI) to the compilerA-sanitizersArea: Sanitizers for correctness and code qualityB-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-needs-summaryStatus: It's hard to tell what's been done and what hasn't! Someone should do some investigation.T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @cuviper@alexcrichton@kennytm@pnkfelix@Firstyear

        Issue actions

          Tracking issue for sanitizer support · Issue #39699 · rust-lang/rust