This is an archive of the discontinued LLVM Phabricator instance.

Unpoison stack before resume instruction
ClosedPublic

Authored by vitalybuka on Jul 21 2016, 7:47 PM.

Details

Summary

Clang inserts cleanup code before resume similar way as before return instruction.
This makes asan poison local variables causing false use-after-scope reports.

__asan_handle_no_return does not help here as it was executed before
llvm.lifetime.end inserted into resume block.

To avoid false report we need to unpoison stack for resume same way as for return.

cleanupret similar to resume but it's used only on windows.

PR27453

Diff Detail

Repository
rL LLVM

Event Timeline

vitalybuka updated this revision to Diff 65015.Jul 21 2016, 7:47 PM
vitalybuka retitled this revision from to Unpoison stack before resume instruction.
vitalybuka updated this object.
vitalybuka added reviewers: kcc, eugenis.
eugenis edited edge metadata.Jul 22 2016, 1:21 PM

I'm not exactly up-to-date on the exception handling IR. I see instructions like "catchret" and "cleanupret" in the LangRef document. Do we need to handle them as well?

eugenis added inline comments.Jul 22 2016, 1:38 PM
lib/Transforms/Instrumentation/AddressSanitizer.cpp
1796 ↗(On Diff #65127)

Why do you rename this?
I kind of like the current name more.

test/Instrumentation/AddressSanitizer/lifetime-throw.ll
23 ↗(On Diff #65127)

"#3" it is not defined anywhere.
How does this work?

vitalybuka updated this revision to Diff 65163.Jul 22 2016, 2:44 PM
vitalybuka marked an inline comment as done.
vitalybuka edited edge metadata.

Handle cleanupret

vitalybuka updated this object.Jul 22 2016, 2:45 PM
vitalybuka added inline comments.
test/Instrumentation/AddressSanitizer/lifetime-throw.ll
23 ↗(On Diff #65127)

It just ignores undefined attributes, I see the same in other tests.

eugenis accepted this revision.Jul 22 2016, 2:52 PM
eugenis edited edge metadata.

LGTM
I'm a bit unhappy about the tests effectively counting the number of __asan_poison_stack_memory calls, and not verifying their placement. This is probably good enough, but a few extra checks would not hurt.

test/Instrumentation/AddressSanitizer/lifetime-throw-win.ll
1 ↗(On Diff #65163)

typo: handling here and below

This revision is now accepted and ready to land.Jul 22 2016, 2:52 PM
vitalybuka updated this revision to Diff 65171.Jul 22 2016, 3:07 PM
vitalybuka edited edge metadata.

Make Evgeniy a bit happier

This revision was automatically updated to reflect the committed changes.