summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/lsan
Commit message (Collapse)AuthorAgeFilesLines
...
* [Sanitizer] Remove CombinedAllocator::Allocate's 'cleared' parameterAlex Shlyapnikov2017-06-161-1/+1
| | | | | | | | | | | | | | Summary: CombinedAllocator::Allocate cleared parameter is not used anywhere and seem to be obsolete. Reviewers: eugenis Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34289 llvm-svn: 305590
* Revert r304285, r304297.Evgeniy Stepanov2017-06-051-24/+0
| | | | | | | | | | | r304285 - [sanitizer] Avoid possible deadlock in child process after fork r304297 - [sanitizer] Trying to fix MAC buildbots after r304285 These changes create deadlock when Tcl calls pthread_create from a pthread_atfork child handler. More info in the original review at https://reviews.llvm.org/D33325 llvm-svn: 304735
* Revert "[sanitizer-coverage] test for -fsanitize-coverage=inline-8bit-counters"Renato Golin2017-06-052-20/+6
| | | | | | | | | | | | | Revert "Mark sancov test as unsupported on Darwin" Revert "[LSan] Detect dynamic loader by its base address." This reverts commit r304633. This reverts commit r304673. This reverts commit r304632. Those commit have broken LOTS of ARM/AArch64 bots for two days. llvm-svn: 304699
* [LSan] Detect dynamic loader by its base address.Alex Shlyapnikov2017-06-032-6/+20
| | | | | | | | | | | | | | | Summary: Whenever possible (Linux + glibc 2.16+), detect dynamic loader module by its base address, not by the module name matching. The current name matching approach fails on some configurations. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D33859 llvm-svn: 304633
* [sanitizer] Trying to fix MAC buildbots after r304285Maxim Ostapenko2017-05-311-4/+8
| | | | | | | It seems that on MAC allocator already locks on fork thus adding another ForceLock in fork interceptor will cause a deadlock. llvm-svn: 304297
* [sanitizer] Avoid possible deadlock in child process after forkMaxim Ostapenko2017-05-311-0/+20
| | | | | | | | | | | | | | This patch addresses https://github.com/google/sanitizers/issues/774. When we fork a multi-threaded process it's possible to deadlock if some thread acquired StackDepot or allocator internal lock just before fork. In this case the lock will never be released in child process causing deadlock on following memory alloc/dealloc routine. While calling alloc/dealloc routines after multi-threaded fork is not allowed, most of modern allocators (Glibc, tcmalloc, jemalloc) are actually fork safe. Let's do the same for sanitizers except TSan that has complex locking rules. Differential Revision: https://reviews.llvm.org/D33325 llvm-svn: 304285
* Fix typo in tls patchFrancis Ricci2017-05-251-1/+1
| | | | llvm-svn: 303906
* Implement tls scanning for darwin LSanFrancis Ricci2017-05-253-20/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This required for any users who call exit() after creating thread-specific data, as tls destructors are only called when pthread_exit() or pthread_cancel() are used. This should also match tls behavior on linux. Getting the base address of the tls section is straightforward, as it's stored as a section offset in %gs. The size is a bit trickier to work out, as there doesn't appear to be any official documentation or source code referring to it. The size used in this patch was determined by taking the difference between the base address and the address of the subsequent memory region returned by vm_region_recurse_64, which was 1024 * sizeof(uptr) on all threads except the main thread, where it was larger. Since the section must be the same size on all of the threads, 1024 * sizeof(uptr) seemed to be a reasonable size to use, barring a more programtic way to get the size. 1024 seems like a reasonable number, given that PTHREAD_KEYS_MAX is 512 on darwin, so pthread keys will fit inside the region while leaving space for other tls data. A larger size would overflow the memory region returned by vm_region_recurse_64, and a smaller size wouldn't leave room for all the pthread keys. In addition, the stress test added here passes, which means that we are scanning at least the full set of possible pthread keys, and probably the full tls section. Reviewers: alekseyshl, kubamracek Subscribers: krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D33215 llvm-svn: 303887
* Use write instead of read permissions to check for global sections on macFrancis Ricci2017-05-191-1/+2
| | | | | | | | | | | | | | | 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
* Revert "Implement tls scanning for darwin LSan"Francis Ricci2017-05-173-17/+20
| | | | | | This reverts r303262, due to TSan buildbot breakages. llvm-svn: 303266
* Implement tls scanning for darwin LSanFrancis Ricci2017-05-173-20/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This required for any users who call exit() after creating thread-specific data, as tls destructors are only called when pthread_exit() or pthread_cancel() are used. This should also match tls behavior on linux. Getting the base address of the tls section is straightforward, as it's stored as a section offset in %gs. The size is a bit trickier to work out, as there doesn't appear to be any official documentation or source code referring to it. The size used in this patch was determined by taking the difference between the base address and the address of the subsequent memory region returned by vm_region_recurse_64, which was 1024 * sizeof(uptr) on all threads except the main thread, where it was larger. Since the section must be the same size on all of the threads, 1024 * sizeof(uptr) seemed to be a reasonable size to use, barring a more programtic way to get the size. 1024 seems like a reasonable number, given that PTHREAD_KEYS_MAX is 512 on darwin, so pthread keys will fit inside the region while leaving space for other tls data. A larger size would overflow the memory region returned by vm_region_recurse_64, and a smaller size wouldn't leave room for all the pthread keys. In addition, the stress test added here passes, which means that we are scanning at least the full set of possible pthread keys, and probably the full tls section. Reviewers: alekseyshl, kubamracek Subscribers: krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D33215 llvm-svn: 303262
* [lsan] Report the missing linker only when the linker is actually missing.Alex Shlyapnikov2017-05-151-2/+4
| | | | | | | | | | Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33218 llvm-svn: 303129
* [sanitizer] Change SizeClassAllocator32 to accept just one templateKostya Kortchinsky2017-05-151-4/+12
| | | | | | | | | | | | | | | | | | | | | Summary: With rL279771, SizeClassAllocator64 was changed to accept only one template instead of 5, for the following reasons: "First, this will make the mangled names shorter. Second, this will make adding more parameters simpler". This patch mirrors that work for SizeClassAllocator32. This is in preparation for introducing the randomization of chunks in the 32-bit SizeClassAllocator in a later patch. Reviewers: kcc, alekseyshl, dvyukov Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D33141 llvm-svn: 303071
* Avoid unnecessary calls to vm_region_recurseFrancis Ricci2017-05-091-0/+5
| | | | | | | | | | | | Summary: This should significantly improve darwin lsan performance in cases where root regions are not used. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32966 llvm-svn: 302530
* [sanitizer] Intercept mcheck and mprobe on LinuxMaxim Ostapenko2017-05-031-0/+14
| | | | | | | | | This patch addresses https://github.com/google/sanitizers/issues/804. Users can use mcheck and mprobe functions to verify heap state so we should intercept them to avoid breakage of valid code. Differential Revision: https://reviews.llvm.org/D32589 llvm-svn: 302001
* [lsan] When necessary, define LSan suppression for tls_get_addr.Alex Shlyapnikov2017-04-261-1/+1
| | | | | | | | | | | | | | | Summary: Generalize already defined LSan suppression for the leak on tls_get_addr, some envs do not have the entire call stack symbolized, so we have to be less specific. Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32545 llvm-svn: 301434
* [lsan] When necessary, define LSan suppression for pthread_exit.Alex Shlyapnikov2017-04-251-3/+3
| | | | | | | | | | | | | | | Summary: Generalize already defined LSan suppression for the leak on pthread_exit, some envs do not have the entire call stack symbolized, so we have to be less specific. Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32497 llvm-svn: 301335
* [lsan] Enable LSan on PowerPC64.Alex Shlyapnikov2017-04-212-2/+3
| | | | | | | | | | | | Summary: Re-landing reverted D31995 with suppressions defined in D32303 and D32377. Reviewers: eugenis Subscribers: nemanjai, llvm-commits Differential Revision: https://reviews.llvm.org/D32379 llvm-svn: 301048
* Suppress DTLS leak happening in some glibc versions.Alex Shlyapnikov2017-04-211-3/+4
| | | | | | | | | | | | Summary: Refer to https://sourceware.org/bugzilla/show_bug.cgi?id=12650 for the context. Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32377 llvm-svn: 301043
* Disable LSan on ppc64, some tests are failing.Alex Shlyapnikov2017-04-212-3/+2
| | | | llvm-svn: 300933
* Enable LSan on PowerPC64.Alex Shlyapnikov2017-04-202-2/+3
| | | | | | | | | | | | Summary: Re-landing reverted D31995 with suppressions defined in D32303. Reviewers: eugenis Subscribers: nemanjai, llvm-commits Differential Revision: https://reviews.llvm.org/D32314 llvm-svn: 300903
* Define standard suppressions for LSan, start with this one.Alex Shlyapnikov2017-04-201-6/+9
| | | | llvm-svn: 300887
* Define a suppression for known leaks on pthread_exit call.Alex Shlyapnikov2017-04-201-0/+6
| | | | | | | | | | | | Summary: Refer to D32194 for the context. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D32303 llvm-svn: 300886
* Fixup style from r300760Francis Ricci2017-04-191-3/+3
| | | | llvm-svn: 300765
* Make sure to scan mmap'd memory regions for root pointers on OS XFrancis Ricci2017-04-193-29/+58
| | | | | | | | | | | | | | | | | | | Summary: In the general case, we only need to check for root regions inside the memory map returned by procmaps. However, on Darwin, we also need to check inside mmap'd regions, which aren't returned in the list of modules we get from procmaps. This patch refactors memory region scanning on darwin to reduce code duplication with the kernel alloc once page scan. Reviewers: kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32190 llvm-svn: 300760
* Implement StopTheWorld for DarwinFrancis Ricci2017-04-191-1/+1
| | | | | | | | | | Reviewers: kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32189 llvm-svn: 300759
* Move valid caller-pc checks out of platform-specific checksFrancis Ricci2017-04-194-64/+77
| | | | | | | | | | | | | | | | | | | | | | Summary: ProcessPlatformSpecificAllocations for linux leak sanitizer iterated over memory chunks and ran two checks concurrently: 1) Ensured the pc was valid 2) Checked whether it was a linker allocation All platforms will need the valid pc check, so it is moved out of the platform- specific file. To prevent code and logic duplication, the linker allocation check is moved as well, with the name of the linker supplied by the platform-specific module. In cases where we don't need to check for linker allocations (ie Darwin), this name will be a nullptr, and we'll only run the caller pc checks. Reviewers: kubamracek, alekseyshl, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32130 llvm-svn: 300690
* Update suspended threads info to be compatible with darwinFrancis Ricci2017-04-171-2/+2
| | | | | | | | | | | | | | | Summary: On Darwin, we need to track thread and tid as separate values. This patch splits out the implementation of the suspended threads list to be OS-specific. Reviewers: glider, kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31474 llvm-svn: 300491
* [sanitizer] Introduce tid_t as a typedef for OS-provided thread IDsKuba Mracek2017-04-174-7/+7
| | | | | | | | 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/+1
| | | | | | | | | | | | 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
* Scan Kernel Alloc Once page for global pointersFrancis Ricci2017-04-171-1/+27
| | | | | | | | | | | | Summary: libxpc stashes some pointers here. Reviewers: kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32045 llvm-svn: 300450
* Disable use of tls scanning on darwin leak sanitizerFrancis Ricci2017-04-132-2/+7
| | | | | | | | | | | | | | Summary: These checks appear linux-specific, disable them on darwin, at least for now. Reviewers: kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32013 llvm-svn: 300248
* Revert "Enable LSan on PowerPC64."Alex Shlyapnikov2017-04-132-3/+2
| | | | | | This reverts commit r300204. Breaks ASAN tests on PPC. llvm-svn: 300237
* Implement global pointer scanning for darwin leak sanitizerFrancis Ricci2017-04-134-15/+34
| | | | | | | | | | Reviewers: kubamracek, kcc, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32012 llvm-svn: 300234
* Don't assume PTHREAD_CREATE_JOINABLE is 0 on all systemsFrancis Ricci2017-04-131-1/+3
| | | | | | | | | | | | | | | | | Summary: Lsan was using PTHREAD_CREATE_JOINABLE/PTHREAD_CREATE_DETACHED as truthy values, which works on Linux, where the values are 0 and 1, but this fails on OS X, where the values are 1 and 2. Set PTHREAD_CREATE_DETACHED to the correct value for a given system. Reviewers: kcc, glider, kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31883 llvm-svn: 300221
* Enable LSan on PowerPC64.Alex Shlyapnikov2017-04-132-2/+3
| | | | | | | | | | | | | | Summary: With D31555 commited, looks like basic LSan functionality works on PPC64. Time to enable LSan there. Reviewers: eugenis Subscribers: nemanjai, llvm-commits Differential Revision: https://reviews.llvm.org/D31995 llvm-svn: 300204
* Implement standalone lsan interceptors for OS XFrancis Ricci2017-04-118-32/+131
| | | | | | | | | | | | | | Summary: Mimicks the existing tsan and asan implementations of Darwin interception. Reviewers: kubamracek, kcc, glider Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D31889 llvm-svn: 299979
* Don't delete lsan thread-local data until it's no longer requiredFrancis Ricci2017-04-112-2/+17
| | | | | | | | | | | | | | | | | | | | | | | Summary: The routines for thread destruction in the thread registry require the lsan thread index, which is stored in pthread tls on OS X. This means that we need to make sure that the lsan tls isn't destroyed until after the thread registry tls. This change ensures that we don't delete the lsan tls until we've finished destroying the thread in the registry, ensuring that the destructor for the lsan tls runs after the destructor for the thread registry tls. This patch also adds a check to ensure that the thread ID is valid before returning it in GetThreadID(), to ensure that the above behavior is working correctly. Reviewers: dvyukov, kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31884 llvm-svn: 299978
* Reapply "Enable LSan for arm Linux"Maxim Ostapenko2017-04-113-6/+33
| | | | | | This patch reapplies r299923 with typo fixed in BLX macros. llvm-svn: 299948
* Revert r299923, it doesn't build in bootstrap builds.Nico Weber2017-04-113-33/+6
| | | | | | | | | | | | | | | FAILED: lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.arm.dir/sanitizer_linux.cc.o lib/sanitizer_common/sanitizer_linux.cc:1340:24: error: invalid instruction BLX(ip) ^ lib/sanitizer_common/sanitizer_linux.cc:1313:19: note: expanded from macro 'BLX' # define BLX(R) "mov lr, pc; bx" #R "\n" ^ <inline asm>:6:13: note: instantiated into assembly here mov lr, pc; bxip ^~~~ llvm-svn: 299943
* [lsan] Enable LSan for arm LinuxMaxim Ostapenko2017-04-113-6/+33
| | | | | | | | This patch enables LSan for arm Linux. Differential Revision: https://reviews.llvm.org/D29586 llvm-svn: 299923
* Enable builds of darwin lsan by defaultFrancis Ricci2017-04-062-9/+4
| | | | | | | | | | | | Summary: Testing and asan leak detection are disabled by default. Reviewers: kubamracek, kcc Subscribers: srhines, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D31307 llvm-svn: 299669
* [lsan] Avoid segfaults during threads destruction under high loadMaxim Ostapenko2017-04-061-6/+12
| | | | | | | | | | | | | | | | | This patch addresses two issues: * It turned out that suspended thread may have dtls->dtv_size == kDestroyedThread (-1) and LSan wrongly assumes that DTV is available. This leads to SEGV when LSan tries to iterate through DTV that is invalid. * In some rare cases GetRegistersAndSP can fail with errno 3 (ESRCH). In this case LSan assumes that the whole stack of a given thread is available. This is wrong because ESRCH can indicate that suspended thread was destroyed and its stack was unmapped. This patch properly handles ESRCH from GetRegistersAndSP in order to avoid invalid accesses to already unpapped threads stack. Differential Revision: https://reviews.llvm.org/D30818 llvm-svn: 299630
* Move current thread data out of lsan_common on linuxFrancis Ricci2017-03-292-4/+4
| | | | | | | | | | | | | | Summary: Now that we have a platform-specific non-common lsan file, use it to store non-common lsan data. Reviewers: kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31472 llvm-svn: 299032
* Remove failing check from platform specific darwin lsan initializerFrancis Ricci2017-03-291-3/+3
| | | | | | | | | | | | | | Summary: We currently don't have any platform specific darwin lsan modules, don't force failure if they don't exist. Reviewers: kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31473 llvm-svn: 299031
* Postpone lsan tls allocation until requiredFrancis Ricci2017-03-281-8/+11
| | | | | | | | | | | | | | Summary: This prevents InternalAlloc from being called before the sanitizers are fully initialized. Reviewers: kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31306 llvm-svn: 298947
* Enable i386 builds for darwin lsanFrancis Ricci2017-03-281-3/+5
| | | | | | | | | | | | | | Summary: Now that __thread is no longer used for lsan on darwin, i386 builds can be enabled. Reviewers: kcc, kubamracek Subscribers: danalbert, srhines, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D29995 llvm-svn: 298946
* Fix missing sanitizer platform includeFrancis Ricci2017-03-271-1/+2
| | | | llvm-svn: 298884
* Fix comment in lsan_linux.ccFrancis Ricci2017-03-271-1/+1
| | | | llvm-svn: 298879
* Move lsan allocator cache from lsan_common_linux to lsan_linuxFrancis Ricci2017-03-273-4/+27
| | | | | | | | Having this function in common seems to trigger a lot of unrelated test failures. Given that this isn't really common code anyway, move this to a new linux-specific lsan file. llvm-svn: 298878
OpenPOWER on IntegriCloud