Bug 1447423 - Enable Rust sanitizers
Summary: Enable Rust sanitizers
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: rust
Version: rawhide
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Rust SIG
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-02 17:12 UTC by Josh Stone
Modified: 2022-08-29 20:43 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-08-29 20:43:05 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github rust-lang rust issues 39699 0 None open Tracking issue for sanitizer support 2021-01-14 23:38:57 UTC

Description Josh Stone 2017-05-02 17:12:16 UTC
Rust on x86_64-unknown-linux-gnu has some preliminary support for sanitizers, per this tracking issue: https://github.com/rust-lang/rust/issues/39699

- asan = AddressSanitizer
- lsan = LeakSanitizer
- msan = MemorySanitizer
- tsan = ThreadSanitizer

They need to be turned on with "./configure --enable-sanitizers".  This uses LLVM's cmake, which means we'll also need a BuildReq on cmake and llvm-static.  And the latter means I'll only want to do this with LLVM 3.9+ where we can force it to still link dynamically to libLLVM.so. (So not on F24.)

I thought at first that we'd want to isolate these in a subpackage, because the upstream librustc_?san*.rlib binaries are about 60MB, but once you strip debuginfo they're only 8MB.  That's manageable, but still a relatively large addition to the current 31MB rust-std-static.  Given the niche use, it may still make sense to package them separately.

Comment 1 Josh Stone 2017-05-05 04:03:53 UTC
Currently, you have to use an unstable -Z option, like -Zsanitizer=asan.  This warns that such options are only meant for the nightly compiler, currently accepted for compatibility but will "soon" change.  It's been a long time coming, but this was finally blocked on all but nightly:
https://github.com/rust-lang/rust/pull/41751

I think we should wait for sanitizers to stabilize before packaging them.

Comment 2 wibrown@redhat.com 2017-05-05 05:32:03 UTC
do you have an estimate as to what kind of time frame that would be before they stabilise? Thanks for your work on this mate :)

Comment 3 Josh Stone 2017-05-05 16:58:40 UTC
There's no indication that they're considering stabilization anytime soon. :/
I'll ask on the GH issue though.

FWIW, my local test at enabling this did appear to build just fine, though I didn't try using it.  But I'd hate to start shipping something that will become inaccessible once 1.19 ships with disabled -Z.

In the meantime, can you incorporate rust-nightly into your workflow?  It's pretty easy using rustup, and you can still prefer the system compiler like:

$ rustup toolchain link system /usr
$ rustup default system

Then you can use "rustup override" to target nightly for a particular directory, or switch toolchains in ad hoc commands like "cargo +nightly build".

Comment 4 Jan Kurik 2017-08-15 07:01:34 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.

Comment 5 Josh Stone 2022-08-29 20:43:05 UTC
I'm deferring this to the upstream issue. If/when the feature stabilizes, we can ship it in the distro too.


Note You need to log in before you can comment on or make changes to this bug.