Crates.io | unsafe_ls |
lib.rs | unsafe_ls |
version | 0.1.0 |
source | src |
created_at | 2014-12-30 10:35:59.044527 |
updated_at | 2015-12-11 23:59:34.806356 |
description | A tool to list unsafe blocks and the unsafe actions within them, to enable easier auditing of regions that need extra-careful examination. |
homepage | https://github.com/huonw/unsafe_ls |
repository | https://github.com/huonw/unsafe_ls |
max_upload_size | |
id | 669 |
size | 30,961 |
List unsafe blocks and the unsafe actions within them, to enable
easier auditing of regions that need extra-careful examination. This
cannot catch memory-unsafe actions in safe code caused by bad unsafe
code, but correctly written/audited unsafe
blocks will not cause
such problems.
It can be used to only display blocks that have non-FFI unsafety in them, to avoid having to filter through lots of "routine" C calls.
Unfortunately #11792
means you may have to pass -L
pointing to the directory that
contains the core crates (std
, etc.) or edit the DEFAULT_LIB_DIR
static to avoiding the repetition.
See unsafe_ls -h
for all flags.
unsafe
except for FFI$ ./unsafe_ls -n test.rs
test.rs:3:1: fn with 1 static mut
x += 1
test.rs:7:5: block with 1 deref, 1 static mut
*std::ptr::null::<int>();
x += 1;
test.rs:11:5: block with 1 unsafe call
foo()
$ ./unsafe_ls -f test.rs
test.rs:11:5: block with 1 ffi, 1 unsafe call
abort()
test.rs:17:5: block with 1 ffi
abort()
unsafe
$ ./unsafe_ls -nf test.rs
test.rs:3:1: fn with 1 static mut
x += 1
test.rs:7:5: block with 1 deref, 1 static mut
*std::ptr::null::<int>();
x += 1;
test.rs:11:5: block with 1 ffi, 1 unsafe call
foo();
abort()
test.rs:17:5: block with 1 ffi
abort()
cargo build --release
Known to work with Rust master at aa0e35bc6 2014-07-22.
I used it to submit
#12445, reducing the
number of transmute
s (since those are wildly unsafe) among other
small changes.