summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/asan_thread.h
Commit message (Collapse)AuthorAgeFilesLines
* compiler-rt: Rename .cc file in lib/asan to .cppNico Weber2019-08-011-1/+1
| | | | | | Like r367463, but for asan. llvm-svn: 367558
* [NFC] Move ScopedUnwinding from .h to .ccVitaly Buka2019-03-051-12/+0
| | | | llvm-svn: 355377
* [hwasan, asan] Intercept vfork.Evgeniy Stepanov2019-02-271-0/+3
| | | | | | | | | | | | | | | Summary: Intercept vfork on arm, aarch64, i386 and x86_64. Reviewers: pcc, vitalybuka Subscribers: kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58533 llvm-svn: 355030
* Revert "[asan] Fix vfork handling.", +1Evgeniy Stepanov2019-02-211-3/+0
| | | | | | Revert r354625, r354627 - multiple build failures. llvm-svn: 354629
* [hwasan,asan] Intercept vfork.Evgeniy Stepanov2019-02-211-0/+3
| | | | | | | | | | | | | | Summary: AArch64 only for now. Reviewers: vitalybuka, pcc Subscribers: srhines, kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, jdoerfert, #sanitizers, llvm-commits, kcc Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58313 llvm-svn: 354625
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [asan] Restore check removed by r332033Walter Lee2018-05-161-0/+2
| | | | | | | | Needed by fiber handling code, and possibly other code paths. Differential Revision: https://reviews.llvm.org/D46981 llvm-svn: 332553
* [asan] Initialize fake stack during thread initWalter Lee2018-05-101-2/+0
| | | | | | | | | | | If detect-stack-use-after-return is on, initialize fake stack during AsanThread::Init(), rather than lazily. This is required on Myriad. From kcc: "There used to be a reason why this was done lazily, but I don't remember if we still have that reason." Tested on x86. Differential Revision: https://reviews.llvm.org/D46626 llvm-svn: 332033
* [ASan] Enhance libsanitizer support for invalid-pointer-pair.Alex Shlyapnikov2017-12-041-0/+3
| | | | | | | | | | | | | | | | | | | | Following patch adds support of all memory origins in CheckForInvalidPointerPair function. For small difference of pointers, it's directly done in shadow memory (the limit was set to 2048B). Then we search for origin of first pointer and verify that the second one has the same origin. If so, we verify that it points either to a same variable (in case of stack memory or a global variable), or to a same heap segment. Committing on behanf of marxin and jakubjelinek. Reviewers: alekseyshl, kcc Subscribers: llvm-commits Differential revision: https://reviews.llvm.org/D40600 llvm-svn: 319668
* [asan] Remove ScopedDeadlySignalVitaly Buka2017-09-181-19/+0
| | | | | | | This is used only to make fast = true in GetStackTraceWithPcBpAndContext on SANITIZER_FREEBSD and SANITIZER_NETBSD and can be done explicitly. llvm-svn: 313517
* [asan] Refactor thread creation bookkeepingVitaly Buka2017-08-091-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This is a pure refactoring change. It paves the way for OS-specific implementations, such as Fuchsia's, that can do most of the per-thread bookkeeping work in the creator thread before the new thread actually starts. This model is simpler and cleaner, avoiding some race issues that the interceptor code for thread creation has to do for the existing OS-specific implementations. Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl, kcc Reviewed By: alekseyshl Subscribers: phosek, filcab, llvm-commits, kubamracek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36385 llvm-svn: 310432
* [sanitizer] Introduce tid_t as a typedef for OS-provided thread IDsKuba Mracek2017-04-171-1/+1
| | | | | | | | We seem to assume that OS-provided thread IDs are either uptr or int, neither of which is true on Darwin. This introduces a tid_t type, which holds a OS-provided thread ID (gettid on Linux, pthread_threadid_np on Darwin, pthread_self on FreeBSD). Differential Revision: https://reviews.llvm.org/D31774 llvm-svn: 300473
* [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiberDmitry Vyukov2016-09-281-1/+2
| | | | | | | | | | | This patch extends __sanitizer_finish_switch_fiber method to optionally return previous stack base and size. This solves the problem of coroutines/fibers library not knowing the original stack context from which the library is used. It's incorrect to assume that such context is always the default stack of current thread (e.g. one such library may be used from a fiber/coroutine created by another library). Bulding a separate stack tracking mechanism would not only duplicate AsanThread, but also require each coroutines/fibers library to integrate with it. Author: Andrii Grynenko (andriigrynenko) Reviewed in: https://reviews.llvm.org/D24628 llvm-svn: 282582
* [asan] add primitives that allow coroutine implementationsDmitry Vyukov2016-06-211-10/+24
| | | | | | | | | | | | | | | | | This patch adds the __sanitizer_start_switch_fiber and __sanitizer_finish_switch_fiber methods inspired from what can be found here https://github.com/facebook/folly/commit/2ea64dd24946cbc9f3f4ac3f6c6b98a486c56e73 . These methods are needed when the compiled software needs to implement coroutines, fibers or the like. Without a way to annotate them, when the program jumps to a stack that is not the thread stack, __asan_handle_no_return shows a warning about that, and the fake stack mechanism may free fake frames that are still in use. Author: blastrock (Philippe Daouadi) Reviewed in http://reviews.llvm.org/D20913 llvm-svn: 273260
* [LSan] Use __tls_get_addr interceptor to keep track of dynamic TLS.Alexey Samsonov2016-01-141-0/+6
| | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 257785
* [compiler-rt] Apply modernize-use-nullptr fixes in sanitizersVedant Kumar2015-10-011-6/+7
| | | | | | | | | | | | | | | | | | - 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 llvm-svn: 248966
* [asan] Fix SanitizerCommon.PthreadDestructorIterations test on Android L.Evgeniy Stepanov2015-06-291-6/+3
| | | | | | | 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). llvm-svn: 240992
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-111-2/+2
| | | | | | | | | | | | 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 llvm-svn: 234680
* [ASan] Refactor thread starting code.Sergey Matveev2014-12-051-6/+2
| | | | | | Move thread context creation into AsanThread::Create(). llvm-svn: 223483
* [ASan, LSan] Improve tracking of thread creation.Sergey Matveev2014-12-051-1/+2
| | | | | | | | | | | | | | | 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. llvm-svn: 223419
* [Sanitizers] Enable stack traces on FreeBSDViktor Kutuzov2014-11-101-0/+19
| | | | | | Differential Revision: http://reviews.llvm.org/D6086 llvm-svn: 221595
* [ASan] Make stack-buffer-overflow reports more robustAlexey Samsonov2014-10-011-1/+6
| | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 218819
* [ASan] Speed up stack trace unwinding for stacks of size 2.Alexey Samsonov2014-03-041-1/+0
| | | | | | | | | | | | | | | | 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 llvm-svn: 202845
* [asan] if verbosity>=2, print the fake stack usage stats at thread exit; No ↵Kostya Serebryany2013-12-111-2/+2
| | | | | | functionality change in non-verboze mode llvm-svn: 197037
* [ASan] Clarify that AsanThread objects are allocated only via mmap(). No ↵Alexey Samsonov2013-11-271-7/+8
| | | | | | functionality change. llvm-svn: 195840
* [asan] reduce the size of AsanThreadContext by storing the stack trace in ↵Kostya Serebryany2013-10-181-4/+4
| | | | | | the stack depot llvm-svn: 192979
* [asan] Improve thread lifetime tracking on POSIX systems.Sergey Matveev2013-10-141-0/+3
| | | | | | | | 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. llvm-svn: 192585
* [asan] nuke yet another async-signal-safety bug in UAR (oh, my)Kostya Serebryany2013-09-201-1/+0
| | | | llvm-svn: 191080
* [asan] fix one more async-signal-safety issue with use-after-returnKostya Serebryany2013-09-191-1/+4
| | | | llvm-svn: 191004
* [asan] add a run-time option detect_stack_use_after_return, add verbosity ↵Kostya Serebryany2013-09-181-0/+2
| | | | | | output for fake stack llvm-svn: 190932
* [asan] second attempt to use TLS with fake stack. This time it looks (more) ↵Kostya Serebryany2013-09-131-1/+4
| | | | | | async-signal safe. llvm-svn: 190663
* [asan] don't lazy-init fake_stack if we only need to check that fake_stack ↵Kostya Serebryany2013-09-121-1/+5
| | | | | | exists (should fix 32-bit builds) llvm-svn: 190593
* [asan] hopefully make the FakeStack async-signal safe, enable the related testKostya Serebryany2013-09-121-2/+4
| | | | llvm-svn: 190592
* [asan] Fix deadlock in stack unwinder on android/x86.Evgeniy Stepanov2013-09-121-1/+20
| | | | | | | Fixes PR17116. Patch by 林作健 (manjian2006 at gmail.com). llvm-svn: 190590
* [asan] fully re-implement the FakeStack (use-after-return) to make it faster ↵Kostya Serebryany2013-09-121-8/+8
| | | | | | and async-signal-safe. The implementation is not yet complete (see FIXMEs) but the existing tests pass. llvm-svn: 190588
* [lsan] Handle fork() correctly.Sergey Matveev2013-07-081-0/+2
| | | | | | | | 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(). llvm-svn: 185815
* [asan] initialize fake_stack lazily and increase its maximal size. This ↵Kostya Serebryany2013-06-261-2/+13
| | | | | | makes -fsanitize=address,use-after-return more robust: all SPEC tests pass now. In the default mode thread stacks become a bit smaller. llvm-svn: 184934
* [asan] Move lsan_disabled out of thread context.Sergey Matveev2013-06-211-10/+0
| | | | | | Fix for the case where disabler is used in pthread key destructor. llvm-svn: 184553
* [lsan] Add __lsan_disable() and __lsan_enable().Sergey Matveev2013-06-031-0/+10
| | | | | | | Objects allocated after a call to __lsan_disable() will be treated as live memory. Also add a ScopedDisabler. llvm-svn: 183099
* [asan] Make ASan report the correct thread address ranges to LSan.Sergey Matveev2013-05-291-2/+6
| | | | | | This CL enables thread support in LSan when used on top of ASan. llvm-svn: 182854
* [asan] move fake stack into a separate .h file; actually disable a failing testKostya Serebryany2013-04-111-0/+1
| | | | llvm-svn: 179273
* [asan] Change the way we report the alloca frame on stack-buff-overflow.Kostya Serebryany2013-03-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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' llvm-svn: 177723
* [ASan] Switch ASan to generic ThreadRegistry from sanitizer_common. Delete ↵Alexey Samsonov2013-03-211-41/+35
| | | | | | ASan-specific AsanThreadRegistry. llvm-svn: 177634
* [ASan] Move GetCurrentThread/SetCurrentThread from AsanThreadRegistry class ↵Alexey Samsonov2013-03-201-0/+5
| | | | | | into plain functions: they don't actually use registry llvm-svn: 177501
* [asan] intercept prctl(PR_SET_NAME) and set the thread name. Output the ↵Kostya Serebryany2012-12-071-0/+9
| | | | | | thread names (if non-empty) in asan reports llvm-svn: 169601
* [ASan] Add print_full_thread_history runtime option (on by default) that ↵Alexey Samsonov2012-09-051-8/+4
| | | | | | prints all full thread creation paths for threads involved in ASan error report llvm-svn: 163200
* Whitespace/lintAlexey Samsonov2012-08-301-1/+0
| | | | llvm-svn: 162909
* [asan] even more refactoring to move StackTrace to sanitizer_commonKostya Serebryany2012-08-281-1/+1
| | | | llvm-svn: 162754
* [asan] some renaming before we move StackTrace into sanitizer_commonKostya Serebryany2012-08-281-3/+3
| | | | llvm-svn: 162747
* [asan] get rid of AsanPrintf in favor of Printf from sanitizer_commonKostya Serebryany2012-08-281-1/+1
| | | | llvm-svn: 162746
OpenPOWER on IntegriCloud