summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/asan_thread.cc
Commit message (Collapse)AuthorAgeFilesLines
* compiler-rt: Rename .cc file in lib/asan to .cppNico Weber2019-08-011-535/+0
| | | | | | Like r367463, but for asan. llvm-svn: 367558
* sanitizers: Introduce ThreadType enumDmitry Vyukov2019-02-071-2/+1
| | | | | | | | | | | | | Replace bool workerthread flag with ThreadType enum. This change is preparation for fiber support. [dvyukov: fixed build of sanitizer_thread_registry_test.cc] Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D57839 Context: https://reviews.llvm.org/D54889 llvm-svn: 353390
* 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] Support running without /procEvgeniy Stepanov2019-01-081-6/+14
| | | | | | | | | | | | | | | | | | Summary: This patch lets ASan run when /proc is not accessible (ex. not mounted yet). It includes a special test-only flag that emulates this condition in an unpriviledged process. This only matters on Linux, where /proc is necessary to enumerate virtual memory mappings. Reviewers: vitalybuka, pcc, krytarowski Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D56141 llvm-svn: 350590
* Revert "[asan] Support running without /proc.", +1Evgeniy Stepanov2018-12-281-35/+14
| | | | | | | | | Revert r350104 "[asan] Fix build on windows." Revert r350101 "[asan] Support running without /proc." These changes break Mac build, too. llvm-svn: 350112
* [asan] Fix build on windows.Evgeniy Stepanov2018-12-271-1/+9
| | | | | | | | | | Reviewers: vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D56111 llvm-svn: 350104
* [asan] Support running without /proc.Evgeniy Stepanov2018-12-271-14/+27
| | | | | | | | | | | | | | | | | | Summary: This patch lets ASan run when /proc is not accessible (ex. not mounted yet). It includes a special test-only flag that emulates this condition in an unpriviledged process. This only matters on Linux, where /proc is necessary to enumerate virtual memory mappings. Reviewers: pcc, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D55874 llvm-svn: 350101
* Remove pointless casts.Evgeniy Stepanov2018-12-201-2/+2
| | | | llvm-svn: 349717
* [asan] Make GetCurrentThread RTEMS-friendlyWalter Lee2018-05-211-0/+3
| | | | | | | | | | | | | | | | | On RTEMS, system and user code all live in a single binary and address space. There is no clean separation, and instrumented code may execute before the ASan run-time is initialized (or after it has been destroyed). Currently, GetCurrentThread() may crash if it's called before ASan run-time is initialized. Make it return nullptr instead. Similarly, fix __asan_handle_no_return so that it gives up rather than try something that may crash. Differential Revision: https://reviews.llvm.org/D46459 llvm-svn: 332888
* Align ClearShadowForThreadStackAndTLS for NetBSD/i386Kamil Rytarowski2018-05-191-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The static TLS vector for the main thread on NetBSD/i386 can be unaligned in terms of the shadow granularity. Align the start of it with Round Down and end of it with Round Up operations for the shadow granularity shift. Example static TLS vector ranges on NetBSD/i386: tls_begin_=0xfbee7244 tls_end_=0xfbee726c. ClearShadowForThreadStackAndTLS() is called from the Main Thread bootstrap functions. This change restores the NetBSD x86 32-bit (i386) support. Sponsored by <The NetBSD Foundation> Reviewers: vitalybuka, joerg Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D46585 llvm-svn: 332792
* [sanitizer] Trivial portion of the port to Myriad RTEMSWalter Lee2018-05-181-4/+5
| | | | | | | | | | | | | | | | | | | | | This commit contains the trivial portion of the port of ASan to Myriad RTEMS. - Whitelist platform in sanitizer_platform.h, ubsan_platform.h - Turn off general interception - Use memset for FastPoisonShadow - Define interception wrappers - Set errno symbol correctly - Enable ASAN_LOW_MEMORY - Enable preinit array - Disable slow unwinding - Use fuchsia offline symbolizer - Disable common code for: InitializeShadowMemory, CreateMainThread, AsanThread::ThreadStart, StartReportDeadlySignal, MaybeReportNonExecRegion. Differential Revision: https://reviews.llvm.org/D46454 llvm-svn: 332681
* [asan] Initialize fake stack during thread initWalter Lee2018-05-101-1/+3
| | | | | | | | | | | 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
* [lsan] Report unsuspended threadsVitaly Buka2018-05-091-0/+5
| | | | | | | | | | | | | | | Summary: Leak checker needs to suspend all process threads. If we have some running thread in registry but not suspended we can have false leak report. So we will report this case here for future debugging. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D46663 llvm-svn: 331936
* [ASan] Enhance libsanitizer support for invalid-pointer-pair.Alex Shlyapnikov2017-12-041-1/+24
| | | | | | | | | | | | | | | | | | | | 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] Refactor thread creation bookkeepingVitaly Buka2017-08-091-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [asan] Complete the Fuchsia portVitaly Buka2017-08-091-0/+6
| | | | | | | | | | | | | | | | Submitted on behalf of Roland McGrath. Reviewers: kcc, eugenis, alekseyshl, vitalybuka Reviewed By: vitalybuka Subscribers: filcab, vitalybuka, srhines, kubamracek, mgorny, phosek, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35865 llvm-svn: 310431
* [asan] Remove check for stack sizeJonas Hahnfeld2017-07-051-1/+0
| | | | | | | | This has been introduced in r304598 and fails for increased stack sizes. Differential Revision: https://reviews.llvm.org/D34876 llvm-svn: 307127
* [asan] fix one more case where stack-use-after-return is not ↵Kostya Serebryany2017-06-021-4/+8
| | | | | | async-signal-safe (during thread startup). beef-up the test to give it a chance to catch regressions. Also relax the lint to make C++11 more usable. llvm-svn: 304598
* [sanitizer] Introduce tid_t as a typedef for OS-provided thread IDsKuba Mracek2017-04-171-4/+4
| | | | | | | | 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] Eliminate SHADOW_TO_MEM() macroIvan A. Kosarev2017-04-101-1/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D31592 llvm-svn: 299867
* [tsan] Properly describe GCD worker threads in reportsKuba Mracek2017-02-021-1/+2
| | | | | | | | When dealing with GCD worker threads, TSan currently prints weird things like "created by thread T-1" and "[failed to restore the stack]" in reports. This patch avoids that and instead prints "Thread T3 (...) is a GCD worker thread". Differential Revision: https://reviews.llvm.org/D29103 llvm-svn: 293882
* [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiberDmitry Vyukov2016-09-281-3/+13
| | | | | | | | | | | 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] Fix a crash in GetCurrentThread() before init.Evgeniy Stepanov2016-09-071-1/+1
| | | | | | | | | Android-specific code in GetCurrentThread() does not handle the situation when there is no ThreadContext for the current thread. This happens if the current thread is requested before the main thread is added to the registry. 64-bit allocator does that to record map/unmap stats during initialization. llvm-svn: 280876
* [asan] add primitives that allow coroutine implementationsDmitry Vyukov2016-06-211-3/+102
| | | | | | | | | | | | | | | | | 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-2/+4
| | | | | | | | | | | | | | | | | | | | 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-10/+10
| | | | | | | | | | | | | | | | | | - 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] Remove AsanPlatformThreadInitReid Kleckner2015-07-211-1/+0
| | | | | | | | | | | Since the CoreFoundation allocator replacement was moved in r173134, all implementations of this function have been empty. Reviewers: samsonov Differential Revision: http://reviews.llvm.org/D11375 llvm-svn: 242811
* [ASan] Refactor thread starting code.Sergey Matveev2014-12-051-2/+11
| | | | | | Move thread context creation into AsanThread::Create(). llvm-svn: 223483
* [ASan, LSan] Improve tracking of thread creation.Sergey Matveev2014-12-051-1/+5
| | | | | | | | | | | | | | | 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
* Change StackDepot interface to use StackTrace more extensivelyAlexey Samsonov2014-10-261-1/+1
| | | | llvm-svn: 220637
* [ASan] Make stack-buffer-overflow reports more robustAlexey Samsonov2014-10-011-10/+11
| | | | | | | | | | | | | | | | | | | | 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] initialize fake_stack_ to 0 before we call SetThreadStackAndTls, ↵Kostya Serebryany2014-06-061-1/+3
| | | | | | because that may actually try to use fake_stack_ (still don't know how). Yet another case where we desperately want https://sourceware.org/glibc/wiki/ThreadPropertiesAPI llvm-svn: 210315
* Fix typosAlp Toker2014-05-151-1/+1
| | | | llvm-svn: 208841
* Reapply r201910. MSVC gets __func__ defined explicitly, even though itJoerg Sonnenberger2014-02-261-1/+1
| | | | | | can't build anything here. llvm-svn: 202297
* Revert "Replace __FUNCTION__ with __func__, the latter being standard ↵Reid Kleckner2014-02-221-1/+1
| | | | | | | | | | | | C99/C++11." This reverts commit r201910. While __func__ may be standard in C++11, it was only recently added to MSVC in 2013 CTP, and LLVM supports MSVC 2012. __FUNCTION__ may not be standard, but it's *very* portable. llvm-svn: 201916
* Replace __FUNCTION__ with __func__, the latter being standard C99/C++11.Joerg Sonnenberger2014-02-211-1/+1
| | | | llvm-svn: 201910
* [asan] experimental intercetor for __tls_get_addr. So far it does nothing ↵Kostya Serebryany2014-01-291-0/+2
| | | | | | interesting, actual usage will come later. See https://groups.google.com/forum/#!topic/address-sanitizer/BfwYD8HMxTM for background llvm-svn: 200384
* [ASan] Move the signal handling-related flags to sanitizer_common.Alexander Potapenko2014-01-281-2/+2
| | | | | | This change is a part of refactoring intended to have common signal handling behavior in all tools. llvm-svn: 200295
* [asan] replace the flag uar_stack_size_log with two flags ↵Kostya Serebryany2013-12-161-2/+5
| | | | | | min_uar_stack_size_log/max_uar_stack_size_log llvm-svn: 197370
* [asan] if verbosity>=2, print the fake stack usage stats at thread exit; No ↵Kostya Serebryany2013-12-111-3/+4
| | | | | | functionality change in non-verboze mode llvm-svn: 197037
* [sanitizer] Introduce VReport and VPrintf macros and use them in sanitizer code.Sergey Matveev2013-12-051-15/+8
| | | | | | Instead of "if (common_flags()->verbosity) Report(...)" we now have macros. llvm-svn: 196497
* [ASan] Clarify that AsanThread objects are allocated only via mmap(). No ↵Alexey Samsonov2013-11-271-1/+0
| | | | | | functionality change. llvm-svn: 195840
* [asan] fix a leak in tds ↵Kostya Serebryany2013-11-131-2/+2
| | | | | | (https://code.google.com/p/address-sanitizer/issues/detail?id=233) llvm-svn: 194572
* Introduce an operator new for LowLevelAllocator, and convert most users to it.Peter Collingbourne2013-10-241-2/+1
| | | | llvm-svn: 193308
* [asan] allocate AsanThreadContext using LowLevelAllocator instead of mmap to ↵Kostya Serebryany2013-10-181-1/+5
| | | | | | save space llvm-svn: 192980
* [asan] reduce the size of AsanThreadContext by storing the stack trace in ↵Kostya Serebryany2013-10-181-3/+3
| | | | | | the stack depot llvm-svn: 192979
* tsan: move verbosity flag to CommonFlagsDmitry Vyukov2013-10-151-4/+4
| | | | llvm-svn: 192701
* [lsan] Support ASan's stack-use-after-return mode in LSan.Sergey Matveev2013-10-141-4/+15
| | | | | | Treat the fake stack as live memory. llvm-svn: 192593
* [asan] Improve thread lifetime tracking on POSIX systems.Sergey Matveev2013-10-141-1/+7
| | | | | | | | 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] introduce run-time flag uar_stack_size_log to control the size of ↵Kostya Serebryany2013-09-271-5/+2
| | | | | | FakeStack; don't crash when the fake stack is exhausted, move some code to .cc file llvm-svn: 191510
OpenPOWER on IntegriCloud