public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gcc-patches:master commit in: 12.2.0/gentoo/
Date: Mon, 23 Jan 2023 00:35:27 +0000 (UTC)	[thread overview]
Message-ID: <1674434120.d3c10f4c409a3b6c07c453af289c5e23420156f1.sam@gentoo> (raw)

commit:     d3c10f4c409a3b6c07c453af289c5e23420156f1
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 23 00:23:09 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jan 23 00:35:20 2023 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=d3c10f4c

12.2.0: backport driver environ corruption fix

Bug: https://bugs.gentoo.org/885501
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../76_all_driver_environ_putenv_PR106624.patch    | 44 ++++++++++++++++++++++
 12.2.0/gentoo/README.history                       |  3 ++
 2 files changed, 47 insertions(+)

diff --git a/12.2.0/gentoo/76_all_driver_environ_putenv_PR106624.patch b/12.2.0/gentoo/76_all_driver_environ_putenv_PR106624.patch
new file mode 100644
index 0000000..16fb131
--- /dev/null
+++ b/12.2.0/gentoo/76_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.cc (driver::detect_jobserver): Allocate storage xputenv()
+	argument using xstrdup().
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -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/12.2.0/gentoo/README.history b/12.2.0/gentoo/README.history
index d71d136..e3e0bf4 100644
--- a/12.2.0/gentoo/README.history
+++ b/12.2.0/gentoo/README.history
@@ -1,3 +1,6 @@
+10		23 Jan 2022
+	+ 76_all_driver_environ_putenv_PR106624.patch
+
 9		8 Jan 2022
 	- 76_all_libsanitizer-implicit-function-decls.patch
 	- 77_all_libiberty-fix-c89-isms-in-configure.patch


             reply	other threads:[~2023-01-23  0:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-23  0:35 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-04-23  2:41 [gentoo-commits] proj/gcc-patches:master commit in: 12.2.0/gentoo/ Sam James
2023-03-13 22:28 Sam James
2023-02-12  2:39 Sam James
2023-02-06 18:36 Sam James
2023-02-06 17:40 Sam James
2023-01-29  8:50 Sam James
2023-01-08  4:46 Sam James
2022-12-28 19:35 Sam James
2022-12-26  8:06 Sam James
2022-12-17  4:54 Sam James
2022-12-09 11:24 Sam James
2022-12-05  0:27 Sam James
2022-12-05  0:18 Andreas K. Hüttel
2022-11-20  0:25 Sam James
2022-08-22  1:41 Sam James
2022-08-22  1:41 Sam James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1674434120.d3c10f4c409a3b6c07c453af289c5e23420156f1.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox