Skip to content

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

Merged
erozenfeld merged 1 commit into
dotnet:masterfrom
erozenfeld:PMIDeterminism
Feb 26, 2020
Merged

erozenfeld merged 1 commit into
dotnet:masterfrom
erozenfeld:PMIDeterminism

Conversation

@erozenfeld

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

@dotnet/jit-contrib @AndyAyersMS PTAL

@AndyAyersMS AndyAyersMS left a comment

Copy link
Copy Markdown
Member

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