-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Disable "UseOdrIndicator" ASan instrumentation mode by default. #35074
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
Changes from all commits
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 |
---|---|---|
|
@@ -134,9 +134,11 @@ static void addAddressSanitizerPasses(const PassManagerBuilder &Builder, | |
auto recover = | ||
bool(BuilderWrapper.IRGOpts.SanitizersWithRecoveryInstrumentation & | ||
SanitizerKind::Address); | ||
auto useODRIndicator = BuilderWrapper.IRGOpts.SanitizeAddressUseODRIndicator; | ||
PM.add(createAddressSanitizerFunctionPass(/*CompileKernel=*/false, recover)); | ||
PM.add(createModuleAddressSanitizerLegacyPassPass(/*CompileKernel=*/false, | ||
recover)); | ||
PM.add(createModuleAddressSanitizerLegacyPassPass( | ||
/*CompileKernel=*/false, recover, /*UseGlobalsGC=*/true, | ||
useODRIndicator)); | ||
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. Just note to myself: here is the place we are switching the default. We are now using an explicit value determined by the driver instead of the default specified in the header (which is true). |
||
} | ||
|
||
static void addThreadSanitizerPass(const PassManagerBuilder &Builder, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,6 +258,22 @@ OptionSet<SanitizerKind> swift::parseSanitizerRecoverArgValues( | |
return sanitizerRecoverSet; | ||
} | ||
|
||
// Note this implementation cannot be inlined at its use site because it calls | ||
// `toStringRef(const SanitizerKind).` | ||
bool swift::parseSanitizerAddressUseODRIndicator( | ||
danliew-apple marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const llvm::opt::Arg *A, const OptionSet<SanitizerKind> &enabledSanitizers, | ||
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. Given that we don't expect this to be 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 is a valid criticism but the use of I'd prefer to keep the APIs as uniform as possible. Note I'm aware there are some oddities already in this file (inconsistent argument order) but we shouldn't add to them if we don't have to. 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 don't think its adding any inconsistency. The LLVM style actually encourages this - pass by reference unless you need to be able to pass in 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 wasn't talking about inconsistency with respect to LLVM's recommended style. I'm talking about inconsistency with respect to the APIs that already exist in I suspect the reason these APIs take a |
||
DiagnosticEngine &Diags) { | ||
// Warn if ASan isn't enabled. | ||
if (!(enabledSanitizers & SanitizerKind::Address)) { | ||
Diags.diagnose( | ||
SourceLoc(), diag::warning_option_requires_specific_sanitizer, | ||
A->getOption().getPrefixedName(), toStringRef(SanitizerKind::Address)); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
std::string swift::getSanitizerList(const OptionSet<SanitizerKind> &Set) { | ||
std::string list; | ||
#define SANITIZER(_, kind, name, file) \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// REQUIRES: asan_runtime | ||
// RUN: %swiftc_driver -driver-print-jobs -sanitize=address -sanitize-address-use-odr-indicator %s 2>&1 | %FileCheck %s | ||
|
||
// CHECK: swift | ||
// CHECK-DAG: -sanitize=address | ||
// CHECK-DAG: -sanitize-address-use-odr-indicator | ||
|
||
// Missing `-sanitize=address` causes warning to be emitted | ||
// RUN: %swiftc_driver -sanitize-address-use-odr-indicator \ | ||
// RUN: %s -o %t 2>&1 | %FileCheck -check-prefix=CHECK-MISSING-ARG %s | ||
// CHECK-MISSING-ARG: warning: option '-sanitize-address-use-odr-indicator' has no effect when 'address' sanitizer is disabled. Use -sanitize=address to enable the sanitizer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// REQUIRES: asan_runtime | ||
|
||
// Default instrumentation that does not use ODR indicators | ||
// and private aliases. | ||
// RUN: %target-swift-frontend -emit-ir -sanitize=address %s | %FileCheck %s | ||
// CHECK: @"[[MANGLED_GLOBAL:.+aGlobal.+]]" = | ||
// CHECK-NOT: __odr_asan_gen_[[MANGLED_GLOBAL]] | ||
// CHECK-NOT: @{{.+}} = private alias {{.*}}@"[[MANGLED_GLOBAL]]" | ||
|
||
// Instrumentation with ODR indicators (implies private aliases) | ||
// RUN: %target-swift-frontend -emit-ir -sanitize=address \ | ||
// RUN: -sanitize-address-use-odr-indicator %s | \ | ||
// RUN: %FileCheck -check-prefix=CHECK-ODR %s | ||
// CHECK-ODR: @"[[MANGLED_GLOBAL:.+aGlobal.+]]" = | ||
// CHECK-ODR: __odr_asan_gen_[[MANGLED_GLOBAL]] | ||
// CHECK-ODR: @{{.+}} = private alias {{.*}}@"[[MANGLED_GLOBAL]]" | ||
|
||
let aGlobal:Int = 128; |
Uh oh!
There was an error while loading. Please reload this page.