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

Fix PMI non-determinism and a potential deadlock. #252

Merged
merged 1 commit into from
Feb 26, 2020

Conversation

erozenfeld
Copy link
Member

PMI in DRIVEALL mode invokes subprocesses in PREPALL mode
in order to be able to recover from errors. We had COMPlus environment
variables (including COMPlus_JitStdOutFile) set for both the parent and
child processes so the jit emitted disassembly, etc. to the same file.
The parent process was still active when the child was running (e.g.,
it called p.StandardOutput.ReadToEnd()). That resulted in duplicate
methods (especially from System.Private.Corelib) in the dasm file and
non-deterministic output interleaving.

The fix is not to set the COMPlus environment variables in jit-dasm-pmi
when invoking pmi but instead pass them in PMIENV environment variable
as semicolon-separated name=value pairs and set the actual COMPlus
environment variables only on child processes.

I also fixed a potential deadlock in output/error redirection: at least
one of the redirected steams has to be read asynchronously.
See https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.standardoutput
for details.

PMI in DRIVEALL mode invokes subprocesses in PREPALL mode
in order to be able to recover from errors. We had COMPlus environment
variables (including COMPlus_JitStdOutFile) set for both the parent and
child processes so the jit emitted disassembly, etc. to the same file.
The parent process was still active when the child was running (e.g.,
it called p.StandardOutput.ReadToEnd()). That resulted in duplicate
methods (especially from System.Private.Corelib) in the dasm file and
non-deterministic output interleaving.

The fix is not to set the COMPlus environment variables  in jit-dasm-pmi
when invoking pmi but instead pass them in PMIENV environment variable
as semicolon-separated name=value pairs and set the actual COMPlus
environment variables only on child processes.

I also fixed a potential deadlock in output/error redirection: at least
one of the redirected steams has to be read asynchronously.
See https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.standardoutput
for details.
@erozenfeld
Copy link
Member Author

@dotnet/jit-contrib @AndyAyersMS PTAL

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down.

@erozenfeld erozenfeld merged commit e209e16 into dotnet:master Feb 26, 2020
@erozenfeld erozenfeld deleted the PMIDeterminism branch February 26, 2020 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants