aboutsummaryrefslogtreecommitdiff
path: root/11.4.0
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2023-01-23 00:27:56 +0000
committerSam James <sam@gentoo.org>2023-01-23 00:35:20 +0000
commit3efe77f935c0d12b9bcc869bca60669e12a0c0ad (patch)
treefad1e1abf8395fb00da6fb8343689dd9778c73a4 /11.4.0
parent11.4.0: drop 26_all_enable-cet.patch (bootstrapping issues with PGO/LTO?) (diff)
downloadgcc-patches-3efe77f935c0d12b9bcc869bca60669e12a0c0ad.tar.gz
gcc-patches-3efe77f935c0d12b9bcc869bca60669e12a0c0ad.tar.bz2
gcc-patches-3efe77f935c0d12b9bcc869bca60669e12a0c0ad.zip
11.4.0: backport driver environ corruption fix
Bug: https://bugs.gentoo.org/885501 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to '11.4.0')
-rw-r--r--11.4.0/gentoo/77_all_driver_environ_putenv_PR106624.patch44
-rw-r--r--11.4.0/gentoo/README.history3
2 files changed, 46 insertions, 1 deletions
diff --git a/11.4.0/gentoo/77_all_driver_environ_putenv_PR106624.patch b/11.4.0/gentoo/77_all_driver_environ_putenv_PR106624.patch
new file mode 100644
index 0000000..baad63a
--- /dev/null
+++ b/11.4.0/gentoo/77_all_driver_environ_putenv_PR106624.patch
@@ -0,0 +1,44 @@
+https://bugs.gentoo.org/885501
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106624
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=2b403297b111c990c331b5bbb6165b061ad2259b
+
+From 2b403297b111c990c331b5bbb6165b061ad2259b Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <siarheit@google.com>
+Date: Tue, 16 Aug 2022 12:35:07 +0100
+Subject: [PATCH 1/1] driver: fix environ corruption after putenv() [PR106624]
+
+The bug appeared afte r13-2010-g1270ccda70ca09 "Factor out
+jobserver_active_p" slightly changed `putenv()` use from allocating
+to non-allocating:
+
+ -xputenv (concat ("MAKEFLAGS=", dup, NULL));
+ +xputenv (jinfo.skipped_makeflags.c_str ());
+
+`xputenv()` (and `putenv()`) don't copy strings and only store the
+pointer in the `environ` global table. As a result `environ` got
+corrupted as soon as `jinfo.skipped_makeflags` store got deallocated.
+
+This started causing bootstrap crashes in `execv()` calls:
+
+ xgcc: fatal error: cannot execute '/build/build/./prev-gcc/collect2': execv: Bad address
+
+The change restores memory allocation for `xputenv()` argument.
+
+gcc/
+
+ PR driver/106624
+ * gcc.c (driver::detect_jobserver): Allocate storage xputenv()
+ argument using xstrdup().
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -9182,7 +9182,7 @@ driver::detect_jobserver () const
+ {
+ jobserver_info jinfo;
+ if (!jinfo.is_active && !jinfo.skipped_makeflags.empty ())
+- xputenv (jinfo.skipped_makeflags.c_str ());
++ xputenv (xstrdup (jinfo.skipped_makeflags.c_str ()));
+ }
+
+ /* Determine what the exit code of the driver should be. */
+--
+2.31.1
diff --git a/11.4.0/gentoo/README.history b/11.4.0/gentoo/README.history
index 1f5565d..bf891fa 100644
--- a/11.4.0/gentoo/README.history
+++ b/11.4.0/gentoo/README.history
@@ -1,5 +1,6 @@
-7 22 Jan 2022
+7 23 Jan 2022
- 26_all_enable-cet.patch
+ + 77_all_driver_environ_putenv_PR106624.patch
6 7 Jan 2022
- 77_all_configure-c89.patch