bugmake - Bugs: bug #57242, Non-recursive command passes...

 
 

bug #57242: Non-recursive command passes invalid jobserver file descriptors

Submitted by:  Stefan Brüns <stefanbruens>
Submitted on:  Fri 15 Nov 2019 07:41:39 PM UTC  
 
Severity:  3 - Normal Item Group:  Bug
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  4.2.1 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 20 Nov 2019 08:22:52 AM UTC, comment #3: 

I fully agree with Stafan that MAKEFLAGS should be aligned with jobserver FDs.
My impression is that a much better approach would be the usage of named pipes instead of file descriptors. I would consider the process relying on fixed file descriptor numbers as a bad practice.

Martin Liška <marxin>
Tue 19 Nov 2019 10:24:27 PM UTC, comment #2: 

comment #1:

> Stefan, the behavior you described is intended.
> make closes the pipe unless the command has + or (MAKE) or {MAKE}.
> This is necessary, because a command can mess up job server operation or a command may expect a specific fd to be available.


Then at least the information should be consistent and the MAKEFLAGS should not mention jobserver FDs.

As is, it already messes up make itself - a make process invocated indirectly may get valid filedescriptors not belonging to the jobserver, and start busy looping on the "read(rfd, 1)" call (when the other end is closed and read returns 0).

Stefan Brüns <stefanbruens>
Tue 19 Nov 2019 09:58:28 PM UTC, comment #1: 

Stefan, the behavior you described is intended.
make closes the pipe unless the command has + or (MAKE) or {MAKE}.
This is necessary, because a command can mess up job server operation or a command may expect a specific fd to be available.

Dmitry Goncharov <dgoncharov>
Fri 15 Nov 2019 07:41:39 PM UTC, original submission:  

The problem can be reproduced using the following trivial
Makefile:
---
all:
    env | grep FLAGS
---

Using strace to get some diagnostics:
$> env -i strace -epipe,dup2,execve,fcntl -v -f -o nonrecursive.txt  /usr/bin/make -j2 -f  Makefile

Obivously, the jobserver file descriptors (3,4) are closed on exec by fcntl({3,4}, F_SETFD, FD_CLOEXEC), but are still exported via MFLAGS/MAKEFLAGS=--jobserver-auth=3,4.

When the "env | grep FLAGS" command is invoked via shell, the shell creates a new pipe, reusing the no longer used file descriptors 3 and 4.

I.e. "env" (which serves as a placeholder here for some command implementing the jobserver protocol) receives some file descriptors which are no jobserver fds.

This does not happen when the command is marked as a recursive one (using the '+' marker), but this is non-trivial to achieve in practice:

1. the Makefile may come from some generator
2. the command itself may be some script invoking "gmake" again.

Stefan Brüns <stefanbruens>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by marxin (Posted a comment)
  • -email is unavailable- added by dgoncharov (Posted a comment)
  • -email is unavailable- added by stefanbruens
  • -email is unavailable- added by stefanbruens (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-11-15 stefanbruens Carbon-Copy- => Added marxin

    Back to the top


    Powered by Savane 3.5