Skip to content

Commit ece2a2b

Browse files
committed
do not asan-instrument catch parameters on windows
1 parent ce5a115 commit ece2a2b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,16 @@ void AddressSanitizer::instrumentMemIntrinsic(MemIntrinsic *MI,
13971397
MI->eraseFromParent();
13981398
}
13991399

1400+
// Check if an alloca is a catch block parameter
1401+
static bool isCatchParameter(const AllocaInst &AI) {
1402+
for (const Use &U : AI.uses()) {
1403+
if (isa<CatchPadInst>(U.getUser())) {
1404+
return true;
1405+
}
1406+
}
1407+
return false;
1408+
}
1409+
14001410
/// Check if we want (and can) handle this alloca.
14011411
bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) {
14021412
auto [It, Inserted] = ProcessedAllocas.try_emplace(&AI);
@@ -1417,7 +1427,11 @@ bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) {
14171427
// swifterror allocas are register promoted by ISel
14181428
!AI.isSwiftError() &&
14191429
// safe allocas are not interesting
1420-
!(SSGI && SSGI->isSafe(AI)));
1430+
!(SSGI && SSGI->isSafe(AI)) &&
1431+
// Mitigation for https://github.com/google/sanitizers/issues/749
1432+
// We don't instrument Windows catch-block parameters to avoid
1433+
// interfering with exception handling assumptions.
1434+
!(TargetTriple.isOSWindows() && isCatchParameter(AI)));
14211435

14221436
It->second = IsInteresting;
14231437
return IsInteresting;

0 commit comments

Comments
 (0)