[Bug driver/106624] [13 Regression] LTO plugin fails to build in parallel builds: xgcc: fatal error: cannot execute '/build/build/./prev-gcc/collect2': execv: Bad address since r13-2011-g53e3b2bf16a486

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 24 10:53:43 GMT 2023


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106624

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Martin Liska
<marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:9d21cc4edd94f8f2b1a3241fab5cf75649003226

commit r11-10479-g9d21cc4edd94f8f2b1a3241fab5cf75649003226
Author: Sergei Trofimovich <siarheit@google.com>
Date:   Tue Aug 16 12:35:07 2022 +0100

    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().

    (cherry picked from commit 2b403297b111c990c331b5bbb6165b061ad2259b)


More information about the Gcc-bugs mailing list