Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/clang/files/6.0.0/, sys-devel/clang/
Date: Tue, 20 Mar 2018 22:13:33
Message-Id: 1521583993.e461935372c17b9715f87b6ce16620046d465add.mgorny@gentoo
1 commit: e461935372c17b9715f87b6ce16620046d465add
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Tue Mar 20 20:19:44 2018 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue Mar 20 22:13:13 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e4619353
7
8 sys-devel/clang: Backport fix for crash with long cmdline to 6.0.0
9
10 Closes: https://bugs.gentoo.org/650082
11
12 .../{clang-6.0.0.ebuild => clang-6.0.0-r1.ebuild} | 4 ++
13 ...d-invalidated-iterator-in-insertTargetAnd.patch | 55 ++++++++++++++++++++++
14 2 files changed, 59 insertions(+)
15
16 diff --git a/sys-devel/clang/clang-6.0.0.ebuild b/sys-devel/clang/clang-6.0.0-r1.ebuild
17 similarity index 98%
18 rename from sys-devel/clang/clang-6.0.0.ebuild
19 rename to sys-devel/clang/clang-6.0.0-r1.ebuild
20 index e819506ad55..c001fef8e41 100644
21 --- a/sys-devel/clang/clang-6.0.0.ebuild
22 +++ b/sys-devel/clang/clang-6.0.0-r1.ebuild
23 @@ -70,6 +70,10 @@ CMAKE_BUILD_TYPE=RelWithDebInfo
24 PATCHES=(
25 # add Prefix include paths for Darwin
26 "${FILESDIR}"/5.0.1/darwin_prefix-include-paths.patch
27 +
28 + # fix Driver crash with CHOST prefix and long command-line
29 + # https://bugs.gentoo.org/650082
30 + "${FILESDIR}"/6.0.0/0001-Driver-Avoid-invalidated-iterator-in-insertTargetAnd.patch
31 )
32
33 # Multilib notes:
34
35 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
36 new file mode 100644
37 index 00000000000..20ba89bf126
38 --- /dev/null
39 +++ b/sys-devel/clang/files/6.0.0/0001-Driver-Avoid-invalidated-iterator-in-insertTargetAnd.patch
40 @@ -0,0 +1,55 @@
41 +From 99418eabfbe5378d7a751444856c6c5c656519c4 Mon Sep 17 00:00:00 2001
42 +From: Serge Pavlov <sepavloff@×××××.com>
43 +Date: Mon, 19 Mar 2018 16:13:43 +0000
44 +Subject: [PATCH 1/2] [Driver] Avoid invalidated iterator in
45 + insertTargetAndModeArgs
46 +
47 +Doing an .insert() can potentially invalidate iterators by reallocating the
48 +vector's storage. When all the stars align just right, this causes segfaults
49 +or glibc aborts.
50 +
51 +Gentoo Linux bug (crashes while building Chromium): https://bugs.gentoo.org/650082.
52 +
53 +Patch by Hector Martin!
54 +
55 +Differential Revision: https://reviews.llvm.org/D44607
56 +
57 +
58 +git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327863 91177308-0d34-0410-b5e6-96231b3b80d8
59 +---
60 + tools/driver/driver.cpp | 9 +++++----
61 + 1 file changed, 5 insertions(+), 4 deletions(-)
62 +
63 +diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
64 +index fa757da953..1b614accb2 100644
65 +--- a/tools/driver/driver.cpp
66 ++++ b/tools/driver/driver.cpp
67 +@@ -212,20 +212,21 @@ static void insertTargetAndModeArgs(const ParsedClangName &NameParts,
68 + // Put target and mode arguments at the start of argument list so that
69 + // arguments specified in command line could override them. Avoid putting
70 + // them at index 0, as an option like '-cc1' must remain the first.
71 +- auto InsertionPoint = ArgVector.begin();
72 +- if (InsertionPoint != ArgVector.end())
73 ++ int InsertionPoint = 0;
74 ++ if (ArgVector.size() > 0)
75 + ++InsertionPoint;
76 +
77 + if (NameParts.DriverMode) {
78 + // Add the mode flag to the arguments.
79 +- ArgVector.insert(InsertionPoint,
80 ++ ArgVector.insert(ArgVector.begin() + InsertionPoint,
81 + GetStableCStr(SavedStrings, NameParts.DriverMode));
82 + }
83 +
84 + if (NameParts.TargetIsValid) {
85 + const char *arr[] = {"-target", GetStableCStr(SavedStrings,
86 + NameParts.TargetPrefix)};
87 +- ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr));
88 ++ ArgVector.insert(ArgVector.begin() + InsertionPoint,
89 ++ std::begin(arr), std::end(arr));
90 + }
91 + }
92 +
93 +--
94 +2.16.2
95 +