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

cmd/pprof: invokeVisualizer is racy #19020

Open
dsnet opened this issue Feb 10, 2017 · 4 comments
Open

cmd/pprof: invokeVisualizer is racy #19020

dsnet opened this issue Feb 10, 2017 · 4 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Milestone

Comments

@dsnet
Copy link
Member

dsnet commented Feb 10, 2017

In invokeVisualizer, we defer deleting the temporary file when invoking the visualizer until the end of the pprof program. However, the invokeVisualizer does not wait for the viewer to finish when not running in interactive mode.

Thus, the following race occurs in non-interactive mode:

  • pprof generates some report
  • pprof invokes the browser to show report; Chrome starts running
  • Without waiting for browser to end, we return from invokeVisualizer and the pprof program begins terminations.
  • The DeferDelete is run, deleting the report file
  • Chrome has finished starting up, but cannot find the file. Oops.

The fix is probably to wait for the visualizer to end regardless of "interactivity".

@dsnet dsnet added this to the Go1.9 milestone Feb 10, 2017
@dsnet dsnet self-assigned this Feb 10, 2017
@minux
Copy link
Member

minux commented Feb 10, 2017 via email

@dgryski
Copy link
Contributor

dgryski commented Feb 10, 2017

/cc @rauls5382

@dsnet
Copy link
Member Author

dsnet commented Feb 10, 2017

I noticed that there is already a 1 second wait in the logic I pointed to. I must have been really unlucky and Chrome somehow took longer than 1 second to load up. I'm not sure if there's anything we could do here then. Increasing the wait time seems like a bad idea (how high is high enough?).

@rauls5382
Copy link
Contributor

Note the logic is to do wait for the visualizer in non-interactive mode. On interactive mode (pprof shell) we do not wait to allow you to let you go back to the command line and spawn other visualizers in parallel.

Having said that, there is a fundamental race condition: we to write the files, run the viewer, wait for the viewer read the files, and then delete them. The problem happens when the visualizer is a command that signals another command (eg chrome), so the visualizer exits even though the files haven't been read.

I could agree with special-casing the delay for some platforms.

@dsnet dsnet removed their assignment Feb 10, 2017
@dsnet dsnet modified the milestones: Unplanned, Go1.9 May 24, 2017
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

5 participants