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

std: Synchronize access to global env during exec #55939

Merged
merged 2 commits into from
Nov 15, 2018

Commits on Nov 14, 2018

  1. Revert "Fixes rust-lang#46775 -- don't mutate the process's environme…

    …nt in Command::exec"
    
    This reverts commit 36fe3b6.
    alexcrichton committed Nov 14, 2018
    Configuration menu
    Copy the full SHA
    5856797 View commit details
    Browse the repository at this point in the history
  2. std: Synchronize access to global env during exec

    This commit, after reverting rust-lang#55359, applies a different fix for rust-lang#46775
    while also fixing rust-lang#55775. The basic idea was to go back to pre-rust-lang#55359
    libstd, and then fix rust-lang#46775 in a way that doesn't expose rust-lang#55775.
    
    The issue described in rust-lang#46775 boils down to two problems:
    
    * First, the global environment is reset during `exec` but, but if the
      `exec` call fails then the global environment was a dangling pointer
      into free'd memory as the block of memory was deallocated when
      `Command` is dropped. This is fixed in this commit by installing a
      `Drop` stack object which ensures that the `environ` pointer is
      preserved on a failing `exec`.
    
    * Second, the global environment was accessed in an unsynchronized
      fashion during `exec`. This was fixed by ensuring that the
      Rust-specific environment lock is acquired for these system-level
      operations.
    
    Thanks to Alex Gaynor for pioneering the solution here!
    
    Closes rust-lang#55775
    
    Co-authored-by: Alex Gaynor <[email protected]>
    alexcrichton and alex committed Nov 14, 2018
    Configuration menu
    Copy the full SHA
    4032b7a View commit details
    Browse the repository at this point in the history