summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2018-03-20 21:19:44 +0100
committerMichał Górny <mgorny@gentoo.org>2018-03-20 23:13:13 +0100
commite461935372c17b9715f87b6ce16620046d465add (patch)
tree05df6ebeba996cab5cbda138e0a160755a9e4f63 /sys-devel
parentnet-misc/curl-7.59.0: arm64 stable (bug #650056) (diff)
downloadgentoo-e461935372c17b9715f87b6ce16620046d465add.tar.gz
gentoo-e461935372c17b9715f87b6ce16620046d465add.tar.bz2
gentoo-e461935372c17b9715f87b6ce16620046d465add.zip
sys-devel/clang: Backport fix for crash with long cmdline to 6.0.0
Closes: https://bugs.gentoo.org/650082
Diffstat (limited to 'sys-devel')
-rw-r--r--sys-devel/clang/clang-6.0.0-r1.ebuild (renamed from sys-devel/clang/clang-6.0.0.ebuild)4
-rw-r--r--sys-devel/clang/files/6.0.0/0001-Driver-Avoid-invalidated-iterator-in-insertTargetAnd.patch55
2 files changed, 59 insertions, 0 deletions
diff --git a/sys-devel/clang/clang-6.0.0.ebuild b/sys-devel/clang/clang-6.0.0-r1.ebuild
index e819506ad558..c001fef8e411 100644
--- a/sys-devel/clang/clang-6.0.0.ebuild
+++ b/sys-devel/clang/clang-6.0.0-r1.ebuild
@@ -70,6 +70,10 @@ CMAKE_BUILD_TYPE=RelWithDebInfo
PATCHES=(
# add Prefix include paths for Darwin
"${FILESDIR}"/5.0.1/darwin_prefix-include-paths.patch
+
+ # fix Driver crash with CHOST prefix and long command-line
+ # https://bugs.gentoo.org/650082
+ "${FILESDIR}"/6.0.0/0001-Driver-Avoid-invalidated-iterator-in-insertTargetAnd.patch
)
# Multilib notes:
diff --git a/sys-devel/clang/files/6.0.0/0001-Driver-Avoid-invalidated-iterator-in-insertTargetAnd.patch b/sys-devel/clang/files/6.0.0/0001-Driver-Avoid-invalidated-iterator-in-insertTargetAnd.patch
new file mode 100644
index 000000000000..20ba89bf126b
--- /dev/null
+++ b/sys-devel/clang/files/6.0.0/0001-Driver-Avoid-invalidated-iterator-in-insertTargetAnd.patch
@@ -0,0 +1,55 @@
+From 99418eabfbe5378d7a751444856c6c5c656519c4 Mon Sep 17 00:00:00 2001
+From: Serge Pavlov <sepavloff@gmail.com>
+Date: Mon, 19 Mar 2018 16:13:43 +0000
+Subject: [PATCH 1/2] [Driver] Avoid invalidated iterator in
+ insertTargetAndModeArgs
+
+Doing an .insert() can potentially invalidate iterators by reallocating the
+vector's storage. When all the stars align just right, this causes segfaults
+or glibc aborts.
+
+Gentoo Linux bug (crashes while building Chromium): https://bugs.gentoo.org/650082.
+
+Patch by Hector Martin!
+
+Differential Revision: https://reviews.llvm.org/D44607
+
+
+git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327863 91177308-0d34-0410-b5e6-96231b3b80d8
+---
+ tools/driver/driver.cpp | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
+index fa757da953..1b614accb2 100644
+--- a/tools/driver/driver.cpp
++++ b/tools/driver/driver.cpp
+@@ -212,20 +212,21 @@ static void insertTargetAndModeArgs(const ParsedClangName &NameParts,
+ // Put target and mode arguments at the start of argument list so that
+ // arguments specified in command line could override them. Avoid putting
+ // them at index 0, as an option like '-cc1' must remain the first.
+- auto InsertionPoint = ArgVector.begin();
+- if (InsertionPoint != ArgVector.end())
++ int InsertionPoint = 0;
++ if (ArgVector.size() > 0)
+ ++InsertionPoint;
+
+ if (NameParts.DriverMode) {
+ // Add the mode flag to the arguments.
+- ArgVector.insert(InsertionPoint,
++ ArgVector.insert(ArgVector.begin() + InsertionPoint,
+ GetStableCStr(SavedStrings, NameParts.DriverMode));
+ }
+
+ if (NameParts.TargetIsValid) {
+ const char *arr[] = {"-target", GetStableCStr(SavedStrings,
+ NameParts.TargetPrefix)};
+- ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr));
++ ArgVector.insert(ArgVector.begin() + InsertionPoint,
++ std::begin(arr), std::end(arr));
+ }
+ }
+
+--
+2.16.2
+