From b868df77e9cfc145334c3ae009d93fad587accf0 Mon Sep 17 00:00:00 2001 From: Tom spot Callaway Date: Wed, 24 Mar 2021 10:00:53 -0400 Subject: [PATCH] fix crashes with components/cast_* --- chromium-89-EnumTable-crash.patch | 71 +++++++++++++++++++++++++++++++ chromium.spec | 4 ++ 2 files changed, 75 insertions(+) create mode 100644 chromium-89-EnumTable-crash.patch diff --git a/chromium-89-EnumTable-crash.patch b/chromium-89-EnumTable-crash.patch new file mode 100644 index 00000000..89a50702 --- /dev/null +++ b/chromium-89-EnumTable-crash.patch @@ -0,0 +1,71 @@ +diff --git a/components/cast_channel/enum_table.h b/components/cast_channel/enum_table.h +index e3130c7..2ad16ea 100644 +--- a/components/cast_channel/enum_table.h ++++ b/components/cast_channel/enum_table.h +@@ -212,7 +212,7 @@ class + + template + friend class EnumTable; +- DISALLOW_COPY_AND_ASSIGN(GenericEnumTableEntry); ++ DISALLOW_ASSIGN(GenericEnumTableEntry); + }; + + // Yes, these constructors really needs to be inlined. Even though they look +@@ -250,8 +250,7 @@ class EnumTable { + // Constructor for regular entries. + constexpr Entry(E value, base::StringPiece str) + : GenericEnumTableEntry(static_cast(value), str) {} +- +- DISALLOW_COPY_AND_ASSIGN(Entry); ++ DISALLOW_ASSIGN(Entry); + }; + + static_assert(sizeof(E) <= sizeof(int32_t), +@@ -306,15 +305,14 @@ class EnumTable { + if (is_sorted_) { + const std::size_t index = static_cast(value); + if (ANALYZER_ASSUME_TRUE(index < data_.size())) { +- const auto& entry = data_.begin()[index]; ++ const auto& entry = data_[index]; + if (ANALYZER_ASSUME_TRUE(entry.has_str())) + return entry.str(); + } + return base::nullopt; + } + return GenericEnumTableEntry::FindByValue( +- reinterpret_cast(data_.begin()), +- data_.size(), static_cast(value)); ++ &data_[0], data_.size(), static_cast(value)); + } + + // This overload of GetString is designed for cases where the argument is a +@@ -342,8 +340,7 @@ class EnumTable { + // enum value directly. + base::Optional GetEnum(base::StringPiece str) const { + auto* entry = GenericEnumTableEntry::FindByString( +- reinterpret_cast(data_.begin()), +- data_.size(), str); ++ &data_[0], data_.size(), str); + return entry ? static_cast(entry->value) : base::Optional(); + } + +@@ -358,7 +355,7 @@ class EnumTable { + // Align the data on a cache line boundary. + alignas(64) + #endif +- std::initializer_list data_; ++ const std::vector data_; + bool is_sorted_; + + constexpr EnumTable(std::initializer_list data, bool is_sorted) +@@ -370,8 +367,8 @@ class EnumTable { + + for (std::size_t i = 0; i < data.size(); i++) { + for (std::size_t j = i + 1; j < data.size(); j++) { +- const Entry& ei = data.begin()[i]; +- const Entry& ej = data.begin()[j]; ++ const Entry& ei = data[i]; ++ const Entry& ej = data[j]; + DCHECK(ei.value != ej.value) + << "Found duplicate enum values at indices " << i << " and " << j; + DCHECK(!(ei.has_str() && ej.has_str() && ei.str() == ej.str())) diff --git a/chromium.spec b/chromium.spec index 796d95fd..3fd59356 100644 --- a/chromium.spec +++ b/chromium.spec @@ -306,6 +306,9 @@ Patch77: chromium-88.0.4324.182-gcc-fix-swiftshader-libEGL-visibility.patch Patch78: chromium-89.0.4389.82-support-futex_time64.patch # Do not download proprietary widevine module in the background (thanks Debian) Patch79: chromium-89.0.4389.82-widevine-no-download.patch +# Fix crashes with components/cast_* +# Thanks to Gentoo +Patch80: https://gitweb.gentoo.org/repo/gentoo.git/plain/www-client/chromium/files/chromium-89-EnumTable-crash.patch # Use lstdc++ on EPEL7 only @@ -931,6 +934,7 @@ udev. %patch77 -p1 -b .gcc-swiftshader-visibility %patch78 -p1 -b .futex-time64 %patch79 -p1 -b .widevine-no-download +%patch80 -p1 -b .EnumTable-crash # Fedora branded user agent %if 0%{?fedora}