bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 4.3.90 release candidate segfaults on linux and solaris


From: Denis Excoffier
Subject: Re: 4.3.90 release candidate segfaults on linux and solaris
Date: Mon, 26 Sep 2022 17:59:38 +0200


> On 2022-09-25 16:25, Dmitry Goncharov wrote:
> 
> On Sun, Sep 25, 2022 at 2:09 AM Martin Dorey
> <Martin.Dorey@hitachivantara.com> wrote:
>> And vfork is where that happens.  If I’ve followed the thicket of #ifdef 
>> correctly and understood the vfork man page, then this is illegal when using 
>> vfork:
>> 
>> https://github.com/mirror/make/blob/master/src/job.c#L2556
> 
> 
> Thanks, Martin.
> This is indeed the culprit.
> I was able to find a linux where this reproduces. However, the this
> does this reproduce on my sun. Denis, can you please try this patch on
> your sun?
> 
> regards, Dmitry
> 
> Here is a patch
> 
> index d12a9138..1ed71f0a 100644
> --- a/src/job.c
> +++ b/src/job.c
> @@ -2286,6 +2286,8 @@ child_execute_job (struct childbase *child, int
> good_stdin, char **argv)
>   posix_spawnattr_t attr;
>   posix_spawn_file_actions_t fa;
>   short flags = 0;
> +#else
> +  char **parent_environ = environ;
> #endif
> 
>   /* Divert child output if we want to capture it.  */
> @@ -2301,7 +2303,12 @@ child_execute_job (struct childbase *child, int
> good_stdin, char **argv)
> 
>   pid = vfork();
>   if (pid != 0)
> +    {
> +      /* The child sets environ to child->environment before calling execvp.
> +       * Restore it here.  */
> +      environ = parent_environ;
>       return pid;
> +    }
> 
>   /* We are the child.  */
>   unblock_all_sigs ();
> @@ -2552,7 +2559,8 @@ exec_command (char **argv, char **envp)
>     errno = ENOEXEC;
> 
> # else
> -  /* Run the program.  */
> +  /* Run the program.
> +   * The parent has to restore environ.  */
>   environ = envp;
>   execvp (argv[0], argv);

Hello,
This patch works perfectly, both on my 32bit linux and my 32bit solaris 10.
Thank you.
Regards,
Denis Excoffier.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]