This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Add memset, memmove, and memcpy to the common interceptors
ClosedPublic

Authored by bruening on Mar 24 2016, 3:43 PM.

Details

Summary

Currently, sanitizer_common_interceptors.inc has an implicit, undocumented
assumption that the sanitizer including it has previously declared
interceptors for memset and memmove. Since the memset, memmove, and memcpy
routines require interception by many sanitizers, we add them to the
set of common interceptions, both to address the undocumented assumption
and to speed future tool development. They are intercepted under a new
flag intercept_intrin.

The tsan interceptors are removed in favor of the new common versions. The
asan and msan interceptors for these are more complex (they incur extra
interception steps and their function bodies are exposed to the compiler)
so they opt out of the common versions and keep their own.

Diff Detail

Repository
rL LLVM

Event Timeline

bruening updated this revision to Diff 51613.Mar 24 2016, 3:43 PM
bruening retitled this revision from to [sanitizer] Add memset, memmove, and memcpy to the common interceptors.
bruening updated this object.
bruening added a reviewer: vitalybuka.
bruening added subscribers: kcc, llvm-commits, zhaoqin.

LGTM, but Evgeniy needs take a look as well.

eugenis added inline comments.Mar 24 2016, 5:06 PM
lib/tsan/rtl/tsan_interceptors.cc
673 ↗(On Diff #51613)

Looks like you've lost COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED check in the common interceptor.

bruening updated this revision to Diff 51625.Mar 24 2016, 6:20 PM
bruening edited edge metadata.

Add missing is-initialized checks

bruening marked an inline comment as done.Mar 24 2016, 6:20 PM
bruening added inline comments.
lib/tsan/rtl/tsan_interceptors.cc
673 ↗(On Diff #51613)

Good catch. The asan and msan COMMON_INTERCEPTOR_ENTER do their own is-initialized checks in general (though calling REAL instead of internal_) and samsonov was in favor of relying on those for earlier common interceptors. The tsan _ENTER does not do any check. IMHO these explicit is-init checks should remain here, as the REAL will not work prior to init, rather than just adding a REAL call if !init to tsan's _ENTER.

eugenis accepted this revision.Mar 25 2016, 11:20 AM
eugenis edited edge metadata.

LGTM

Do you want me to land this change for you?

This revision is now accepted and ready to land.Mar 25 2016, 11:20 AM
bruening marked an inline comment as done.Mar 25 2016, 11:30 AM

Do you want me to land this change for you?

That won't be necessary as I am now a committer. Thank you for the review!

This revision was automatically updated to reflect the committed changes.