Index: lib/asan/asan_errors.h =================================================================== --- lib/asan/asan_errors.h +++ lib/asan/asan_errors.h @@ -198,6 +198,37 @@ void Print(); }; +struct ErrorStringFunctionMemoryRangesOverlap : ErrorBase { + u32 tid; + // ErrorStringFunctionMemoryRangesOverlap doesn't own the stack trace. + BufferedStackTrace *stack; + AddressDescriptionBase addr1_description; + AddressDescriptionBase addr2_description; + uptr length1, length2; + const char *function; + // VS2013 doesn't implement unrestricted unions, so we need a trivial default + // constructor + ErrorStringFunctionMemoryRangesOverlap() = default; + ErrorStringFunctionMemoryRangesOverlap(u32 tid_, BufferedStackTrace *stack_, + uptr addr1, uptr length1_, uptr addr2, + uptr length2_, const char *function_) + : tid(tid_), + stack(stack_), + length1(length1_), + length2(length2_), + function(function_) { + char bug_type[100]; + internal_snprintf(bug_type, sizeof(bug_type), "%s-param-overlap", function); + scariness.Clear(); + scariness.Scare(10, bug_type); + addr1_description = AddressDescription( + addr1, length1, /*shouldLockThreadRegistry=*/false); + addr2_description = AddressDescription( + addr2, length2, /*shouldLockThreadRegistry=*/false); + } + void Print(); +}; + #define FOR_EACH_ERROR_KIND_MEMBER_NAME_PAIR(macro) \ macro(StackOverflow, stack_overflow) \ macro(DeadlySignal, deadly_signal) \ @@ -207,7 +238,9 @@ macro(AllocTypeMismatch, alloc_type_mismatch) \ macro(MallocUsableSizeNotOwned, malloc_usable_size_not_owned) \ macro(SanitizerGetAllocatedSizeNotOwned, \ - sanitizer_get_allocated_size_not_owned) + sanitizer_get_allocated_size_not_owned) \ + macro(StringFunctionMemoryRangesOverlap, \ + string_function_memory_ranges_overlap) enum ErrorKind { kErrorKindInvalid = 0, Index: lib/asan/asan_errors.cc =================================================================== --- lib/asan/asan_errors.cc +++ lib/asan/asan_errors.cc @@ -190,4 +190,23 @@ ReportErrorSummary("bad-__sanitizer_get_allocated_size", stack); } +void ErrorStringFunctionMemoryRangesOverlap::Print() { + Decorator d; + char bug_type[100]; + internal_snprintf(bug_type, sizeof(bug_type), "%s-param-overlap", function); + Printf("%s", d.Warning()); + Report( + "ERROR: AddressSanitizer: %s: memory ranges [%p,%p) and [%p, %p) " + "overlap\n", + bug_type, addr1_description.Address(), + addr1_description.Address() + length1, addr2_description.Address(), + addr2_description.Address() + length2); + Printf("%s", d.EndWarning()); + scariness.Print(); + stack->Print(); + addr1_description.Print(); + addr2_description.Print(); + ReportErrorSummary(bug_type, stack); +} + } // namespace __asan Index: lib/asan/asan_report.cc =================================================================== --- lib/asan/asan_report.cc +++ lib/asan/asan_report.cc @@ -382,19 +382,10 @@ const char *offset2, uptr length2, BufferedStackTrace *stack) { ScopedInErrorReport in_report; - Decorator d; - char bug_type[100]; - internal_snprintf(bug_type, sizeof(bug_type), "%s-param-overlap", function); - Printf("%s", d.Warning()); - Report("ERROR: AddressSanitizer: %s: " - "memory ranges [%p,%p) and [%p, %p) overlap\n", \ - bug_type, offset1, offset1 + length1, offset2, offset2 + length2); - Printf("%s", d.EndWarning()); - ScarinessScore::PrintSimple(10, bug_type); - stack->Print(); - PrintAddressDescription((uptr)offset1, length1, bug_type); - PrintAddressDescription((uptr)offset2, length2, bug_type); - ReportErrorSummary(bug_type, stack); + ErrorStringFunctionMemoryRangesOverlap error( + GetCurrentTidOrInvalid(), stack, (uptr)offset1, length1, (uptr)offset2, + length2, function); + in_report.ReportError(error); } void ReportStringFunctionSizeOverflow(uptr offset, uptr size,