rust/src/libstd
Alex Crichton 4032b7a429 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>
2018-11-14 12:46:57 -08:00
..
collections revert making internal APIs const fn. 2018-11-10 01:10:07 +01:00
ffi Auto merge of #55278 - Centril:constification-1, r=alexcrichton 2018-11-12 18:54:11 +00:00
io revert some more constification. 2018-11-10 01:11:06 +01:00
net reduce list to functions callable in const ctx. 2018-11-10 01:10:07 +01:00
os Move std::os::raw::c_void into libcore and re-export in libstd 2018-09-14 16:19:59 +01:00
prelude Reformat std prelude source to show it is the sum of core and alloc preludes 2018-07-07 23:16:27 +02:00
sync revert making internal APIs const fn. 2018-11-10 01:10:07 +01:00
sys std: Synchronize access to global env during exec 2018-11-14 12:46:57 -08:00
sys_common std: Delete the alloc_system crate 2018-11-11 09:22:28 -08:00
tests Breaking change upgrades 2018-09-04 13:22:08 -06:00
thread revert some more constification. 2018-11-10 01:11:06 +01:00
alloc.rs global allocators: add a few comments 2018-11-12 09:01:57 +01:00
ascii.rs Remove unstable and deprecated APIs 2018-07-30 18:18:23 +02:00
build.rs Prefer unwrap_or_else to unwrap_or in case of function calls/allocations 2018-10-19 09:45:45 +02:00
Cargo.toml std: Delete the alloc_system crate 2018-11-11 09:22:28 -08:00
env.rs make reference to dirs crate clickable in terminals 2018-07-12 12:48:10 +02:00
error.rs Rollup merge of #53523 - phungleson:fix-impl-from-for-std-error, r=GuillaumeGomez 2018-10-04 12:20:05 +02:00
f32.rs Fix doc for new copysign functions 2018-10-24 15:19:23 -07:00
f64.rs Fix doc for new copysign functions 2018-10-24 15:19:23 -07:00
fs.rs Rollup merge of #55734 - teresy:shorthand-fields, r=davidtwco 2018-11-07 21:27:00 +08:00
future.rs Remove spawning from task::Context 2018-09-19 15:01:19 -07:00
keyword_docs.rs Hopefully fix compile error 2018-10-23 22:27:02 +02:00
lib.rs std: Delete the alloc_system crate 2018-11-11 09:22:28 -08:00
macros.rs Fix a typo in std::panic 2018-11-11 07:36:10 +00:00
memchr.rs Fix typos found by codespell. 2018-08-19 17:41:28 +02:00
num.rs Stabilize num::NonZeroU* 2018-05-16 19:11:31 +02:00
panic.rs Do not Atomic{I,U}128 in stage0 2018-11-05 18:54:17 +02:00
panicking.rs rustc: Allow #[no_mangle] anywhere in a crate 2018-10-06 13:57:30 -07:00
path.rs reduce list to functions callable in const ctx. 2018-11-10 01:10:07 +01:00
primitive_docs.rs Rollup merge of #55247 - peterjoel:peterjoel-prim-char-doc-example, r=joshtriplett 2018-10-25 14:31:07 +02:00
process.rs Rollup merge of #55754 - spastorino:fix-process-output-docs, r=alexcrichton 2018-11-13 19:20:18 +08:00
rt.rs Deny bare trait objects in src/libstd. 2018-07-10 20:35:36 +02:00
time.rs reduce list to functions callable in const ctx. 2018-11-10 01:10:07 +01:00