Commit 832c74d9 by Nathan Sidwell Committed by Nathan Sidwell

[libiberty patch] Fix PGO bootstrap

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01386.html
	PR driver/87056
	* pex-unix.c (pex_unix_exec_child): Duplicate bad_fn into local
	scopes to avoid potential clobber.

Co-Authored-By: Martin Liska <mliska@suse.cz>

From-SVN: r263807
parent ebdb6f23
2018-08-23 Nathan Sidwell <nathan@acm.org>
Martin Liska <mliska@suse.cz>
PR driver/87056
* pex-unix.c (pex_unix_exec_child): Duplicate bad_fn into local
scopes to avoid potential clobber.
2018-08-20 Nathan Sidwell <nathan@acm.org> 2018-08-20 Nathan Sidwell <nathan@acm.org>
* pex-unix.c (pex_child_error): Delete. * pex-unix.c (pex_child_error): Delete.
......
...@@ -582,8 +582,6 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable, ...@@ -582,8 +582,6 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
issues. */ issues. */
char **save_environ = environ; char **save_environ = environ;
const char *bad_fn = NULL;
for (retries = 0; retries < 4; ++retries) for (retries = 0; retries < 4; ++retries)
{ {
pid = vfork (); pid = vfork ();
...@@ -602,6 +600,9 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable, ...@@ -602,6 +600,9 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
case 0: case 0:
/* Child process. */ /* Child process. */
{
const char *bad_fn = NULL;
if (!bad_fn && in != STDIN_FILE_NO) if (!bad_fn && in != STDIN_FILE_NO)
{ {
if (dup2 (in, STDIN_FILE_NO) < 0) if (dup2 (in, STDIN_FILE_NO) < 0)
...@@ -654,9 +655,8 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable, ...@@ -654,9 +655,8 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
/* Something failed, report an error. We don't use stdio /* Something failed, report an error. We don't use stdio
routines, because we might be here due to a vfork call. */ routines, because we might be here due to a vfork call. */
{
ssize_t retval = 0; ssize_t retval = 0;
int err = errno; int eno = errno;
#define writeerr(s) (retval |= write (STDERR_FILE_NO, s, strlen (s))) #define writeerr(s) (retval |= write (STDERR_FILE_NO, s, strlen (s)))
writeerr (obj->pname); writeerr (obj->pname);
...@@ -665,7 +665,7 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable, ...@@ -665,7 +665,7 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
writeerr ("': "); writeerr ("': ");
writeerr (bad_fn); writeerr (bad_fn);
writeerr (": "); writeerr (": ");
writeerr (xstrerror (err)); writeerr (xstrerror (eno));
writeerr ("\n"); writeerr ("\n");
#undef writeerr #undef writeerr
...@@ -677,12 +677,14 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable, ...@@ -677,12 +677,14 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
default: default:
/* Parent process. */ /* Parent process. */
{
const char *bad_fn = NULL;
/* Restore environ. /* Restore environ. Note that the parent either doesn't run
Note that the parent either doesn't run until the child execs/exits until the child execs/exits (standard vfork behaviour), or
(standard vfork behaviour), or if it does run then vfork is behaving if it does run then vfork is behaving more like fork. In
more like fork. In either case we needn't worry about clobbering either case we needn't worry about clobbering the child's
the child's copy of environ. */ copy of environ. */
environ = save_environ; environ = save_environ;
if (!bad_fn && in != STDIN_FILE_NO) if (!bad_fn && in != STDIN_FILE_NO)
...@@ -701,6 +703,7 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable, ...@@ -701,6 +703,7 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
*errmsg = bad_fn; *errmsg = bad_fn;
return (pid_t) -1; return (pid_t) -1;
} }
}
return pid; return pid;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment