llvm-project/compiler-rt/lib
Filipe Cabecinhas 04d61050ea [asan] Assert in __sanitizer_ptr_{sub,cmp} if one of the pointers was freed.
Summary:
This (partially) implements the check mentioned at
http://kristerw.blogspot.co.uk/2016/04/dangling-pointers-and-undefined-behavior.html
(via John Regehr)

Quoting:
"That the behavior is undefined follows from C11 6.2.4 "Storage
durations of objects"
  The lifetime of an object is the portion of program execution during
  which storage is guaranteed to be reserved for it. An object exists, has
  a constant address, and retains its last-stored value throughout its
  lifetime. If an object is referred to outside of its lifetime, the
  behavior is undefined. The value of a pointer becomes indeterminate when
  the object it points to (or just past) reaches the end of its lifetime.
and 7.22.3 "Memory management functions" that says that free ends the
lifetime of objects
  The lifetime of an allocated object extends from the allocation until
  the deallocation.
"

We can probably implement this for stack variables too, but I think this
is a good start to see if there's interest in this check.
We can also hide this behind a flag, too.

Reviewers: samsonov, kcc, rsmith, regehr

Subscribers: kubabrecka, llvm-commits

Differential Revision: http://reviews.llvm.org/D19691

llvm-svn: 268097
2016-04-29 20:37:34 +00:00
..
BlocksRuntime Move tests for BlocksRuntime and builtins to corresponding directories under test/ 2014-02-14 09:47:31 +00:00
asan [asan] Assert in __sanitizer_ptr_{sub,cmp} if one of the pointers was freed. 2016-04-29 20:37:34 +00:00
builtins builtins: fix -Werror,-Wunused-variable warning 2016-04-20 17:43:43 +00:00
cfi [sancov] common flags initialization. 2016-03-18 19:28:07 +00:00
dfsan [sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143. 2016-04-27 17:42:00 +00:00
esan [sanitizers] Get the proper symbol version when long double transition is involved. 2016-04-27 21:24:21 +00:00
interception [asan] Intercept all Heap* related imports from ucrtbase.dll 2016-03-24 20:19:48 +00:00
lsan [sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143. 2016-04-27 17:42:00 +00:00
msan [msan] Tests for vector compare intrinsics. 2016-04-29 01:20:05 +00:00
profile sync up with master copy 2016-04-06 22:30:14 +00:00
safestack [compiler-rt] [safestack] Enable for aarch64 2015-12-11 17:38:38 +00:00
sanitizer_common [sanitizers] [SystemZ] Mark kernel 3.12.58+ as safe from CVE-2016-2143. 2016-04-29 14:59:19 +00:00
stats [Sanitizer] Introduce ListOfModules object and use it to replace GetListOfModules(). 2016-02-22 18:52:51 +00:00
tsan [tsan] Fix Darwin GCD support after separation of Processor and ThreadState 2016-04-28 09:26:30 +00:00
ubsan [sanitizer] [SystemZ] Enable UBSan. 2016-04-15 22:25:04 +00:00
CMakeLists.txt [esan] EfficiencySanitizer base runtime library 2016-04-21 21:32:25 +00:00
Makefile.mk Remove autoconf support for building runtime libraries. 2016-01-26 21:31:12 +00:00