This is an archive of the discontinued LLVM Phabricator instance.

[LSan] Fix a crash when LSan hits a guard page while scanning thread stack for pointers.
ClosedPublic

Authored by samsonov on Feb 10 2016, 5:00 PM.

Details

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.

Diff Detail

Repository
rL LLVM

Event Timeline

samsonov updated this revision to Diff 47567.Feb 10 2016, 5:00 PM
samsonov retitled this revision from to [LSan] Fix a crash when LSan hits a guard page while scanning thread stack for pointers..
samsonov updated this object.
samsonov added a reviewer: kcc.
samsonov added a subscriber: llvm-commits.
kcc accepted this revision.Feb 10 2016, 5:02 PM
kcc edited edge metadata.

LGTM++

This revision is now accepted and ready to land.Feb 10 2016, 5:02 PM
This revision was automatically updated to reflect the committed changes.