about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-01-06 15:38:56 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-01-06 15:38:56 -0800
commit0393a1602fd224adc36b62e7158f3b1ebb257afb (patch)
tree615625694c1ed0e83323af1224878b0b38fb6457 /src/rustllvm/RustWrapper.cpp
parent36f5d122b80682de473aeda2e20f14b6ceb86d74 (diff)
parent68cb17097ae92dd50ff076d4b34d955836c4977c (diff)
downloadrust-0393a1602fd224adc36b62e7158f3b1ebb257afb.tar.gz
rust-0393a1602fd224adc36b62e7158f3b1ebb257afb.zip
rollup merge of #20650: klutzy/omg-windows-error-mode
Believe or not, `CreateProcess()` is racy if several threads create
child processes: [0], [1], [2].

This caused some tests show crash dialogs during
`make check-stage#-rpass`.

More explanation:

On Windows, `SetErrorMode()` controls display of error dialogs: it
accepts new error mode and returns old error mode.
The error mode is process-global and automatically inherited to child
process when created.

MSYS2 bash shell internally sets it to not show error dialogs, therefore
`make check-stage#-rpass` should not show them either.

However, [1] says that `CreateProcess()` internally invokes
`SetErrorMode()` twice: at first it sets mode `0x8001` and saves
original mode, and at second it restores original mode.
So if two threads simultaneously call `CreateProcess()`, the first
thread sets error mode to `0x8001` then the second thread recognizes
that current error mode is `0x8001`. Therefore, The second thread will
create process with wrong error mode.

This really occurs inside `compiletest`: it creates several processes on
each thread, so some `run-pass` tests are invoked with wrong error mode
therefore show crash dialog.

This commit adds `StaticMutex` for `CreateProcess()` call. This seems
to fix the "dialog annoyance" issue.

[0]: http://support.microsoft.com/kb/315939
[1]: https://code.google.com/p/nativeclient/issues/detail?id=2968
[2]: https://ghc.haskell.org/trac/ghc/ticket/2650
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions