Uh oh!
There was an error while loading. Please reload this page.
std: Synchronize access to global env during exec - #55939
Conversation
alexcrichton
commented
Nov 13, 2018
r? @sfackler |
| assert!(output.stderr.is_empty()); | ||
| assert_eq!(output.stdout, b"passed\n"); | ||
| let output = Command::new(&me).arg("exec-test6").output().unwrap(); |
There was a problem hiding this comment.
Are exec-test6 and exec-test7 identical?
There was a problem hiding this comment.
I think morally yeah, they're just testing the two routes you can get at removing PATH from env (either by clearing or singularly removing it)
There was a problem hiding this comment.
Oh I missed the path manipulation up above.
sfackler
commented
Nov 13, 2018
It's unfortunate we can't use execvpe for this. We could potentially use it if supported and the command hasn't overridden PATH? Doesn't seem like we need to block this on that though. |
alexcrichton
commented
Nov 13, 2018
I think even with |
Multithreaded exec considered harmful :( @bors r+ |
bors
commented
Nov 13, 2018
📌 Commit b967d55 has been approved by |
bors
commented
Nov 13, 2018
💡 This pull request was already approved, no need to approve it again.
|
bors
commented
Nov 13, 2018
📌 Commit b967d55 has been approved by |
alexcrichton
commented
Nov 13, 2018
@bors: p=5 we'll need to backport this to fix the beta-regression as well |
bors
commented
Nov 14, 2018
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
rust-highfive
commented
Nov 14, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
bors
commented
Nov 14, 2018
💔 Test failed - status-travis |
rust-highfive
commented
Nov 14, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
b967d55 to
95585f4Comparealexcrichton
commented
Nov 14, 2018
@bors: r=sfackler |
bors
commented
Nov 14, 2018
📌 Commit 95585f473bdaa52a23a5208ed579c7cd368c32dd has been approved by |
kennytm
commented
Nov 14, 2018
@bors p=83 rollup fairness |
bors
commented
Nov 14, 2018
⌛ Testing commit 95585f473bdaa52a23a5208ed579c7cd368c32dd with merge d3cdb683b627cfb0e429984b501684c5dc42569e... |
…nt in Command::exec" This reverts commit 36fe3b6.
alexcrichton
commented
Nov 14, 2018
@bors: retry |
bors
commented
Nov 14, 2018
⌛ Testing commit 95585f473bdaa52a23a5208ed579c7cd368c32dd with merge 07f40653dfbc70d4579010a1f73a8bd3a1af3fce... |
bors
commented
Nov 14, 2018
💔 Test failed - status-travis |
rust-highfive
commented
Nov 14, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
kennytm
commented
Nov 14, 2018
🤔 Any chance this change causes dead-lock during doc tests? |
alexcrichton
commented
Nov 14, 2018
Yes this seems non spurious, I will investigate |
alexcrichton
commented
Nov 14, 2018
Oh right, if a process forks with the lock held in one thread we can't then try to acquire it later. This will.need to acquire the lock before the fork |
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 fixrust-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! Closesrust-lang#55775 Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
95585f4 to
4032b7aComparealexcrichton
commented
Nov 14, 2018
@bors: r=sfackler |
bors
commented
Nov 14, 2018
📌 Commit 4032b7a has been approved by |
bors
commented
Nov 14, 2018
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
bors
commented
Nov 15, 2018
☀️ Test successful - status-appveyor, status-travis |
[beta] std: Synchronize access to global env during `exec` This is a beta backport of #55939
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
execbut, but if theexeccall fails then the global environment was a dangling pointerinto free'd memory as the block of memory was deallocated when
Commandis dropped. This is fixed in this commit by installing aDropstack object which ensures that theenvironpointer ispreserved on a failing
exec.Second, the global environment was accessed in an unsynchronized
fashion during
exec. This was fixed by ensuring that theRust-specific environment lock is acquired for these system-level
operations.
Thanks to Alex Gaynor for pioneering the solution here!
Closes#55775