summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "[sanitizer] Introduce ReservedAddressRange to sanitizer_common"Petr Hosek2017-10-111-37/+0
| | | | | | This reverts commit r315493 which is failing to build on sanitizer-windows. llvm-svn: 315494
* [sanitizer] Introduce ReservedAddressRange to sanitizer_commonPetr Hosek2017-10-111-0/+37
| | | | | | | | | | | | | | | | | | | | | | In Fuchsia, MmapNoAccess/MmapFixedOrDie are implemented using a global VMAR, which means that MmapNoAccess can only be called once. This works for the sanitizer allocator but *not* for the Scudo allocator. Hence, this changeset introduces a new ReservedAddressRange object to serve as the new API for these calls. In this changeset, the object still calls into the old Mmap implementations. The next changeset two changesets will convert the sanitizer and scudo allocators to use the new APIs, respectively. (ReservedAddressRange will replace the SecondaryHeader in Scudo.) Finally, a last changeset will update the Fuchsia implementation. Patch by Julia Hansbrough Differential Revision: https://reviews.llvm.org/D38759 llvm-svn: 315493
* Add support for custom loaders to the sanitizer symbolizerFrancis Ricci2017-10-021-1/+3
| | | | | | | | | | | | | | | | | Summary: Adds a fallback mode to procmaps when the symbolizer fails to locate a module for a given address by using dl_iterate_phdr. Reviewers: kubamracek, rnk, vitalybuka, eugenis Reviewed By: eugenis Subscribers: srhines, llvm-commits Differential Revision: https://reviews.llvm.org/D37269 llvm-svn: 314713
* Revert "Add support for custom loaders to the sanitizer symbolizer"Francis Ricci2017-10-021-3/+1
| | | | | | This reverts commit r314671, which hangs on the gcc sanitizer buildbot. llvm-svn: 314684
* Add support for custom loaders to the sanitizer symbolizerFrancis Ricci2017-10-021-1/+3
| | | | | | | | | | | | | | | | | Summary: Adds a fallback mode to procmaps when the symbolizer fails to locate a module for a given address by using dl_iterate_phdr. Reviewers: kubamracek, rnk, vitalybuka, eugenis Reviewed By: eugenis Subscribers: srhines, llvm-commits Differential Revision: https://reviews.llvm.org/D37269 llvm-svn: 314671
* Move LoadedModule list to a NoCtor vector and initialize on demand.Francis Ricci2017-09-291-1/+1
| | | | | | | Unreverting this patch because llvm-clang-lld-x86_64-debian-fast started passing again before the revert hit. Must've been just a flake. llvm-svn: 314556
* Revert "Move LoadedModule list to a NoCtor vector and initialize on demand."Francis Ricci2017-09-291-1/+1
| | | | | | | | | I think this may have introduced a failure on llvm-clang-lld-x86_64-debian-fast This reverts commit r314533 llvm-svn: 314552
* Move LoadedModule list to a NoCtor vector and initialize on demand.Francis Ricci2017-09-291-1/+1
| | | | llvm-svn: 314533
* Revert "Add support for custom loaders to the sanitizer symbolizer"Francis Ricci2017-09-281-4/+2
| | | | | | | | This causes the gcc sanitizer buildbot to timeout. This reverts commit 81f388fe570e5b6460dd5bc9b9a36b72714eeb68. llvm-svn: 314453
* Add support for custom loaders to the sanitizer symbolizerFrancis Ricci2017-09-281-2/+4
| | | | | | | | | | | | | | | | | Summary: Adds a fallback mode to procmaps when the symbolizer fails to locate a module for a given address by using dl_iterate_phdr. Reviewers: kubamracek, rnk, vitalybuka, eugenis Reviewed By: eugenis Subscribers: srhines, llvm-commits Differential Revision: https://reviews.llvm.org/D37269 llvm-svn: 314431
* Revert "Add support for custom loaders to symbolizer"Francis Ricci2017-09-271-4/+2
| | | | | | | | This broke the windows buildbots, revert for now. This reverts commit 24050b5ddef42f6f3306aa94d4a1f42a7893a9a7. llvm-svn: 314347
* Add support for custom loaders to symbolizerFrancis Ricci2017-09-271-2/+4
| | | | | Change-Id: I5594bd6b216deca2c73cf0a7001f9aec1e803c60 llvm-svn: 314342
* [sanitizer_common] Don't provide sanitizer_procmaps API functions where not ↵Francis Ricci2017-09-251-1/+0
| | | | | | | | | | | | | | | | | defined Summary: Platforms that don't implement procmaps (primarily fuchsia and windows) still expose the procmaps API when including sanitizer_procmaps.h, despite not implementing the functions provided by that header. Ensure that the API is only exposed on platforms that implement it. Reviewers: vitalybuka, alekseyshl, kubamracek Subscribers: llvm-commits, krytarowski Differential Revision: https://reviews.llvm.org/D38187 llvm-svn: 314149
* [sanitizer] Move StartReportDeadlySignal into sanitizer_common_libcdepVitaly Buka2017-09-181-4/+0
| | | | llvm-svn: 313518
* [sanitizer] Add empty Fuchsia and Win versions of StartReportDeadlySignalVitaly Buka2017-09-141-0/+4
| | | | llvm-svn: 313240
* [sanitizer] Move IsStackOverflow into SignalContextVitaly Buka2017-09-141-0/+4
| | | | llvm-svn: 313227
* [compiler-rt] Fix Windows buildVitaly Buka2017-09-141-4/+0
| | | | llvm-svn: 313224
* [compiler-rt] Cleanup SignalContext initializationVitaly Buka2017-09-141-14/+29
| | | | | | | | | | Reviewers: eugenis, alekseyshl Subscribers: kubamracek, dberris Differential Revision: https://reviews.llvm.org/D37827 llvm-svn: 313223
* [compiler-rt] Use SignalContext in ErrorStackOverflow and ErrorDeadlySignalVitaly Buka2017-09-131-26/+43
| | | | | | | | | | | | Summary: Part of https://github.com/google/sanitizers/issues/637 Reviewers: eugenis, alekseyshl, filcab Subscribers: kubamracek, llvm-commits, dberris Differential Revision: https://reviews.llvm.org/D37793 llvm-svn: 313168
* [compiler-rt] Add siginfo into SignalContextVitaly Buka2017-09-131-2/+6
| | | | | | | | | | | | | | | Summary: Information stored there is often been passed along with SignalContext. Part of https://github.com/google/sanitizers/issues/637 Reviewers: eugenis, alekseyshl Subscribers: kubamracek, llvm-commits, dberris Differential Revision: https://reviews.llvm.org/D37792 llvm-svn: 313167
* [sanitizers] Add a blocking boolean to GetRandom prototypeKostya Kortchinsky2017-08-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: On platforms with `getrandom`, the system call defaults to blocking. This becomes an issue in the very early stage of the boot for Scudo, when the RNG source is not set-up yet: the syscall will block and we'll stall. Introduce a parameter to specify that the function should not block, defaulting to blocking as the underlying syscall does. Update Scudo to use the non-blocking version. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D36399 llvm-svn: 310839
* [sanitizer_common] Move filesystem-related code out of sanitizer_common.ccVitaly Buka2017-07-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: This is a pure refactoring change. It just moves code that is related to filesystem operations from sanitizer_common.{cc,h} to sanitizer_file.{cc,h}. This makes it cleaner to disable the filesystem-related code for a new port that doesn't want it. Submitted on behalf of Roland McGrath. Reviewers: kcc, eugenis, alekseyshl Reviewed By: alekseyshl Subscribers: vitalybuka, llvm-commits, kubamracek, mgorny, phosek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35591 llvm-svn: 308819
* [asan] For iOS/AArch64, if the dynamic shadow doesn't fit, restrict the VM spaceKuba Mracek2017-07-121-1/+2
| | | | | | | | | | On iOS/AArch64, the address space is very limited and has a dynamic maximum address based on the configuration of the device. We're already using a dynamic shadow, and we find a large-enough "gap" in the VM where we place the shadow memory. In some cases and some device configuration, we might not be able to find a large-enough gap: E.g. if the main executable is linked against a large number of libraries that are not part of the system, these libraries can fragment the address space, and this happens before ASan starts initializing. This patch has a solution, where we have a "backup plan" when we cannot find a large-enough gap: We will restrict the address space (via MmapFixedNoAccess) to a limit, for which the shadow limit will fit. Differential Revision: https://reviews.llvm.org/D35098 llvm-svn: 307865
* [Sanitizers] 64 bit allocator respects allocator_may_return_null flagAlex Shlyapnikov2017-06-261-0/+12
| | | | | | | | | | | | | | | | Summary: Make SizeClassAllocator64 return nullptr when it encounters OOM, which allows the entire sanitizer's allocator to follow allocator_may_return_null=1 policy (LargeMmapAllocator: D34243, SizeClassAllocator64: D34433). Reviewers: eugenis Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34540 llvm-svn: 306342
* [Sanitizers] 32 bit allocator respects allocator_may_return_null flagAlex Shlyapnikov2017-06-221-10/+15
| | | | | | | | | | | | | | | | | | | Summary: Make SizeClassAllocator32 return nullptr when it encounters OOM, which allows the entire sanitizer's allocator to follow allocator_may_return_null=1 policy, even for small allocations (LargeMmapAllocator is already fixed by D34243). Will add a test for OOM in primary allocator later, when SizeClassAllocator64 can gracefully handle OOM too. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34433 llvm-svn: 305972
* [sanitizer] Add a function to gather random bytesKostya Kortchinsky2017-06-211-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: AFAICT compiler-rt doesn't have a function that would return 'good' random bytes to seed a PRNG. Currently, the `SizeClassAllocator64` uses addresses returned by `mmap` to seed its PRNG, which is not ideal, and `SizeClassAllocator32` doesn't benefit from the entropy offered by its 64-bit counterpart address space, so right now it has nothing. This function aims at solving this, allowing to implement good 32-bit chunk randomization. Scudo also has a function that does this for Cookie purposes, which would go away in a later CL once this lands. This function will try the `getrandom` syscall if available, and fallback to `/dev/urandom` if not. Unfortunately, I do not have a way to implement and test a Mac and Windows version, so those are unimplemented as of now. Note that `kRandomShuffleChunks` is only used on Linux for now. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: zturner, rnk, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34412 llvm-svn: 305922
* [Sanitizers] Secondary allocator respects allocator_may_return_null=1.Alex Shlyapnikov2017-06-161-0/+10
| | | | | | | | | | | | | | | | | | Summary: Context: https://github.com/google/sanitizers/issues/740. Making secondary allocator to respect allocator_may_return_null=1 flag and return nullptr when "out of memory" happens. More changes in primary allocator and operator new will follow. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34243 llvm-svn: 305569
* [sanitizer] Reverting D34152Kostya Kortchinsky2017-06-141-5/+1
| | | | | | | | | | | | | | | | | Summary: This broke thread_local_quarantine_pthread_join.cc on some architectures, due to the overhead of the stashed regions. Reverting while figuring out the best way to deal with it. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34213 llvm-svn: 305404
* [sanitizer] MmapAlignedOrDie changes to reduce fragmentationKostya Kortchinsky2017-06-141-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The reasoning behind this change is explained in D33454, which unfortunately broke the Windows version (due to the platform not supporting partial unmapping of a memory region). This new approach changes `MmapAlignedOrDie` to allow for the specification of a `padding_chunk`. If non-null, and the initial allocation is aligned, this padding chunk will hold the address of the extra memory (of `alignment` bytes). This allows `AllocateRegion` to get 2 regions if the memory is aligned properly, and thus help reduce fragmentation (and saves on unmapping operations). As with the initial D33454, we use a stash in the 32-bit Primary to hold those extra regions and return them on the fast-path. The Windows version of `MmapAlignedOrDie` will always return a 0 `padding_chunk` if one was requested. Reviewers: alekseyshl, dvyukov, kcc Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34152 llvm-svn: 305391
* [sanitizer-coverage] nuke more stale codeKostya Serebryany2017-06-021-3/+0
| | | | llvm-svn: 304504
* [compiler-rt] Replace allow_user_segv_handler=0 with kHandleSignalExclusiveVitaly Buka2017-05-251-2/+2
| | | | | | | | | | | | | | Summary: allow_user_segv_handler had confusing name did not allow to control behavior for signals separately. Reviewers: eugenis, alekseyshl, kcc Subscribers: llvm-commits, dberris, kubamracek Differential Revision: https://reviews.llvm.org/D33371 llvm-svn: 303941
* Use write instead of read permissions to check for global sections on macFrancis Ricci2017-05-191-1/+1
| | | | | | | | | | | | | | | Summary: The LINKEDIT section is very large and is read-only. Scanning this section caused LSan on darwin to be very slow. When only writable sections are scanned for global pointers, performance improved by a factor of about 25x. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33322 llvm-svn: 303422
* [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
* Don't read non-readable address ranges during lsan pointer scanningFrancis Ricci2017-04-171-1/+2
| | | | | | | | | | | | Summary: This specifically addresses the Mach-O zero page, which we cannot read from. Reviewers: kubamracek, samsonov, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32044 llvm-svn: 300456
* [sanitizer] Bail out with warning if user dlopens shared library with ↵Maxim Ostapenko2017-03-091-0/+3
| | | | | | | | | | | | RTLD_DEEPBIND flag People keep hitting on spurious failures in malloc/free routines when using sanitizers with shared libraries dlopened with RTLD_DEEPBIND (see https://github.com/google/sanitizers/issues/611 for details). Let's check for this flag and bail out with warning message instead of failing in random places. Differential Revision: https://reviews.llvm.org/D30504 llvm-svn: 297370
* [sanitizer] Move DescribeSignalOrException to sanitizer_common.Marcos Pividori2017-02-021-0/+26
| | | | | | Differential Revision: https://reviews.llvm.org/D29459 llvm-svn: 293956
* [sanitizer] Move exception code to sanitizer_common.Marcos Pividori2017-02-021-0/+27
| | | | | | Differential Revision: https://reviews.llvm.org/D29458 llvm-svn: 293955
* General definition for weak functionsMarcos Pividori2017-01-291-11/+0
| | | | | | | | | | | | | | | | | | In this diff, I define a general macro for defining weak functions with a default implementation: "SANITIZER_INTERFACE_WEAK_DEF()". This way, we simplify the implementation for different platforms. For example, we cannot define weak functions on Windows, but we can use linker pragmas to create an alias to a default implementation. All of these implementation details are hidden in the new macro. Also, as I modify the name for exported weak symbols on Windows, I needed to temporarily disable "dll_host" test for asan, which checks the list of functions included in asan_win_dll_thunk. Differential Revision: https://reviews.llvm.org/D28596 llvm-svn: 293419
* [sanitizer] [asan] Use macros to simplify weak aliases on Windows.Marcos Pividori2017-01-201-5/+3
| | | | | | | | | This patch adds some useful macros for dealing with pragma directives on Windows. Also, I add appropriate documentation for future users. Differential Revision: https://reviews.llvm.org/D28525 llvm-svn: 292650
* [sanitizer] Add a 'print_module_map' flag which prints modules with UUIDs on ↵Kuba Mracek2017-01-061-0/+2
| | | | | | | | | | Darwin This patch add a new sanitizer flag, print_module_map, which enables printing a module map when the process exits, or after each report (for TSan). The output format is very similar to what Crash Reporter produces on Darwin (e.g. the format of module UUIDs). This enables users to use the existing symbol servers to offline symbolicate and aggregate reports. Differential Revision: https://reviews.llvm.org/D27400 llvm-svn: 291277
* break overly long line in sanitizer_win.ccBob Haarman2017-01-051-1/+2
| | | | llvm-svn: 291062
* fix warning about noreturn in sanitizer_win's internal__exit()Bob Haarman2017-01-051-1/+15
| | | | | | | | | | | | | | Summary: A previous fix used __assume(0), but not all compilers know that control will not pass that. This patch uses a macro which works in more compilers. Reviewers: rnk Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D28268 llvm-svn: 291042
* Fix warning for noreturn functionReid Kleckner2016-12-131-0/+1
| | | | llvm-svn: 289568
* Release memory to OS only when the requested range covers the entire pageEvgeniy Stepanov2016-11-301-2/+1
| | | | | | | | | | | | | | | | | Summary: The current code was sometimes attempting to release huge chunks of memory due to undesired RoundUp/RoundDown interaction when the requested range is fully contained within one memory page. Reviewers: eugenis Subscribers: kubabrecka, llvm-commits Patch by Aleksey Shlyapnikov. Differential Revision: https://reviews.llvm.org/D27228 llvm-svn: 288271
* [asan] Add a "dump_registers" flag to print out CPU registers after a SIGSEGVKuba Mracek2016-11-261-0/+4
| | | | | | | | This patch prints out all CPU registers after a SIGSEGV. These are available in the signal handler context. Only implemented for Darwin. Can be turned off with the dump_registers flag. Differential Revision: https://reviews.llvm.org/D11365 llvm-svn: 287957
* [asan/win] Delay load dbghelp.dll to delay ucrtbase.dll initializationReid Kleckner2016-11-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: ASan needs to initialize before ucrtbase.dll so that it can intercept all of its heap allocations. New versions of dbghelp.dll depend on ucrtbase.dll, which means both of those DLLs will initialize before the dynamic ASan runtime. By lazily loading dbghelp.dll with LoadLibrary, we avoid the issue. Eventually, I would like to remove our dbghelp.dll dependency in favor of always using llvm-symbolizer.exe, but this seems like an acceptable interim solution. Fixes PR30903 Reviewers: etienneb Subscribers: kubabrecka, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D26473 llvm-svn: 286848
* [asan/win] Fix wrong TerminateProcess exit codeReid Kleckner2016-11-111-1/+1
| | | | | | Add a test for it. llvm-svn: 286608
* [asan/win] Move breakpoint from Abort to internal__exitReid Kleckner2016-11-101-2/+4
| | | | | | | | Now that we use TerminateProcess, the debugger doesn't stop on program exit. Add this breakpoint so that the debugger stops after asan reports an error and is prepared to exit the program. llvm-svn: 286501
* [asan/win] Use TerminateProcess when we want to exit abnormallyReid Kleckner2016-11-091-1/+2
| | | | | | | | ExitProcess still runs some code which can lead to ASan interceptors running after CHECK failure. This can lead to deadlock if it CHECK fails again. Avoid that mess by really exiting immediately. llvm-svn: 286395
* tsan: always define SANITIZER_GODmitry Vyukov2016-10-281-4/+4
| | | | | | | | | | | | | | | | | | | | | | Currently we either define SANITIZER_GO for Go or don't define it at all for C++. This works fine with preprocessor (ifdef/ifndef/defined), but does not work for C++ if statements (e.g. if (SANITIZER_GO) {...}). Also this is different from majority of SANITIZER_FOO macros which are always defined to either 0 or 1. Always define SANITIZER_GO to either 0 or 1. This allows to use SANITIZER_GO in expressions and in flag default values. Also remove kGoMode and kCppMode, which were meant to be used in expressions, but they are not defined in sanitizer_common code, so SANITIZER_GO become prevalent. Also convert some preprocessor checks to C++ if's or ternary expressions. Majority of this change is done mechanically with: sed "s#ifdef SANITIZER_GO#if SANITIZER_GO#g" sed "s#ifndef SANITIZER_GO#if \!SANITIZER_GO#g" sed "s#defined(SANITIZER_GO)#SANITIZER_GO#g" llvm-svn: 285443
OpenPOWER on IntegriCloud