summaryrefslogtreecommitdiff
path: root/lib/asan/asan_malloc_win.cc
AgeCommit message (Collapse)Author
2017-03-15Fix -Wstring-conversion instanceReid Kleckner
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297879 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-30Recommit: Stop intercepting some malloc-related functions on FreeBSD andDimitry Andric
macOS Summary: In https://bugs.freebsd.org/215125 I was notified that some configure scripts attempt to test for the Linux-specific `mallinfo` and `mallopt` functions by compiling and linking small programs which references the functions, and observing whether that results in errors. FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so normally these tests would fail, but when sanitizers are enabled, they incorrectly succeed, because the sanitizers define interceptors for these functions. This also applies to some other malloc-related functions, such as `memalign`, `pvalloc` and `cfree`. Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`, `pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers. Also delete the non-functional `cfree` wrapper for Windows, to fix the test cases on that platform. Reviewers: emaste, kcc, rnk Subscribers: timurrrr, eugenis, hans, joerg, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D27654 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293536 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-11Fix _recalloc redefinition link error in ASan RTLReid Kleckner
Fixes PR30329 Patch by Hans-Bernhard Broeker! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@283955 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-24[asan] Intercept all Heap* related imports from ucrtbase.dllReid Kleckner
ucrtbase.dll appears to be built with some kind of cross-module inlining, because there are calls to imported Heap* routines sprinkled throughout the code. This inlining defeats our attempts to hotpatch malloc, _malloc_base, and related functions. Failing to intercept an allocation or deallocation results in a crash when the program attempts to deallocate or reallocate memory with the wrong allocator. This change patches the IAT of ucrtbase.dll to replace the addresses of the imported Heap* functions with implementations provided by ASan. We don't globally intercept the win32 Heap* functions because they are typically used by system DLLs that run before ASan initializes. Eventually, we may want to intercept them, but for now I think this is the minimal change that will keep ASan stable. Reviewers: samsonov Differential Revision: http://reviews.llvm.org/D18413 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264327 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-23[asan] Export new and delete operators on WindowsReid Kleckner
This is necessary to support the dynamic CRT (/MD) with VS2015. In VS2015, these symbols are no longer imported from a DLL, they provided statically by msvcrt.lib. This means our approach of hotpatching the DLL no longer works. By exporting the symbols, we end up relying on the same mechanism that we use to intercept symbols in the static CRT (/MT) case. The ASan runtime always needs to appear first on the link line, and the linker searches for symbol definitions from left to right. This means we can stop hotpatching operator new and delete in the CRT, which is nice. I think that the only reason we weren't exporting the symbols already is because MSVC doesn't allow you to do it directly with __declspec(dllexport). Instead, we can use `#pragma comment(linker, "/export:foo")`, which is most of what the attribute does under the hood. It does mean we have to write down the mangled names of the operators, but that's not too bad. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264190 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-21[asan] Add new _*_base interceptors for VS 2015Reid Kleckner
There are some places in the CRT (such as mbctype) that directly call _malloc_base. If you are incrementally linking a binary with ASan from before this change, this change appears to result in a linker error. Retrying the link succeeds for some reason. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264005 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-18[msan] Remove MSanDR and supporting code.Evgeniy Stepanov
MSanDR is a dynamic instrumentation tool that can instrument the code (prebuilt libraries and such) that could not be instrumented at compile time. This code is unused (to the best of our knowledge) and unmaintained, and starting to bit-rot. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@222232 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-25[ASan/Win] Intercept memory allocation functions in the MD CRTTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216382 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15Follow-up to r215724: fix a lint warningTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215725 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15[ASan/Win] Introduce a new macro for malloc-like function attributes; also, ↵Timur Iskhodzhanov
clang-format the definitions of these functions git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215724 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15[ASan/Win] Remove old, unused and non-functional code that will be ↵Timur Iskhodzhanov
re-written soon git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215707 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-27Add support for _expand[_dbg] so we don't crash when _aligned_* allocation ↵Timur Iskhodzhanov
functions are used git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204925 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-20[sanitizer] Use the new sanitizer_interception.h header in all interceptors.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197808 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-13[ASan] Do not rely on malloc context in allocator reports.Alexey Samsonov
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! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194579 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-13[ASan/Win] Oops, forgot to add the attributes to the memory allocations ↵Timur Iskhodzhanov
functions git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188290 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-19[sanitizer] More renamed macros.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177401 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-19[sanitizer] Replace more platform checks with SANITIZER_ constants.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177400 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-21[asan] add a flag alloc_dealloc_mismatch (off by default for now) which ↵Kostya Serebryany
finds malloc/delete, new/free, new/delete[], etc mismatches git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170869 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-13[asan] add two asan flags: fast_unwind_on_fatal and fast_unwind_on_malloc to ↵Kostya Serebryany
allow using the slow CFI-based unwinder git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170117 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-24[ASan] Apply some ASan-relevant pieces of patch by Ruben Van Boxem. In the ↵Alexey Samsonov
same time, remove ASan from CMake build on Windows after conversation with Timur. We don't want to support building ASan on Windows until it is in a working state. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@164486 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04Remove file-type tags for .cc files in ASan run-time libraryAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157927 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-31[asan] more renamingKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157746 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-23[ASan] Add a few more malloc-related interceptors for WindowsTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@153327 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-12[ASan] Add back the support for /MT; intercept statically-linked functionsTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@152557 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-07[ASan] Fix lint warningTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@152226 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-07[ASan/Win] Intercept _msize, required for running SQLiteTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@152224 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-29[ASan] Replace CRT .dll malloc with our implementation at asan_init() timeTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@151715 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-22[ASan] Intercept functions on Windows - first versionTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@151161 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-06[asan] The first version of Windows malloc interceptors, patch by ↵Kostya Serebryany
timurrrr@google.com git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@149875 91177308-0d34-0410-b5e6-96231b3b80d8