summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
Commit message (Collapse)AuthorAgeFilesLines
* SanitizerCommon: fixes for unwinding & backtrace on SPARCVitaly Buka2019-03-121-1/+1
| | | | | | | | | | | | | | | | | | | Summary: This patch contains various fixes for the unwinding and backtrace machinery on the SPARC, which doesn't work correctly in various cases. It was tested with GCC on SPARC/Solaris and SPARC/Linux. Patch by Eric Botcazou. Reviewers: #sanitizers, vitalybuka Reviewed By: #sanitizers, vitalybuka Subscribers: jrtc27, delcypher, vitalybuka, ro, jyknight, kubamracek, fedor.sergeev, jdoerfert, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58431 llvm-svn: 355965
* Revert "[NFC][Sanitizer] Cleanup ASan's GetStackTrace implementation"Vitaly Buka2019-03-051-5/+0
| | | | | | | | I've missed that UnwindSlow was removed from ScopedUnwinding. This reverts commit 4ce918e3942f0333ccb7d65d6265f4fc5f5324be. llvm-svn: 355369
* [NFC][Sanitizer] Cleanup ASan's GetStackTrace implementationJulian Lettner2019-03-051-0/+5
| | | | | | | | | | | | | | | | | | | | | Cleanup ASan's __sanitizer::BufferedStackTrace::UnwindImpl (formerly GetStackTrace) implementation. Start with ASan because it is the most complex implementation. GetStackTrace implementations seem to have started out as exact copies of the original implementation in ASan, but have diverged in subtle ways. My goal is to parameterize this algorithm (via templating or callbacks) so we can share the implementation and get rid of the inversed dependency (sanitizer_common depends on concrete implementations in asan, ubsan, etc.). This should also help us to avoid those pesky linker errors caused by undefined, duplicate, and weak symbols on Windows. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D58861 llvm-svn: 355355
* [NFC][Sanitizer] Replace last uses of old Unwind APIJulian Lettner2019-03-011-0/+2
| | | | | | | | | | | | | Replace remaining uses of old Unwind API in unit tests. Allows us to remove the old API and WillUseFastUnwind can be made private. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D58754 llvm-svn: 355242
* [NFC][Sanitizer] Make GetStackTrace a private method of BufferedStackTraceJulian Lettner2019-03-011-6/+10
| | | | | | | | | | GetStackTrace is a implementation detail of BufferedStackTrace. Make it a private method. Reviewed By: vitalybuka Differential-Revision: https://reviews.llvm.org/D58753 llvm-svn: 355232
* [NFC][Sanitizer] Add new BufferedStackTrace::Unwind APIJulian Lettner2019-03-011-14/+31
| | | | | | | | | | | | | | | | | | | | | Retrying without replacing call sites in sanitizer_common (which might not have a symbol definition). Add new Unwind API. This is the final envisioned API with the correct abstraction level. It hides/slow fast unwinder selection from the caller and doesn't take any arguments that would leak that abstraction (i.e., arguments like stack_top/stack_bottom). GetStackTrace will become an implementation detail (private method) of the BufferedStackTrace class. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58741 > llvm-svn: 355168 llvm-svn: 355172
* Revert "[NFC][Sanitizer] Add new BufferedStackTrace::Unwind API"Julian Lettner2019-03-011-31/+14
| | | | | | This reverts commit 6112f37e758ebf2405955e091a745f5003c1f562. llvm-svn: 355171
* [NFC][Sanitizer] Add new BufferedStackTrace::Unwind APIJulian Lettner2019-03-011-14/+31
| | | | | | | | | | | | | | | | Add new Unwind API. This is the final envisioned API with the correct abstraction level. It hides/slow fast unwinder selection from the caller and doesn't take any arguments that would leak that abstraction (i.e., arguments like stack_top/stack_bottom). GetStackTrace will become an implementation detail (private method) of the BufferedStackTrace class. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58741 llvm-svn: 355168
* [NFC][Sanitizer] Pull up GetStackTrace into sanitizer_commonJulian Lettner2019-02-271-0/+6
| | | | | | | | | | | | | | | | | | | | We already independently declare GetStackTrace in all (except TSan) sanitizer runtime headers. Lets move it to sanitizer_stacktrace.h to have one canonical way to fill in a BufferedStackFrame. Also enables us to use it in sanitizer_common itself. This patch defines GetStackTrace for TSan and moves the function from ubsan_diag.cc to ubsan_diag_standalone.cc to avoid duplicate symbols for the UBSan-ASan runtime. Other than that this patch just moves the code out of headers and into the correct namespace. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58651 llvm-svn: 355039
* Remove overly broad assert from r354717.Richard Trieu2019-02-231-2/+0
| | | | llvm-svn: 354720
* [NFC][Sanitizer] Add argument checks to BufferedStackTrace::Unwind* functionsJulian Lettner2019-02-231-1/+3
| | | | | | | | Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58555 llvm-svn: 354717
* [NFC][Sanitizer] Rename BufferedStackTrace::FastUnwindStackJulian Lettner2019-02-221-5/+4
| | | | | | | | | | | | | | | | FastUnwindStack -> UnwindFast SlowUnwindStack -> UnwindSlow Stack is redundant, verb should come first. SlowUnwindStackWithContext(uptr pc, void *context, u32 max_depth) -> SlowUnwindStack WithContext is redundant, since it is a required parameter. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58551 llvm-svn: 354696
* 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
* [Sanitizers] Disable SANITIZER_CAN_FAST_UNWIND on all SPARC targetsRainer Orth2018-11-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | While testing my to-be-submitted Solaris sanitizer support on gcc mainline, I ran into an issue on Solaris/SPARC (sparc-sun-solaris2.11). Initially libasan.so failed to link: Undefined first referenced symbol in file __sanitizer::BufferedStackTrace::FastUnwindStack(unsigned long, unsigned long, unsigned long, unsigned long, unsigned int) /var/gcc/gcc-9.0.0-20181024/11.5-gcc-gas/sparc-sun-solaris2.11/./libsanitizer/asan/.libs/libasan.so This happens because SANITIZER_CAN_FAST_UNWIND is enabled on non-Linux SPARC targets (cf. sanitizer_stacktrace.h), but the guard around the SPARCv8-only definition in sanitizer_stacktrace_sparc.cc only works with clang: clang predefines __sparcv8__ on non-Solaris, and __sparcv8 only on Solaris gcc predefines __sparcv8 on Solaris, but __sparc_v8__ on non-Solaris The attached patch allows for all three variants. However, disabling SANITIZER_CAN_FAST_UNWIND on all SPARC targets fixes a couple of testsuite failures in the Solaris asan testsuite, so for now it's better to keep it disabled everywhere. This allowed the libsanitizer build to complete and gave reasonable (though slightly worse than on Solaris/x86) testsuite results. Differential Revision: https://reviews.llvm.org/D54099 llvm-svn: 346155
* [sanitizer] Reland "Be more accurate when calculating the previous ↵Igor Kudrin2018-05-231-4/+5
| | | | | | | | instruction address on ARM." Differential Revision: https://reviews.llvm.org/D46004 llvm-svn: 333071
* [sanitizer] Trivial portion of the port to Myriad RTEMSWalter Lee2018-05-181-1/+1
| | | | | | | | | | | | | | | | | | | | | 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
* Revert "[sanitizer] Be more accurate when calculating the previous ↵Igor Kudrin2018-05-081-5/+4
| | | | | | | | | | | instruction address on ARM." This reverts commit r331626 because it causes build bot failures: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/5069 Differential Revision: https://reviews.llvm.org/D46004 llvm-svn: 331734
* [sanitizer] Be more accurate when calculating the previous instruction ↵Igor Kudrin2018-05-071-4/+5
| | | | | | | | address on ARM. Differential Revision: https://reviews.llvm.org/D46004 llvm-svn: 331626
* OpenBSD UBsan support enabling SANITIZER_OPENBSD widelyKamil Rytarowski2018-03-031-1/+3
| | | | | | | | | | | | | | | | Summary: Adding OpenBSD platform Patch by: David CARLIER Reviewers: krytarowski, vitalybuka Reviewed By: vitalybuka Subscribers: srhines, kubamracek, fedor.sergeev, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D44049 llvm-svn: 326651
* [sanitizer] Add BufferedStackTrace::Reset()Vitaly Buka2017-09-141-2/+7
| | | | llvm-svn: 313226
* [LSAN] Fix test swapcontext.cc on MIPSSagar Thakur2016-05-181-0/+5
| | | | | | | | | There is no frame validity check in the slow unwinder like there is in the fast unwinder due to which lsan reports a leak even for heap allocated coroutine in the test swapcontext.cc. Since mips/linux uses slow unwindwer instead of fast unwinder, the test fails for mips/linux. Therefore adding the checks before unwinding fixes the test for mips/linux. Reviewed by aizatsky. Differential: http://reviews.llvm.org/D19961 llvm-svn: 269882
* Revert "[LSAN] Fix test swapcontext.cc on MIPS"Renato Golin2016-04-221-5/+0
| | | | | | This reverts commit r266716, as it breaks the self-hosting on Thumb2 buildbot. llvm-svn: 267158
* [LSAN] Fix test swapcontext.cc on MIPSSagar Thakur2016-04-191-0/+5
| | | | | | | | | Summary: There is no frame validity check in the slow unwinder like there is in the fast unwinder due to which lsan reports a leak even for heap allocated coroutine in the test swapcontext.cc. Since mips/linux uses slow unwindwer instead of fast unwinder, the test fails for mips/linux. Therefore adding the checks before unwinding fixes the test for mips/linux. Reviewers: samsonov, earthdok, kcc Subscribers: llvm-commits, mohit.bhakkad, jaydeep Differential: http://reviews.llvm.org/D18690 llvm-svn: 266716
* [libsanitizer] Fix bugs and wiki links to point to GitHub.Alexander Potapenko2015-12-041-1/+1
| | | | llvm-svn: 254738
* [MSan] Enable MSAN for aarch64Adhemerval Zanella2015-09-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch enabled msan for aarch64 with 39-bit VMA and 42-bit VMA. As defined by lib/msan/msan.h the memory layout used is for 39-bit is: 00 0000 0000 - 40 0000 0000: invalid 40 0000 0000 - 43 0000 0000: shadow 43 0000 0000 - 46 0000 0000: origin 46 0000 0000 - 55 0000 0000: invalid 55 0000 0000 - 56 0000 0000: app (low) 56 0000 0000 - 70 0000 0000: invalid 70 0000 0000 - 80 0000 0000: app (high) And for 42-bit VMA: 000 0000 0000 - 100 0000 0000: invalid 100 0000 0000 - 11b 0000 0000: shadow 11b 0000 0000 - 120 0000 0000: invalid 120 0000 0000 - 13b 0000 0000: origin 13b 0000 0000 - 2aa 0000 0000: invalid 2aa 0000 0000 - 2ab 0000 0000: app (low) 2ab 0000 0000 - 3f0 0000 0000: invalid 3f0 0000 0000 - 400 0000 0000: app (high) Most of tests are passing with exception of: * Linux/mallinfo.cc * chained_origin_limits.cc * dlerror.cc * param_tls_limit.cc * signal_stress_test.cc * nonnull-arg.cpp The 'Linux/mallinfo.cc' is due the fact AArch64 returns the sret in 'x8' instead of default first argument 'x1'. So a function prototype that aims to mimic (by using first argument as the return of function) won't work. For GCC one can make a register alias (register var asm ("r8")), but for clang it detects is an unused variable and generate wrong code. The 'chained_origin_limits' is probably due a wrong code generation, since it fails only when origin memory is used (-fsanitize-memory-track-origins=2) and only in the returned code (return buf[50]). The 'signal_streess_test' and 'nonnull-arg' are due currently missing variadic argument handling in memory sanitizer code instrumentation on LLVM side. Both 'dlerror' and 'param_tls_test' are unknown failures that require further investigation. All the failures are XFAIL for aarch64 for now. llvm-svn: 247809
* PowerPC's ABIs differ from those of other architectures in that theBill Schmidt2015-07-281-2/+1
| | | | | | | | | | callee-saved return address is stored in the caller's stack frame, not the callee's. This patch adjusts the logic to find the LR in the correct place for PowerPC. Patch joint with Bill Seurer. llvm-svn: 243467
* [msan] Better use-after-free reports.Evgeniy Stepanov2015-01-221-8/+16
| | | | | | | | | | | | | By attaching an extra integer tag to heap origins, we are able to distinguish between uninits - created by heap allocation, - created by heap deallocation (i.e. use-after-free), - created by __msan_allocated_memory call, - etc. See https://code.google.com/p/memory-sanitizer/issues/detail?id=35. llvm-svn: 226821
* [sanitizer] fix a performance regression in sanitizer coverage: move a small ↵Kostya Serebryany2014-12-201-1/+18
| | | | | | perf-critical function to a header. ALso set the coverage guard to 1 before the early return from CoverageData::Add llvm-svn: 224660
* [MSan] [MIPS] Adding support for MIPS64 (patch by Mohit Bhakkad).Alexey Samsonov2014-11-191-0/+1
| | | | | | Reviewed at http://reviews.llvm.org/D5906 llvm-svn: 222388
* [Sanitizers] Enable stack traces on FreeBSDViktor Kutuzov2014-11-101-5/+10
| | | | | | Differential Revision: http://reviews.llvm.org/D6086 llvm-svn: 221595
* [TSan] Use StackTrace from sanitizer_common where applicableAlexey Samsonov2014-11-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change removes `__tsan::StackTrace` class. There are now three alternatives: # Lightweight `__sanitizer::StackTrace`, which doesn't own a buffer of PCs. It is used in functions that need stack traces in read-only mode, and helps to prevent unnecessary allocations/copies (e.g. for StackTraces fetched from StackDepot). # `__sanitizer::BufferedStackTrace`, which stores buffer of PCs in a constant array. It is used in TraceHeader (non-Go version) # `__tsan::VarSizeStackTrace`, which owns buffer of PCs, dynamically allocated via TSan internal allocator. Test Plan: compiler-rt test suite Reviewers: dvyukov, kcc Reviewed By: kcc Subscribers: llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D6004 llvm-svn: 221194
* [Sanitizer] Return code that calculates hash for stacktrace back to ↵Alexey Samsonov2014-10-271-21/+0
| | | | | | StackDepot implementation llvm-svn: 220663
* Change StackDepot interface to use StackTrace more extensivelyAlexey Samsonov2014-10-261-0/+22
| | | | llvm-svn: 220637
* [Sanitizer] Make StackTrace a lightweight reference to array of PCs, andAlexey Samsonov2014-10-261-19/+17
| | | | | | | | | | | | | | | | | | | | | | introduce a BufferedStackTrace class, which owns this array. Summary: This change splits __sanitizer::StackTrace class into a lightweight __sanitizer::StackTrace, which doesn't own array of PCs, and BufferedStackTrace, which owns it. This would allow us to simplify the interface of StackDepot, and eventually merge __sanitizer::StackTrace with __tsan::StackTrace. Test Plan: regression test suite. Reviewers: kcc, dvyukov Reviewed By: dvyukov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5985 llvm-svn: 220635
* [UBSan] Get pc/bp for stack unwinding as early as possible.Alexey Samsonov2014-07-291-0/+4
| | | | | | | | This will ensure that stack frames in error reports will not contain internal UBSan failures, and frame #0 will be the actual place in the program where the error happens. llvm-svn: 214245
* Only use fast stack unwinding for sanitizers failure reports on FreeBSDViktor Kutuzov2014-07-101-1/+4
| | | | | | Differential Revision: http://reviews.llvm.org/D4420 llvm-svn: 212691
* [sanitizer] AArch64 sanitizer support; patch by Christophe Lyon and Yvan RouxKostya Serebryany2014-02-131-2/+3
| | | | llvm-svn: 201303
* [sanitizer] Use system unwinder in signal handlers on Android.Evgeniy Stepanov2014-02-111-1/+3
| | | | | | | | | | Because of the way Bionic sets up signal stack frames, libc unwinder is unable to step through it, resulting in broken SEGV stack traces. Luckily, libcorkscrew.so on Android implements an unwinder that can start with a signal context, thus sidestepping the issue. llvm-svn: 201151
* [asan] Enable frame pointer based unwinder on ARM.Evgeniy Stepanov2014-01-211-4/+2
| | | | | | | | This code works with AAPCS-style {fp, lr} frames. Unlike linux perf, it does not unwind through code compiled with -mapcs-frame (which Clang does not support anyway). llvm-svn: 199725
* [ASan] Get rid of ASan-specific functions for printing stack tracesAlexey Samsonov2013-12-191-0/+3
| | | | llvm-svn: 197672
* [Sanitizer] Delete unused StackTrace::PrintStack argumentAlexey Samsonov2013-12-191-2/+1
| | | | llvm-svn: 197671
* Unbreak build by adding an implementation of PopStackFrames function.Richard Smith2013-12-091-0/+1
| | | | llvm-svn: 196809
* Revert three patches which were committed without explicit contributionChandler Carruth2013-12-091-1/+0
| | | | | | | | | | | | | | | by their authors. This may break builds where others added code relying on these patches, but please *do not* revert this commit. Instead, we will prepare patches which fix the failures. Reverts the following commits: r168306: "[asan] support x32 mode in the fast stack unwinder. Patch by H.J. Lu" r168356: "[asan] more support for powerpc, patch by Peter Bergner" r196489: "[sanitizer] fix the ppc32 build (patch by Jakub Jelinek)" llvm-svn: 196802
* [Sanitizer] Make slow unwinder on Linux more robustAlexey Samsonov2013-11-151-1/+1
| | | | llvm-svn: 194805
* [Sanitizer] Use same PC threshold in slow unwinder on all platformsAlexey Samsonov2013-11-131-1/+1
| | | | llvm-svn: 194580
* [ASan] Do not rely on malloc context in allocator reports.Alexey Samsonov2013-11-131-0/+2
| | | | | | | | | | | Invoke a fatal stack trace unwinder when ASan prints allocator-relevant error reports (double-free, alloc-dealloc-mismatch, invalid-free). Thus we'll be able to print complete stack trace even if allocation/free stacks are not stored (malloc_context_size=0). Based on the patch by Yuri Gribov! llvm-svn: 194579
* [Sanitizers] Share some stack walking code between Windows and LinuxTimur Iskhodzhanov2013-11-091-0/+1
| | | | | | Reviewed at http://llvm-reviews.chandlerc.com/D2126 llvm-svn: 194326
* [Sanitizer] Make StackTrace::Unwind the only public way to unwind a stack trace.Alexey Samsonov2013-11-071-6/+15
| | | | llvm-svn: 194196
* [Sanitizer] Call Windows unwinder 'slow' and share StackTrace::Unwind across ↵Alexey Samsonov2013-11-071-2/+4
| | | | | | all platforms. No functionality change. llvm-svn: 194193
* [ASan] Kill use_stack_depot runtime flag and stack trace compression routines.Alexey Samsonov2013-11-011-5/+0
| | | | llvm-svn: 193868
OpenPOWER on IntegriCloud