Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #83286

Closed
wants to merge 34 commits into from

Commits on Feb 21, 2021

  1. Configuration menu
    Copy the full SHA
    f45fe94 View commit details
    Browse the repository at this point in the history

Commits on Feb 24, 2021

  1. Configuration menu
    Copy the full SHA
    2cbea9f View commit details
    Browse the repository at this point in the history

Commits on Mar 4, 2021

  1. Configuration menu
    Copy the full SHA
    8c718bd View commit details
    Browse the repository at this point in the history

Commits on Mar 5, 2021

  1. Configuration menu
    Copy the full SHA
    0201e2b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a2571cf View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2021

  1. Configuration menu
    Copy the full SHA
    302867c View commit details
    Browse the repository at this point in the history

Commits on Mar 15, 2021

  1. Add Linux-specific pidfd process extensions

    Background:
    
    Over the last year, pidfd support was added to the Linux kernel. This
    allows interacting with other processes. In particular, this allows
    waiting on a child process with a timeout in a race-free way, bypassing
    all of the awful signal-handler tricks that are usually required.
    
    Pidfds can be obtained for a child process (as well as any other
    process) via the `pidfd_open` syscall. Unfortunately, this requires
    several conditions to hold in order to be race-free (i.e. the pid is not
    reused).
    Per `man pidfd_open`:
    
    ```
    · the disposition of SIGCHLD has not been explicitly set to SIG_IGN
     (see sigaction(2));
    
    · the SA_NOCLDWAIT flag was not specified while establishing a han‐
     dler for SIGCHLD or while setting the disposition of that signal to
     SIG_DFL (see sigaction(2)); and
    
    · the zombie process was not reaped elsewhere in the program (e.g.,
     either by an asynchronously executed signal handler or by wait(2)
     or similar in another thread).
    
    If any of these conditions does not hold, then the child process
    (along with a PID file descriptor that refers to it) should instead
    be created using clone(2) with the CLONE_PIDFD flag.
    ```
    
    Sadly, these conditions are impossible to guarantee once any libraries
    are used. For example, C code runnng in a different thread could call
    `wait()`, which is impossible to detect from Rust code trying to open a
    pidfd.
    
    While pid reuse issues should (hopefully) be rare in practice, we can do
    better. By passing the `CLONE_PIDFD` flag to `clone()` or `clone3()`, we
    can obtain a pidfd for the child process in a guaranteed race-free
    manner.
    
    This PR:
    
    This PR adds Linux-specific process extension methods to allow obtaining
    pidfds for processes spawned via the standard `Command` API. Other than
    being made available to user code, the standard library does not make
    use of these pidfds in any way. In particular, the implementation of
    `Child::wait` is completely unchanged.
    
    Two Linux-specific helper methods are added: `CommandExt::create_pidfd`
    and `ChildExt::pidfd`. These methods are intended to serve as a building
    block for libraries to build higher-level abstractions - in particular,
    waiting on a process with a timeout.
    
    I've included a basic test, which verifies that pidfds are created iff
    the `create_pidfd` method is used. This test is somewhat special - it
    should always succeed on systems with the `clone3` system call
    available, and always fail on systems without `clone3` available. I'm
    not sure how to best ensure this programatically.
    
    This PR relies on the newer `clone3` system call to pass the `CLONE_FD`,
    rather than the older `clone` system call. `clone3` was added to Linux
    in the same release as pidfds, so this shouldn't unnecessarily limit the
    kernel versions that this code supports.
    
    Unresolved questions:
    * What should the name of the feature gate be for these newly added
      methods?
    * Should the `pidfd` method distinguish between an error occurring
      and `create_pidfd` not being called?
    Aaron1011 authored and voidc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    5e788f2 View commit details
    Browse the repository at this point in the history
  2. Typo fix

    Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
    2 people authored and voidc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    3426bf7 View commit details
    Browse the repository at this point in the history
  3. Add PidFd type and seal traits

    Improve docs
    voidc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    704d6c5 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    766cc25 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d850f6b View commit details
    Browse the repository at this point in the history

Commits on Mar 16, 2021

  1. Fix test header and imports

    voidc committed Mar 16, 2021
    Configuration menu
    Copy the full SHA
    5ac8a31 View commit details
    Browse the repository at this point in the history
  2. Split do_fork into two

    voidc committed Mar 16, 2021
    Configuration menu
    Copy the full SHA
    a266bd8 View commit details
    Browse the repository at this point in the history
  3. use checkout@v2

    klensy committed Mar 16, 2021
    Configuration menu
    Copy the full SHA
    22f2548 View commit details
    Browse the repository at this point in the history
  4. Make do_fork unsafe

    voidc committed Mar 16, 2021
    Configuration menu
    Copy the full SHA
    cfb2d72 View commit details
    Browse the repository at this point in the history

Commits on Mar 17, 2021

  1. Move some test-only code to test files

    This also relaxes the bounds on some structs and moves them to the impl
    block instead.
    jyn514 committed Mar 17, 2021
    Configuration menu
    Copy the full SHA
    620ecc0 View commit details
    Browse the repository at this point in the history
  2. Fix gitattibutes for old git versions

    Jethro Beekman committed Mar 17, 2021
    Configuration menu
    Copy the full SHA
    b1de9d4 View commit details
    Browse the repository at this point in the history

Commits on Mar 18, 2021

  1. Configuration menu
    Copy the full SHA
    cfb4ad4 View commit details
    Browse the repository at this point in the history
  2. Extend proc_macro_back_compat lint to actix-web

    Unlike the other cases of this lint, there's no simple way to detect if
    an old version of the relevant crate (`syn`) is in use. The `actix-web`
    crate only depends on `pin-project` v1.0.0, so checking the version of
    `actix-web` does not guarantee that a new enough version of
    `pin-project` (and therefore `syn`) is in use.
    
    Instead, we rely on the fact that virtually all of the regressed crates
    are pinned to a pre-1.0 version of `pin-project`. When this is the case,
    bumping the `actix-web` dependency will pull in the *latest* version of
    `pin-project`, which has an explicit dependency on a newer v dependency
    on a newer version of `syn`.
    
    The lint message tells users to update `actix-web`, since that's what
    they're most likely to have control over. We could potentially tell them
    to run `cargo update -p syn`, but I think it's more straightforward to
    suggest an explicit change to the `Cargo.toml`
    
    The `actori-web` fork had its last commit over a year ago, and appears
    to just be a renamed fork of `actix-web`. Therefore, I've removed the
    `actori-web` check entirely - any crates that actually get broken can
    simply update `syn` themselves.
    Aaron1011 committed Mar 18, 2021
    Configuration menu
    Copy the full SHA
    390d1ef View commit details
    Browse the repository at this point in the history
  3. Fix typo/inaccuracy in the documentation of Iterator::skip_while

    One of the examples used to say “this leads to a possibly confusing situation,
    where the type of the closure is a double reference” while _actually_ referring to
    the type of the closure _argument_.
    steffahn committed Mar 18, 2021
    Configuration menu
    Copy the full SHA
    99b2054 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9dfda62 View commit details
    Browse the repository at this point in the history

Commits on Mar 19, 2021

  1. Configuration menu
    Copy the full SHA
    4238a8f View commit details
    Browse the repository at this point in the history
  2. Rollup merge of rust-lang#71780 - jcotton42:string_remove_matches, r=…

    …joshtriplett
    
    Implement String::remove_matches
    
    Closes rust-lang#50206.
    
    I lifted the function help from `@frewsxcv's` original PR (rust-lang#50015), hope they don't mind.
    
    I'm also wondering whether it would be useful for `remove_matches` to collect up the removed substrings into a `Vec` and return them, right now they're just overwritten by the copy and lost.
    Dylan-DPC authored Mar 19, 2021
    Configuration menu
    Copy the full SHA
    2523b66 View commit details
    Browse the repository at this point in the history
  3. Rollup merge of rust-lang#81825 - voidc:pidfd, r=joshtriplett

    Add Linux-specific pidfd process extensions (take 2)
    
    Continuation of rust-lang#77168.
    I addressed the following concerns from the original PR:
    
    - make `CommandExt` and `ChildExt` sealed traits
    - wrap file descriptors in `PidFd` struct representing ownership over the fd
    - add `take_pidfd` to take the fd out of `Child`
    - close fd when dropped
    
    Tracking Issue: rust-lang#82971
    Dylan-DPC authored Mar 19, 2021
    Configuration menu
    Copy the full SHA
    7c079e0 View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#82374 - clehner:licenses, r=joshtriplett

    Add license metadata for std dependencies
    
    These five crates are in the dependency tree of `std` but lack license metadata:
    - `alloc`
    - `core`
    - `panic_abort`
    - `panic_unwind`
    - `unwind`
    
    Querying the dependency tree of `std` is a useful thing to be able to do, since these crates will typically be linked into Rust binaries. Tools show the license fields missing, as seen in rust-lang#67014 (comment). This PR adds the license field for the five crates, based on the license of the `std` package and this repo as a whole. I also added the `repository` and `descriptions` fields, since those seem useful. For `description`, I copied text from top-level comments for the respective modules - except for `unwind` which has none.
    
    I also note that rust-lang#73530 attempted to add license metadata for all crates in this repo, but was rejected because there was question about some of them. I hope that this smaller change, focusing only on the runtime dependencies, will be easier to review.
    
    cc ``@Mark-Simulacrum`` ``@Lokathor``
    Dylan-DPC authored Mar 19, 2021
    Configuration menu
    Copy the full SHA
    ad8c628 View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#82500 - CDirkx:hermit-pipe, r=joshtriplett

    Reuse `std::sys::unsupported::pipe` on `hermit`
    
    Pipes are not supported on `hermit` and `hermit/pipe.rs` is identical to `unsupported/pipe.rs`. This PR reduces duplication between the two by doing the following on `hermit`:
    
    ```rust
    #[path = "../unsupported/pipe.rs"]
    pub mod pipe;
    ```
    Dylan-DPC authored Mar 19, 2021
    Configuration menu
    Copy the full SHA
    b567cd1 View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#82754 - rylev:rusage-windows, r=pnkfelix

    Attempt to gather similar stats as rusage on Windows
    
    A follow up to rust-lang#82532. This is a bit hacked in because I think we need to discuss this before merging, but this is an attempt to gather similar metrics as `libc::rusage` on Windows.
    
    Some comments on differences:
    * Currently, we're passing `RUSAGE_CHILDREN` to `rusage` which collects statistics on all children that have been waited on and terminated. I believe this is currently just the invocation of the real `rustc` that the shim is wrapping. Does `rustc` itself spawn children processes? The windows version gets the child processes handle when spawning it, and uses that to collect the statistics. For maxrss, `rusage` will return "the resident set size of the largest child, not the maximum resident set size of the process tree.", the Windows version will only collect statistics on the wrapped `rustc` child process directly even if some theoretical sub process has a larger memory footprint.
    * There might be subtle differences between `rusage`'s "resident set" and Window's "working set". The "working set" and "resident set" should both be the number of pages that are in memory and which would not cause a page fault when accessed.
    * I'm not yet sure how best to get the same information that `ru_minflt`, `ru_inblock`, `ru_oublock`, `ru_nivcsw ` and `ru_nvcsw` provide.
    
    r? ```@pnkfelix```
    Dylan-DPC authored Mar 19, 2021
    Configuration menu
    Copy the full SHA
    3ce28b6 View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#82759 - m-ou-se:remove-unwrap-none, r=petro…

    …chenkov
    
    Remove unwrap_none/expect_none from compiler/.
    
    We're not going to stabilize `Option::{unwrap_none, expect_none}`. (See rust-lang#62633.) This removes the usage of those unstable methods from `compiler/`.
    Dylan-DPC authored Mar 19, 2021
    Configuration menu
    Copy the full SHA
    25fc5f0 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#82892 - jix:clarify-read-read, r=joshtriplett

    Clarify docs for Read::read's return value
    
    Right now the docs for `Read::read`'s return value are phrased in a way that makes it easy for the reader to assume that the return value is never larger than the passed buffer. This PR clarifies that this is a requirement for implementations of the trait, but that callers have to expect a buggy yet safe implementation failing to do so, especially if unchecked accesses to the buffer are done afterwards.
    
    I fell into this trap recently, and when I noticed, I looked at the docs again and had the feeling that I might not have been the first one to miss this.
    
    The same issue of trusting the return value of `read` was also present in std itself for about 2.5 years and only fixed recently, see rust-lang#80895.
    
    I hope that clarifying the docs might help others to avoid this issue.
    Dylan-DPC authored Mar 19, 2021
    Configuration menu
    Copy the full SHA
    fc30f2b View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#83179 - Aaron1011:actix-web-lint, r=petroch…

    …enkov
    
    Extend `proc_macro_back_compat` lint to `actix-web`
    
    Unlike the other cases of this lint, there's no simple way to detect if
    an old version of the relevant crate (`syn`) is in use. The `actix-web`
    crate only depends on `pin-project` v1.0.0, so checking the version of
    `actix-web` does not guarantee that a new enough version of
    `pin-project` (and therefore `syn`) is in use.
    
    Instead, we rely on the fact that virtually all of the regressed crates
    are pinned to a pre-1.0 version of `pin-project`. When this is the case,
    bumping the `actix-web` dependency will pull in the *latest* version of
    `pin-project`, which has an explicit dependency on a newer v dependency
    on a newer version of `syn`.
    
    The lint message tells users to update `actix-web`, since that's what
    they're most likely to have control over. We could potentially tell them
    to run `cargo update -p syn`, but I think it's more straightforward to
    suggest an explicit change to the `Cargo.toml`
    
    The `actori-web` fork had its last commit over a year ago, and appears
    to just be a renamed fork of `actix-web`. Therefore, I've removed the
    `actori-web` check entirely - any crates that actually get broken can
    simply update `syn` themselves.
    Dylan-DPC authored Mar 19, 2021
    Configuration menu
    Copy the full SHA
    c1b8cb2 View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#83197 - jyn514:cfg-test-dead-code, r=joshtr…

    …iplett
    
    Move some test-only code to test files
    
    Split out from rust-lang#83185.
    Dylan-DPC authored Mar 19, 2021
    Configuration menu
    Copy the full SHA
    e62250b View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    682eace View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#83208 - jethrogb:jb/gitignore, r=Xanewok

    Fix gitattibutes for old git versions
    Dylan-DPC authored Mar 19, 2021
    Configuration menu
    Copy the full SHA
    d503b69 View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#83270 - steffahn:missing_word_in_skip_while…

    …_doc, r=joshtriplett
    
    Fix typo/inaccuracy in the documentation of Iterator::skip_while
    
    One of the examples used to say “this leads to a possibly confusing situation, where the type of the closure is a double reference” while _actually_ referring to the type of the closure _argument_.
    
    This PR just changes a single word in documentation.
    
    `@rustbot` modify labels: A-iterators, T-doc, T-lang
    Dylan-DPC authored Mar 19, 2021
    Configuration menu
    Copy the full SHA
    810db68 View commit details
    Browse the repository at this point in the history