This is an archive of the discontinued LLVM Phabricator instance.

[asan] Turn -fsanitize-address-use-after-scope on by default
ClosedPublic

Authored by kubamracek on Mar 29 2017, 3:07 PM.

Details

Summary

AddressSanitizer has an optional compile-time flag, -fsanitize-address-use-after-scope, which enables detection of use-after-scope bugs. We'd like to have this feature on by default, because it is already very well tested, it's used in several projects already (LLVM automatically enables it when using -DLLVM_USE_SANITIZER=Address), it's low overhead and there are no known issues or incompatibilities.

This patch enables use-after-scope by default via the Clang driver, where we set true as the default value for AsanUseAfterScope. This also causes the lifetime markers to be generated whenever fsanitize=address is used. This has some nice consequences, e.g. we now have line numbers for all local variables. Several testcases needed to be updated to address this change. The ParseFrameDescription function needed to be updated to properly parse "varname:line".

Diff Detail

Repository
rL LLVM

Event Timeline

kubamracek created this revision.Mar 29 2017, 3:07 PM
vitalybuka edited edge metadata.Mar 29 2017, 3:24 PM

LGTM, but could you split this patch into two?

  1. ParseFrameDescription change
  2. AsanUseAfterScope = true
kubamracek updated this revision to Diff 93425.Mar 29 2017, 4:41 PM

I extracted the StackVarDescr change into https://reviews.llvm.org/D31484. This patch now simply just enables -fsanitize-address-use-after-scope by default.

vitalybuka accepted this revision.Mar 29 2017, 4:43 PM

Thank you! LGTM

This revision is now accepted and ready to land.Mar 29 2017, 4:43 PM
This revision was automatically updated to reflect the committed changes.