[LSan] Fix a crash when LSan hits a guard page while scanning thread stack for pointers.
authorAlexey Samsonov <vonosmas@gmail.com>
Thu, 11 Feb 2016 18:07:17 +0000 (18:07 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Thu, 11 Feb 2016 18:07:17 +0000 (18:07 +0000)
commit027729c56688a0a5d8eab8ad81d46fc0304dd16a
tree7b5dabbd7d1ff3b7374e93d69af3c49397697093
parent37a09a8428f895161fe8e11001d319ca199582e1
[LSan] Fix a crash when LSan hits a guard page while scanning thread stack for pointers.

Summary:
In some cases stack pointer register (SP) doesn't point into the thread
stack: e.g. if one is using swapcontext(). In this case LSan
conservatively tries to scan the whole thread stack for pointers.
However, thread stack (at least in glibc implementation) may also
include guard pages, causing LSan to crash when it's reading from them.

One of the solutions is to use a pthread_attr_getguardsize() to adjust
the calculated stack boundaries. However, here we're just using
IsAccessibleMemoryRange to skip guard pages and make the code (slightly)
less platform-specific.

Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 260554
compiler-rt/lib/lsan/lsan_common.cc
compiler-rt/test/lsan/TestCases/guard-page.c [new file with mode: 0644]