summaryrefslogtreecommitdiff
path: root/lib/asan/asan_thread.h
AgeCommit message (Collapse)Author
2016-01-14[LSan] Use __tls_get_addr interceptor to keep track of dynamic TLS.Alexey Samsonov
Summary: We have a way to keep track of allocated DTLS segments: let's use it in LSan. Although this code is fragile and relies on glibc implementation details, in some cases it proves to be better than existing way of tracking DTLS in LSan: marking as "reachable" all memory chunks allocated directly by "ld". The plan is to eventually get rid of the latter, once we are sure it's safe to remove. Reviewers: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D16164 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@257785 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01[compiler-rt] Apply modernize-use-nullptr fixes in sanitizersVedant Kumar
- Trim spaces. - Use nullptr in place of 0 for pointer variables. - Use '!p' in place of 'p == 0' for null pointer checks. - Add blank lines to separate function definitions. - Add 'extern "C"' or 'namespace foo' comments after the appropriate closing brackets This is a continuation of work from 409b7b82. The focus here is on the various sanitizers (not sanitizer_common, as before). Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13225 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248966 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-29[asan] Fix SanitizerCommon.PthreadDestructorIterations test on Android L.Evgeniy Stepanov
On Android L, TSD destructors run 8 times instead of 4. Back to 4 times on the current master branch (as well as on K). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240992 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-11Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko
The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix \ -format git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234680 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05[ASan] Refactor thread starting code.Sergey Matveev
Move thread context creation into AsanThread::Create(). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@223483 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05[ASan, LSan] Improve tracking of thread creation.Sergey Matveev
In the current scheme of things, the call to ThreadStart() in the child thread is not synchronized with the parent thread. So, if a pointer is passed to pthread_create, there may be a window of time during which this pointer will not be discoverable by LSan. I.e. the pthread_create interceptor has already returneed and thus the pointer is no longer on the parent stack, but we don't yet know the location of the child stack. This has caused bogus leak reports (see http://llvm.org/bugs/show_bug.cgi?id=21621/). This patch makes the pthread_create interceptor wait until the child thread is properly registered before returning. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@223419 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-10[Sanitizers] Enable stack traces on FreeBSDViktor Kutuzov
Differential Revision: http://reviews.llvm.org/D6086 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221595 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01[ASan] Make stack-buffer-overflow reports more robustAlexey Samsonov
Summary: Fix the function that gets stack frame description by address in thread stack, so that it clearly indicates failures. Make this error non-fatal, and print as much information as we can in this case. Make all errors in ParseFrameDescription non-fatal. Test Plan: check-asan testsuite Reviewers: kcc Reviewed By: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5554 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@218819 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-04[ASan] Speed up stack trace unwinding for stacks of size 2.Alexey Samsonov
Summary: We don't need to do any work in this case - just take the current PC and caller PC. Reviewers: eugenis, ygribov Reviewed By: eugenis CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2936 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202845 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-11[asan] if verbosity>=2, print the fake stack usage stats at thread exit; No ↵Kostya Serebryany
functionality change in non-verboze mode git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197037 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27[ASan] Clarify that AsanThread objects are allocated only via mmap(). No ↵Alexey Samsonov
functionality change. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195840 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-18[asan] reduce the size of AsanThreadContext by storing the stack trace in ↵Kostya Serebryany
the stack depot git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192979 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-14[asan] Improve thread lifetime tracking on POSIX systems.Sergey Matveev
Call AsanThread::Destroy() from a late-running TSD destructor. Previously we called it before any user-registered TSD destructors, which caused false positives in LeakSanitizer. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192585 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-20[asan] nuke yet another async-signal-safety bug in UAR (oh, my)Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191080 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-19[asan] fix one more async-signal-safety issue with use-after-returnKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191004 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-18[asan] add a run-time option detect_stack_use_after_return, add verbosity ↵Kostya Serebryany
output for fake stack git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190932 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-13[asan] second attempt to use TLS with fake stack. This time it looks (more) ↵Kostya Serebryany
async-signal safe. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190663 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-12[asan] don't lazy-init fake_stack if we only need to check that fake_stack ↵Kostya Serebryany
exists (should fix 32-bit builds) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190593 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-12[asan] hopefully make the FakeStack async-signal safe, enable the related testKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190592 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-12[asan] Fix deadlock in stack unwinder on android/x86.Evgeniy Stepanov
Fixes PR17116. Patch by 林作健 (manjian2006 at gmail.com). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190590 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-12[asan] fully re-implement the FakeStack (use-after-return) to make it faster ↵Kostya Serebryany
and async-signal-safe. The implementation is not yet complete (see FIXMEs) but the existing tests pass. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190588 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-08[lsan] Handle fork() correctly.Sergey Matveev
Update the main thread's os_id on every pthread_create, and before initiating leak checking. This ensures that we have the correct os_id even if we have forked after Init(). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@185815 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-26[asan] initialize fake_stack lazily and increase its maximal size. This ↵Kostya Serebryany
makes -fsanitize=address,use-after-return more robust: all SPEC tests pass now. In the default mode thread stacks become a bit smaller. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@184934 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-21[asan] Move lsan_disabled out of thread context.Sergey Matveev
Fix for the case where disabler is used in pthread key destructor. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@184553 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-03[lsan] Add __lsan_disable() and __lsan_enable().Sergey Matveev
Objects allocated after a call to __lsan_disable() will be treated as live memory. Also add a ScopedDisabler. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@183099 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-29[asan] Make ASan report the correct thread address ranges to LSan.Sergey Matveev
This CL enables thread support in LSan when used on top of ASan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182854 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-11[asan] move fake stack into a separate .h file; actually disable a failing testKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@179273 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-22[asan] Change the way we report the alloca frame on stack-buff-overflow.Kostya Serebryany
Before: the function name was stored by the compiler as a constant string and the run-time was printing it. Now: the PC is stored instead and the run-time prints the full symbolized frame. This adds a couple of instructions into every function with non-empty stack frame, but also reduces the binary size because we store less strings (I saw 2% size reduction). This change bumps the asan ABI version to v3. compiler-rt part, llvm part will follow. Example of report (now): ==31711==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffa77cf1c5 at pc 0x41feb0 bp 0x7fffa77cefb0 sp 0x7fffa77cefa8 READ of size 1 at 0x7fffa77cf1c5 thread T0 #0 0x41feaf in Frame0(int, char*, char*, char*) stack-oob-frames.cc:20 #1 0x41f7ff in Frame1(int, char*, char*) stack-oob-frames.cc:24 #2 0x41f477 in Frame2(int, char*) stack-oob-frames.cc:28 #3 0x41f194 in Frame3(int) stack-oob-frames.cc:32 #4 0x41eee0 in main stack-oob-frames.cc:38 #5 0x7f0c5566f76c (/lib/x86_64-linux-gnu/libc.so.6+0x2176c) #6 0x41eb1c (/usr/local/google/kcc/llvm_cmake/a.out+0x41eb1c) Address 0x7fffa77cf1c5 is located in stack of thread T0 at offset 293 in frame #0 0x41f87f in Frame0(int, char*, char*, char*) stack-oob-frames.cc:12 <<<<<<<<<<<<<< this is new This frame has 6 object(s): [32, 36) 'frame.addr' [96, 104) 'a.addr' [160, 168) 'b.addr' [224, 232) 'c.addr' [288, 292) 's' [352, 360) 'd' git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177723 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-21[ASan] Switch ASan to generic ThreadRegistry from sanitizer_common. Delete ↵Alexey Samsonov
ASan-specific AsanThreadRegistry. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177634 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-20[ASan] Move GetCurrentThread/SetCurrentThread from AsanThreadRegistry class ↵Alexey Samsonov
into plain functions: they don't actually use registry git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177501 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-07[asan] intercept prctl(PR_SET_NAME) and set the thread name. Output the ↵Kostya Serebryany
thread names (if non-empty) in asan reports git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169601 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-05[ASan] Add print_full_thread_history runtime option (on by default) that ↵Alexey Samsonov
prints all full thread creation paths for threads involved in ASan error report git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163200 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-30Whitespace/lintAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162909 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-28[asan] even more refactoring to move StackTrace to sanitizer_commonKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162754 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-28[asan] some renaming before we move StackTrace into sanitizer_commonKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162747 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-28[asan] get rid of AsanPrintf in favor of Printf from sanitizer_commonKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162746 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-17[asan] get rid of the last operator new call in asan rtlKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@160347 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06[asan] make tid u32 instead of intKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158074 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06[Sanitizer]: Introduce a common internal printf function. For now, also use ↵Alexey Samsonov
tool-specific wrappers TsanPrintf (its output is controlled by TSan flags) and AsanPrintf (which copies its results to the ASan-private buffer). Supported formats: %[z]{d,u,x}, %s, %p. Re-write all format strings in TSan according to this format (this should have no effect on 64-bit platforms). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158065 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-31[asan] more renamingKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157746 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-22[asan] increase the stack size limit to 256M (yes, that happens); also CHECK ↵Kostya Serebryany
that the stack size is less than that on a non-main thread git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157249 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-24[ASan] Intercept CreateThread on WindowsTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@151366 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-07[asan] make sure the AsanThread object is destroyed if pthread_exit is calledKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@149940 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-17AddressSanitizer: create AsanThreadSummary together with AsanThread (in ↵Alexey Samsonov
parent thread) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@148286 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-06[asan] do not use new/delete for the internal thread structureKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@147674 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-16Recently the GCD tests started failing because of the invalid size ofKostya Serebryany
FakeStack on the worker threads. This patch moves the AsanThread initialization into a separate procedure that's called when AsanThread objects are called for worker threads. Patch by glider@google.com git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@146752 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-30AddressSanitizer run-time library. Not yet integrated with the compiler-rt ↵Kostya Serebryany
build system, but can be built using the old makefile. See details in README.txt git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@145463 91177308-0d34-0410-b5e6-96231b3b80d8