diff options
author | Khem Raj <raj.khem@gmail.com> | 2018-05-20 15:37:12 -0700 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2018-05-20 15:37:12 -0700 |
commit | dd5d611b0d6763c0a625c1315fb873cd28a50158 (patch) | |
tree | 05b36488a67b24c3f37ea8e3ae84eaa9d57ed1e3 | |
parent | 6791d4931106e7206bdd09670621f22fea42730f (diff) | |
download | meta-clang-dd5d611b0d6763c0a625c1315fb873cd28a50158.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.patch | 56 | ||||
-rw-r--r-- | recipes-devtools/clang/common.inc | 1 |
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 @@ | |||
1 | From 19c832f5017f796012812414705f8d57e77b28ce Mon Sep 17 00:00:00 2001 | ||
2 | From: Serge Pavlov <sepavloff@gmail.com> | ||
3 | Date: Mon, 19 Mar 2018 16:13:43 +0000 | ||
4 | Subject: [PATCH 9/9] clang: [Driver] Avoid invalidated iterator in | ||
5 | insertTargetAndModeArgs | ||
6 | |||
7 | Doing an .insert() can potentially invalidate iterators by reallocating the | ||
8 | vector's storage. When all the stars align just right, this causes segfaults | ||
9 | or glibc aborts. | ||
10 | |||
11 | Gentoo Linux bug (crashes while building Chromium): https://bugs.gentoo.org/650082. | ||
12 | |||
13 | Patch by Hector Martin! | ||
14 | |||
15 | Differential Revision: https://reviews.llvm.org/D44607 | ||
16 | |||
17 | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327863 91177308-0d34-0410-b5e6-96231b3b80d8 | ||
18 | --- | ||
19 | Upstream-Status: Backport | ||
20 | |||
21 | tools/driver/driver.cpp | 9 +++++---- | ||
22 | 1 file changed, 5 insertions(+), 4 deletions(-) | ||
23 | |||
24 | diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp | ||
25 | index 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 | -- | ||
55 | 2.17.0 | ||
56 | |||
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc index e1543f0..7936405 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 | ||