diff options
| author | Alex Shlyapnikov <alekseys@google.com> | 2018-06-08 20:40:35 +0000 |
|---|---|---|
| committer | Alex Shlyapnikov <alekseys@google.com> | 2018-06-08 20:40:35 +0000 |
| commit | dcf0097962e4506aec59fbbd01c874527d2e061d (patch) | |
| tree | 1a41b71908299f93693d176a5cb9b94ea7a9de77 /compiler-rt/lib/asan/asan_errors.cc | |
| parent | 9e5eafbaa8ab0d49ccfd197a91b386e9aba28972 (diff) | |
| download | bcm5719-llvm-dcf0097962e4506aec59fbbd01c874527d2e061d.tar.gz bcm5719-llvm-dcf0097962e4506aec59fbbd01c874527d2e061d.zip | |
[Sanitizers] Check alignment != 0 for aligned_alloc and posix_memalign
Summary:
Move the corresponding tests to the common folder (as all of the
sanitizer allocators will support this feature soon) and add the checks
specific to aligned_alloc to ASan and LSan allocators.
Reviewers: vitalybuka
Subscribers: srhines, kubamracek, delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D47924
llvm-svn: 334316
Diffstat (limited to 'compiler-rt/lib/asan/asan_errors.cc')
| -rw-r--r-- | compiler-rt/lib/asan/asan_errors.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/asan_errors.cc b/compiler-rt/lib/asan/asan_errors.cc index bd007e5c563..abbb8e6ce56 100644 --- a/compiler-rt/lib/asan/asan_errors.cc +++ b/compiler-rt/lib/asan/asan_errors.cc @@ -216,6 +216,28 @@ void ErrorInvalidAllocationAlignment::Print() { ReportErrorSummary(scariness.GetDescription(), stack); } +void ErrorInvalidAlignedAllocAlignment::Print() { + Decorator d; + Printf("%s", d.Warning()); + char tname[128]; +#if SANITIZER_POSIX + Report("ERROR: AddressSanitizer: invalid alignment requested in " + "aligned_alloc: %zd, alignment must be a power of two and the " + "requested size 0x%zx must be a multiple of alignment " + "(thread T%d%s)\n", alignment, size, tid, + ThreadNameWithParenthesis(tid, tname, sizeof(tname))); +#else + Report("ERROR: AddressSanitizer: invalid alignment requested in " + "aligned_alloc: %zd, the requested size 0x%zx must be a multiple of " + "alignment (thread T%d%s)\n", alignment, size, tid, + ThreadNameWithParenthesis(tid, tname, sizeof(tname))); +#endif + Printf("%s", d.Default()); + stack->Print(); + PrintHintAllocatorCannotReturnNull("ASAN_OPTIONS"); + ReportErrorSummary(scariness.GetDescription(), stack); +} + void ErrorInvalidPosixMemalignAlignment::Print() { Decorator d; Printf("%s", d.Warning()); |

