summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2019-01-24 14:57:32 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-26 13:39:37 +0000
commitbb97a087e98697ee8dafa27ad5eb9b3d50f18387 (patch)
tree683c00cc24f8e1d93ec2972d0ac1ccc82a7f97fb /meta
parentf3b6a6e4ee41d466646866dfcd544b386cb499b9 (diff)
downloadpoky-bb97a087e98697ee8dafa27ad5eb9b3d50f18387.tar.gz
ccache: Fix Segmentation fault error when gcc -o /dev/null
Fixed: $ export CCACHE_DEBUG=1 $ ccache gcc -c hello.c -o /dev/null Segmentation fault (core dumped) This is because failed to open /dev/null.foo (Permission denied), check file stream before write to it can fix the problem. (From OE-Core rev: 78a24b3a1eae04e5f4744f320e4ccbb8bfe17b9a) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/ccache/ccache_3.6.bb1
-rw-r--r--meta/recipes-devtools/ccache/files/0003-Fix-Segmentation-fault-error-when-gcc-o-dev-null.patch79
2 files changed, 80 insertions, 0 deletions
diff --git a/meta/recipes-devtools/ccache/ccache_3.6.bb b/meta/recipes-devtools/ccache/ccache_3.6.bb
index a12306e9a5..60807be0ae 100644
--- a/meta/recipes-devtools/ccache/ccache_3.6.bb
+++ b/meta/recipes-devtools/ccache/ccache_3.6.bb
@@ -8,4 +8,5 @@ SRC_URI[sha256sum] = "a3f2b91a2353b65a863c5901251efe48060ecdebec46b5eaec8ea8e092
8 8
9SRC_URI += " \ 9SRC_URI += " \
10 file://0002-dev.mk.in-fix-file-name-too-long.patch \ 10 file://0002-dev.mk.in-fix-file-name-too-long.patch \
11 file://0003-Fix-Segmentation-fault-error-when-gcc-o-dev-null.patch \
11" 12"
diff --git a/meta/recipes-devtools/ccache/files/0003-Fix-Segmentation-fault-error-when-gcc-o-dev-null.patch b/meta/recipes-devtools/ccache/files/0003-Fix-Segmentation-fault-error-when-gcc-o-dev-null.patch
new file mode 100644
index 0000000000..b3012b7e89
--- /dev/null
+++ b/meta/recipes-devtools/ccache/files/0003-Fix-Segmentation-fault-error-when-gcc-o-dev-null.patch
@@ -0,0 +1,79 @@
1From c51b63758e95247e3c1e2f06e5f5bfb49849e66d Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Tue, 22 Jan 2019 16:30:52 +0800
4Subject: [PATCH] Fix Segmentation fault error when gcc -o /dev/null
5
6Fixed:
7$ export CCACHE_DEBUG=1
8$ ccache gcc -c hello.c -o /dev/null
9
10Segmentation fault (core dumped)
11
12This is because failed to open /dev/null.foo (Permission denied), check file
13stream before write to it can fix the problem.
14
15Upstream-Status: Backport [https://github.com/ccache/ccache/commit/4d86e884d07ba1853a0c70507cc4d04107f57c29]
16
17Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
18---
19 src/ccache.c | 15 ++++++++++++---
20 src/util.c | 8 ++++++--
21 2 files changed, 18 insertions(+), 5 deletions(-)
22
23diff --git a/src/ccache.c b/src/ccache.c
24index b4cdb86..8c227df 100644
25--- a/src/ccache.c
26+++ b/src/ccache.c
27@@ -521,9 +521,13 @@ init_hash_debug(struct hash *hash, const char *obj_path, char type,
28
29 char *path = format("%s.ccache-input-%c", obj_path, type);
30 FILE *debug_binary_file = fopen(path, "wb");
31- hash_enable_debug(hash, section_name, debug_binary_file, debug_text_file);
32+ if (debug_binary_file) {
33+ hash_enable_debug(hash, section_name, debug_binary_file, debug_text_file);
34+ exitfn_add(fclose_exitfn, debug_binary_file);
35+ } else {
36+ cc_log("Failed to open %s: %s", path, strerror(errno));
37+ }
38 free(path);
39- exitfn_add(fclose_exitfn, debug_binary_file);
40 }
41
42 static enum guessed_compiler
43@@ -3670,8 +3674,13 @@ ccache(int argc, char *argv[])
44 if (conf->debug) {
45 char *path = format("%s.ccache-input-text", output_obj);
46 debug_text_file = fopen(path, "w");
47+ if (debug_text_file) {
48+ exitfn_add(fclose_exitfn, debug_text_file);
49+ }
50+ else {
51+ cc_log("Failed to open %s: %s", path, strerror(errno));
52+ }
53 free(path);
54- exitfn_add(fclose_exitfn, debug_text_file);
55 }
56
57 struct hash *common_hash = hash_init();
58diff --git a/src/util.c b/src/util.c
59index e442cc4..a49fb4c 100644
60--- a/src/util.c
61+++ b/src/util.c
62@@ -219,8 +219,12 @@ void
63 cc_dump_log_buffer(const char *path)
64 {
65 FILE *file = fopen(path, "w");
66- (void) fwrite(logbuffer, 1, logsize, file);
67- fclose(file);
68+ if (file) {
69+ (void) fwrite(logbuffer, 1, logsize, file);
70+ fclose(file);
71+ } else {
72+ cc_log("Failed to open %s: %s", path, strerror(errno));
73+ }
74 }
75
76 // Something went badly wrong!
77--
782.7.4
79