diff options
author | Sergei Trofimovich <siarheit@google.com> | 2022-08-16 12:35:07 +0100 |
---|---|---|
committer | Sergei Trofimovich <siarheit@google.com> | 2022-08-16 13:15:46 +0100 |
commit | 2b403297b111c990c331b5bbb6165b061ad2259b (patch) | |
tree | 92d3fffabf3332891535c3a5257aba0126f17405 /libcpp | |
parent | 6e790ca4615443fa395ac5cdba1ab6c87810985c (diff) | |
download | gcc-2b403297b111c990c331b5bbb6165b061ad2259b.zip gcc-2b403297b111c990c331b5bbb6165b061ad2259b.tar.gz gcc-2b403297b111c990c331b5bbb6165b061ad2259b.tar.bz2 |
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().
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions