about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-11-13 14:57:10 -0800
committerAlex Crichton <alex@alexcrichton.com>2018-11-14 12:46:57 -0800
commit4032b7a429462ece781629cab9f785742991ebef (patch)
treeb6c33b77b3c46908ddcf75280fac788598a5de86 /src/rustllvm/RustWrapper.cpp
parent5856797bda5b1cfecb486e8de439e958325a8a42 (diff)
downloadrust-4032b7a429462ece781629cab9f785742991ebef.tar.gz
rust-4032b7a429462ece781629cab9f785742991ebef.zip
std: Synchronize access to global env during `exec`
This commit, after reverting #55359, applies a different fix for #46775
while also fixing #55775. The basic idea was to go back to pre-#55359
libstd, and then fix #46775 in a way that doesn't expose #55775.

The issue described in #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 #55775

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions