summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2018-05-20 15:37:12 -0700
committerKhem Raj <raj.khem@gmail.com>2018-07-06 10:17:50 -0700
commit29b53f86d9a581c08ff2898caa7ee4d5d214deb5 (patch)
treebe5c578bac6b2f0b483f60c0598649f2a812f91d
parent357d498581bdddd608f5b036f7ccc37b8e78f299 (diff)
downloadmeta-clang-29b53f86d9a581c08ff2898caa7ee4d5d214deb5.tar.gz
clang: Fix driver segfault with very long commandline
This is triggerred with webkit linking commands Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--recipes-devtools/clang/clang/0009-clang-Driver-Avoid-invalidated-iterator-in-insertTar.patch56
-rw-r--r--recipes-devtools/clang/common.inc1
2 files changed, 57 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0009-clang-Driver-Avoid-invalidated-iterator-in-insertTar.patch b/recipes-devtools/clang/clang/0009-clang-Driver-Avoid-invalidated-iterator-in-insertTar.patch
new file mode 100644
index 0000000..2f7b921
--- /dev/null
+++ b/recipes-devtools/clang/clang/0009-clang-Driver-Avoid-invalidated-iterator-in-insertTar.patch
@@ -0,0 +1,56 @@
1From 19c832f5017f796012812414705f8d57e77b28ce Mon Sep 17 00:00:00 2001
2From: Serge Pavlov <sepavloff@gmail.com>
3Date: Mon, 19 Mar 2018 16:13:43 +0000
4Subject: [PATCH 9/9] clang: [Driver] Avoid invalidated iterator in
5 insertTargetAndModeArgs
6
7Doing an .insert() can potentially invalidate iterators by reallocating the
8vector's storage. When all the stars align just right, this causes segfaults
9or glibc aborts.
10
11Gentoo Linux bug (crashes while building Chromium): https://bugs.gentoo.org/650082.
12
13Patch by Hector Martin!
14
15Differential Revision: https://reviews.llvm.org/D44607
16
17git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327863 91177308-0d34-0410-b5e6-96231b3b80d8
18---
19Upstream-Status: Backport
20
21 tools/driver/driver.cpp | 9 +++++----
22 1 file changed, 5 insertions(+), 4 deletions(-)
23
24diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
25index fa757da953..1b614accb2 100644
26--- a/tools/driver/driver.cpp
27+++ b/tools/driver/driver.cpp
28@@ -212,20 +212,21 @@ static void insertTargetAndModeArgs(const ParsedClangName &NameParts,
29 // Put target and mode arguments at the start of argument list so that
30 // arguments specified in command line could override them. Avoid putting
31 // them at index 0, as an option like '-cc1' must remain the first.
32- auto InsertionPoint = ArgVector.begin();
33- if (InsertionPoint != ArgVector.end())
34+ int InsertionPoint = 0;
35+ if (ArgVector.size() > 0)
36 ++InsertionPoint;
37
38 if (NameParts.DriverMode) {
39 // Add the mode flag to the arguments.
40- ArgVector.insert(InsertionPoint,
41+ ArgVector.insert(ArgVector.begin() + InsertionPoint,
42 GetStableCStr(SavedStrings, NameParts.DriverMode));
43 }
44
45 if (NameParts.TargetIsValid) {
46 const char *arr[] = {"-target", GetStableCStr(SavedStrings,
47 NameParts.TargetPrefix)};
48- ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr));
49+ ArgVector.insert(ArgVector.begin() + InsertionPoint,
50+ std::begin(arr), std::end(arr));
51 }
52 }
53
54--
552.17.0
56
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc
index 6ed40be..b3f5cdd 100644
--- a/recipes-devtools/clang/common.inc
+++ b/recipes-devtools/clang/common.inc
@@ -19,6 +19,7 @@ CLANGPATCHES = "\
19 file://0006-clang-Define-releative-gcc-installation-dir.patch;patchdir=tools/clang \ 19 file://0006-clang-Define-releative-gcc-installation-dir.patch;patchdir=tools/clang \
20 file://0007-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch;patchdir=tools/clang \ 20 file://0007-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch;patchdir=tools/clang \
21 file://0008-clang-scan-view-needs-python-2.x.patch;patchdir=tools/clang \ 21 file://0008-clang-scan-view-needs-python-2.x.patch;patchdir=tools/clang \
22 file://0009-clang-Driver-Avoid-invalidated-iterator-in-insertTar.patch;patchdir=tools/clang \
22" 23"
23#CLANGPATCHES += "${@'file://0007-clang-Enable-SSP-and-PIE-by-default.patch;patchdir=tools/clang' if '${GCCPIE}' else ''}" 24#CLANGPATCHES += "${@'file://0007-clang-Enable-SSP-and-PIE-by-default.patch;patchdir=tools/clang' if '${GCCPIE}' else ''}"
24 25