Commit 4f4f08c9 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Work around VC++ code-ben bug 804884

VC++ PGO builds crash deep inside memmove, as called by
message_center::InnerBoundedLabel::GetSizeForWidthAndLines which calls
base::JoinString and then ultimately basic_string<>::append and memmove.
Inspection of the stack and the generated code shows that
base::JoinString is called correctly but that base::JoinString (or the
inlined JoinStringT and three other levels of inlining) fail to read
separator off the stack correctly - they read it from an address that is
four bytes too early. This leads to copying too many bytes from the
wrong address.

Fully disabling optimizations in VC++ builds for the affected function
seems like the right fix. If time permits then a reduction and VC++ bug
will be created. However if this is a PGO-only bug then...

Bug: 804884
Change-Id: I80fd8e693a35b26a386cd99a1b17c54bede95d5c
Reviewed-on: https://chromium-review.googlesource.com/891569Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532658}
parent 9d4bba6e
...@@ -936,6 +936,11 @@ char16* WriteInto(string16* str, size_t length_with_null) { ...@@ -936,6 +936,11 @@ char16* WriteInto(string16* str, size_t length_with_null) {
return WriteIntoT(str, length_with_null); return WriteIntoT(str, length_with_null);
} }
#if defined(_MSC_VER) && !defined(__clang__)
// Work around VC++ code-gen bug. https://crbug.com/804884
#pragma optimize("", off)
#endif
// Generic version for all JoinString overloads. |list_type| must be a sequence // Generic version for all JoinString overloads. |list_type| must be a sequence
// (std::vector or std::initializer_list) of strings/StringPieces (std::string, // (std::vector or std::initializer_list) of strings/StringPieces (std::string,
// string16, StringPiece or StringPiece16). |string_type| is either std::string // string16, StringPiece or StringPiece16). |string_type| is either std::string
...@@ -983,6 +988,11 @@ string16 JoinString(const std::vector<string16>& parts, ...@@ -983,6 +988,11 @@ string16 JoinString(const std::vector<string16>& parts,
return JoinStringT(parts, separator); return JoinStringT(parts, separator);
} }
#if defined(_MSC_VER) && !defined(__clang__)
// Work around VC++ code-gen bug. https://crbug.com/804884
#pragma optimize("", on)
#endif
std::string JoinString(const std::vector<StringPiece>& parts, std::string JoinString(const std::vector<StringPiece>& parts,
StringPiece separator) { StringPiece separator) {
return JoinStringT(parts, separator); return JoinStringT(parts, separator);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment