Skip to content

Don't close jobserver fd when executing external subcommand #10477

Closed
@trinity-1686a

Description

@trinity-1686a

Problem

I tried to use cargo-fuzz from a Makefile, expecting it to use make's jobserver to limit concurency.
When running it as cargo-fuzz, it worked as intended, but when running it as cargo fuzz, it did not seem to acknowledge make job count.
I found cargo-fuzz environment variables contained --jobserver-auth=3,4 as expected, but these file descriptors are closed.

Steps

  • create a script called cargo-sleep and put it into your $PATH
#!/bin/bash
sleep $2
  • write a simple Makefile calling this command with jobserver passing
all:
        +cargo sleep 10
  • run the makefile with jobserver
make -j2
  • look at the environment of sleep. It contains MAKEFLAGS= -j2 --jobserver-auth=3,4 (actual number may vary)
  • look at open file descriptors of sleep, 3 and 4 (in my case) are not open.

Possible Solution(s)

No response

Notes

As stated there is a simple workaround, calling the sub-command directly instead of through cargo

Version

cargo 1.59.0 (49d8809dc 2022-02-10)
release: 1.59.0
commit-hash: 49d8809dc2d3e6e0d5ec634fcf26d8e2aab67130
commit-date: 2022-02-10
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1l)
os: Arch Linux [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-custom-subcommandsArea: custom 3rd party subcommand pluginsA-jobserverArea: jobserver, concurrency, parallelismC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions