-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expand osx sanitizer support (lsan, dylib, cdylib, staticlib) #62681
Changes from all commits
0c285fb
b89e852
f33875d
e85a37e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# needs-sanitizer-support | ||
# only-x86_64 | ||
-include ../tools.mk | ||
|
||
ifeq ($(TARGET),x86_64-apple-darwin) | ||
# sanitizers are always built as dylibs on osx | ||
EXTRACFLAGS=-L$(TARGET_RPATH_DIR) -l__rustc__clang_rt.asan_osx_dynamic | ||
LD_LIBRARY_PATH="$(TARGET_RPATH_DIR):$(TMPDIR)" | ||
else | ||
LD_LIBRARY_PATH=$(TMPDIR) | ||
endif | ||
|
||
# This test builds a staticlib, then an executable that links to it. | ||
# The staticlib is compiled with address sanitizer, and we assert that a fault | ||
# in the staticlib is correctly detected. | ||
|
||
all: | ||
$(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs | ||
$(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS) | ||
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[no_mangle] | ||
pub extern fn overflow() { | ||
let xs = [0, 1, 2, 3]; | ||
let _y = unsafe { *xs.as_ptr().offset(4) }; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,9 @@ | |
-include ../tools.mk | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not expect this test to pass. Is it run for PRs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None of the tests tagged with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should pass now - if it were run. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @rust-lang/infra is there anything that should/could be done here to get these tests running? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can edit |
||
|
||
# NOTE the address sanitizer only supports x86_64 linux and macOS | ||
|
||
ifeq ($(TARGET),x86_64-apple-darwin) | ||
EXTRA_RUSTFLAG=-C rpath | ||
else | ||
ifeq ($(TARGET),x86_64-unknown-linux-gnu) | ||
EXTRA_RUSTFLAG= | ||
endif | ||
endif | ||
|
||
all: | ||
$(RUSTC) -Z sanitizer=address --crate-type proc-macro --target $(TARGET) hello.rs 2>&1 | $(CGREP) '-Z sanitizer' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this is necessary. It would only really affect linux targets which I don't have access to for testing. My thinking was changing the sanitizer crate depkind to
Implicit
requires addingactivate_injected_dep
in suitable places.