summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc
Commit message (Collapse)AuthorAgeFilesLines
* compiler-rt: Rename .cc file in lib/sanitizer_common to .cppNico Weber2019-07-311-133/+0
| | | | | | | | | | | See https://reviews.llvm.org/D58620 for discussion, and for the commands I ran. In addition I also ran for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $f . ; done and manually updated (many) references to renamed files found by that. llvm-svn: 367463
* SanitizerCommon: fixes for unwinding & backtrace on SPARCVitaly Buka2019-03-121-3/+2
| | | | | | | | | | | | | | | | | | | 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
* [NFC][Sanitizer] Add TODO commentsJulian Lettner2019-02-271-2/+1
| | | | llvm-svn: 354947
* [NFC][Sanitizer] Comment out argument checksJulian Lettner2019-02-231-2/+2
| | | | | | These break clang-ppc64 bots. llvm-svn: 354718
* [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-2/+2
| | | | | | | | | | | | | | | | 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
* [Sanitizer] On Darwin `__sanitizer_print_stack_trace` only prints topmost frameJulian Lettner2019-02-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In compiler-rt we have the notion of a `fast` and a `slow` stack unwinder. Darwin currently only supports the fast unwinder. From reading the code, my understanding is that `BufferedStackTrace::Unwind` can be called with `bp=0, stack_top=0, stack_bottom=0, request_fast_unwind=false`. If `request_fast_unwind=true`, then we alos need to supply bp, stack_top, and stack_bottom. However, `BufferedStackTrace::Unwind` uses `StackTrace::WillUseFastUnwind` which will adapt `request_fast_unwind` if the requested unwinder is not supported. On Darwin, the result is that we don't pass actual values for bp, stack_top, and stack_bottom, but end up using the fast unwinder. The tests then fail because we only print the topmost stack frame. This patch adds a check to `WillUseFastUnwind` at the point of usage to avoid the mismatch between `request_fast_unwind` and what `Unwind` actually does. I am also interested in cleaning up the `request_fast_unwind` machinery so this patch just the simplest thing possible so I can enable the tests. Reviewers: vitalybuka, vsk Differential Revision: https://reviews.llvm.org/D58156 llvm-svn: 354282
* 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
* [sanitizer] Reland "Be more accurate when calculating the previous ↵Igor Kudrin2018-05-231-1/+2
| | | | | | | | instruction address on ARM." Differential Revision: https://reviews.llvm.org/D46004 llvm-svn: 333071
* [sanitizer] Port fast stack unwinder to sparcv8Walter Lee2018-05-101-1/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D46469 llvm-svn: 332046
* Revert "[PowerPC] Fix sanitizer frame unwind on 32-bit ABIs"Juergen Ributzka2017-03-171-14/+7
| | | | | | | This broke GreenDragon: http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/29210/ llvm-svn: 298029
* [PowerPC] Fix sanitizer frame unwind on 32-bit ABIsBill Seurer2017-03-161-7/+14
| | | | | | | | | This fixes many sanitizer problems with -m32. It is really intended for gcc but patches to the sanitizers make their way through llvm first. ref: https://gcc.gnu.org/ml/gcc-patches/2017-02/msg00855.html llvm-svn: 297995
* [asan] Fix comparison in BufferedStackTrace::LocatePcInTraceVitaly Buka2017-01-051-11/+6
| | | | | | | | | | | | | | Summary: Debug builds can have larger distance between stack trace and PC on that stack. If we assume that PC is always correct we can snap it to the nearest trace. Reviewers: eugenis Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D28342 llvm-svn: 291173
* Adding a comment to explain r273886 ("Stop unwinding the stack when a ↵Kuba Brecka2016-06-281-0/+3
| | | | | | close-to-zero PC is found"). NFC. llvm-svn: 274010
* [sanitizer] Stop unwinding the stack when a close-to-zero PC is foundKuba Brecka2016-06-271-0/+3
| | | | | | | | On OS X, we often get stack trace in a report that ends with a 0x0 frame. To get rid of it, let's trim the stack trace when we find a close-to-zero value, which is obviously not a valid PC. Differential Revision: http://reviews.llvm.org/D14656 llvm-svn: 273886
* [LSAN] Fix test swapcontext.cc on MIPSSagar Thakur2016-05-181-5/+0
| | | | | | | | | 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-0/+5
| | | | | | This reverts commit r266716, as it breaks the self-hosting on Thumb2 buildbot. llvm-svn: 267158
* [asan] Increase LocatePcInTrace threshold.Evgeniy Stepanov2016-04-201-1/+1
| | | | | | | | | | | | | | Not sure what changed, but on my machine this is literally one byte short. Only happens when malloc_context_size <= 2 due to the special case in GET_STACK_TRACE definition (see asan_stack.h): StackTrace::GetCurrentPc() on the right (context size > 2) branch returns the address that is 200-something bytes from the return address it is later matched to, while the same call on the left branch is 321 bytes away from it. This fixes the double-free test on my machine. llvm-svn: 266932
* [LSAN] Fix test swapcontext.cc on MIPSSagar Thakur2016-04-191-5/+0
| | | | | | | | | 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
* [sanitizer] [SystemZ] Fix stack traces.Marcin Koscielnicki2016-04-141-0/+2
| | | | | | | | | | | | | | | | | | | On s390, the return address is in %r14, which is saved 14 words from the frame pointer. Unfortunately, there's no way to do a proper fast backtrace on SystemZ with current LLVM - the saved %r15 in fixed-layout register save area points to the containing frame itself, and not to the next one. Likewise for %r11 - it's identical to %r15, unless alloca is used (and even if it is, it's still useless). There's just no way to determine frame size / next frame pointer. -mbackchain would fix that (and make the current code just work), but that's not yet supported in LLVM. We will thus need to XFAIL some asan tests (Linux/stack-trace-dlclose.cc, deep_stack_uaf.cc). Differential Revision: http://reviews.llvm.org/D18895 llvm-svn: 266371
* [Sanitizer] Increase kPcThreshold in slow unwinder after r254395.Alexey Samsonov2015-12-011-1/+1
| | | | llvm-svn: 254460
* Add commentary explaining PPC access to return addressBill Schmidt2015-07-281-0/+3
| | | | llvm-svn: 243470
* PowerPC's ABIs differ from those of other architectures in that theBill Schmidt2015-07-281-0/+8
| | | | | | | | | | 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
* Enable memory sanitizer for PPC64Jay Foad2015-06-251-0/+2
| | | | | | | | | | | | | | | | | | Summary: This patch adds basic memory sanitizer support for PPC64. PR23219. I have further patches ready to enable it in LLVM and Clang, and to fix most of the many failing tests in check-msan. Reviewers: kcc, willschm, samsonov, wschmidt, eugenis Reviewed By: eugenis Subscribers: wschmidt, llvm-commits Differential Revision: http://reviews.llvm.org/D10648 llvm-svn: 240623
* [msan] Better use-after-free reports.Evgeniy Stepanov2015-01-221-1/+1
| | | | | | | | | | | | | 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-15/+0
| | | | | | perf-critical function to a header. ALso set the coverage guard to 1 before the early return from CoverageData::Add llvm-svn: 224660
* [ASan] Allow to atomically modify malloc_context_size at runtime.Alexey Samsonov2014-12-161-1/+1
| | | | | | | | | | | | | | | | | | Summary: Introduce __asan::malloc_context_size atomic that is used to determine required malloc/free stack trace size. It is initialized with common_flags()->malloc_context_size flag, but can later be overwritten at runtime (e.g. when ASan is activated / deactivated). Test Plan: regression test suite Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6645 llvm-svn: 224305
* [MSan] [MIPS] Adding support for MIPS64 (patch by Mohit Bhakkad).Alexey Samsonov2014-11-191-0/+8
| | | | | | Reviewed at http://reviews.llvm.org/D5906 llvm-svn: 222388
* [TSan] Use StackTrace from sanitizer_common where applicableAlexey Samsonov2014-11-031-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | 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] Make StackTrace a lightweight reference to array of PCs, andAlexey Samsonov2014-10-261-8/+7
| | | | | | | | | | | | | | | | | | | | | | 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
* [sanitizer] Fix a crash in FP unwinder on ARM.Evgeniy Stepanov2014-10-141-6/+15
| | | | | | | | | | | | | This change fixes 2 issues in the fast unwinder from r217079: * A crash if a frame pointer points below current stack head, but inside the current thread stack limits. That memory may be unmapped. A check for this was lost in r217079. * The last valid stack frame (the first one with an invalid next frame pointer) is always interpreted as a GCC layout frame. This results in garbled last PC in the (expected) case when the last frame has LLVM layout. llvm-svn: 219683
* [UBSan] Adding support of MIPS32Petar Jovanovic2014-09-261-1/+1
| | | | | | | | | | | | | | Changed files: config-ix.cmake: Enabled UBSan for MIPS32 sanitizer_stacktrace.cc: Program counter for MIPS32 is four byte aligned and a delay slot so subtracted PC by 8 for getting call site address. cast-overflow.cpp: Added big endian support for this test case. Patch by Sagar Thakur. Differential Revision: http://reviews.llvm.org/D4881 llvm-svn: 218519
* Fix fast stack unwind on ARM to support code generated with GCC.Alexey Samsonov2014-09-031-5/+25
| | | | | | | | http://reviews.llvm.org/D4692 Patch by Maxim Ostapenko! llvm-svn: 217079
* [sanitizer] Fix build on ARM.Evgeniy Stepanov2014-05-301-1/+2
| | | | llvm-svn: 209884
* [asan] Enable ASan on PowerPC.Evgeniy Stepanov2014-05-301-3/+5
| | | | | | Patch by Peter Bergner. llvm-svn: 209879
* Use 64-bit pointer to unwind stack for x86-64Kostya Serebryany2014-05-211-7/+7
| | | | | | | | X32 uses ILP32 data model in 64-bit hardware mode. This patch always uses 64-bit pointer to unwind stack for x86-64. Patch by H.J. Lu llvm-svn: 209277
* Increase threshold in StackTrace::LocatePcInTraceAlexey Samsonov2014-03-051-1/+1
| | | | llvm-svn: 202950
* Fix StackTrace::LocatePcInTrace, add more unit tests for generic StackTraceAlexey Samsonov2014-03-041-1/+1
| | | | llvm-svn: 202849
* Avoid doing any work when unwinding stack traces with 0 or 1 frameAlexey Samsonov2014-03-041-4/+1
| | | | llvm-svn: 202837
* [Sanitizer] Don't use MemoryMappingLayout in StackTrace::PrintStack - it is ↵Alexey Samsonov2013-12-251-70/+0
| | | | | | now a responsibility of Symbolizer class. llvm-svn: 198006
* [Sanitizer] Delete unused StackTrace::PrintStack argumentAlexey Samsonov2013-12-191-17/+1
| | | | llvm-svn: 197671
* [Sanitizer] Implement Symbolizer class on WindowsTimur Iskhodzhanov2013-12-181-0/+3
| | | | llvm-svn: 197571
* [Sanitizers] Rename Symbolizer::SymbolizeCode to Symbolizer::SymbolizePCTimur Iskhodzhanov2013-12-181-1/+1
| | | | llvm-svn: 197569
* [ASan] Fix StackTrace::SlowUnwindStack on WindowsTimur Iskhodzhanov2013-12-101-1/+1
| | | | llvm-svn: 196894
* Unbreak build by adding an implementation of PopStackFrames function.Richard Smith2013-12-091-0/+8
| | | | llvm-svn: 196809
* Revert three patches which were committed without explicit contributionChandler Carruth2013-12-091-19/+8
| | | | | | | | | | | | | | | 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
* Increase the LocatePcInTrace PC threshold now that ↵Timur Iskhodzhanov2013-11-291-1/+1
| | | | | | GET_STACK_TRACE_WITH_PC_AND_BP has grown llvm-svn: 195957
* [ASan] Also print <empty stack> when size==0Timur Iskhodzhanov2013-11-291-2/+2
| | | | llvm-svn: 195955
* [Sanitizer] Make slow unwinder on Linux more robustAlexey Samsonov2013-11-151-4/+3
| | | | llvm-svn: 194805
* [Sanitizer] Print symbolized stack frame using a single Printf() call.Alexey Samsonov2013-11-141-17/+24
| | | | | | | | This reduces the number of "write" syscalls performed to print a single stack frame description, and makes sanitizer output less intermixed with program output. Also, add a number of unit tests. llvm-svn: 194686
OpenPOWER on IntegriCloud