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

REPL: Try to fix intermittent hang during precompile #51891

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Conversation

Keno
Copy link
Member

@Keno Keno commented Oct 26, 2023

I was intermittently observing the REPL precompile process not finishing. What I believe was happening is the following:

  1. The last line of the precompile script is cd("complete_path\t\t$CTRL_C
  2. As soon as child julia sees the CTRL_C, the prompt is terminated, and a new prompt is echod.
  3. The parent julia tries to complete the line by sending \n, and immediately returns, because the child has already written a new prompt.
  4. The child reads the \n and enters raw mode (ignoring things like ^D).
  5. The parent tries to write ^D to complete the process, but because the child is still processing the \n, this ^D is ignored and the process hangs.

Try to fix this by not writing the superfluous \n if the precompile line ends in ^C.

I was intermittently observing the REPL precompile process not finishing.
What I believe was happening is the following:

1. The last line of the precompile script is `cd("complete_path\t\t$CTRL_C`
2. As soon as child julia sees the `CTRL_C`, the prompt is terminated,
   and a new prompt is echod.
3. The parent julia tries to complete the line by sending `\n`, and
   immediately returns, because the child has already written a new
   prompt.
4. The child reads the `\n` and enters raw mode (ignoring things like
   ^D).
5. The parent tries to write `^D` to complete the process, but because
   the child is still processing the `\n`, this `^D` is ignored and
   the process hangs.

Try to fix this by not writing the superfluous `\n` if the precompile line
ends in `^C`.
Copy link
Sponsor Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

Sgtm

@brenhinkeller brenhinkeller added stdlib:REPL Julia's REPL (Read Eval Print Loop) compiler:precompilation Precompilation of modules labels Oct 27, 2023
@Keno Keno merged commit f235291 into master Oct 27, 2023
7 of 9 checks passed
@Keno Keno deleted the kf/replprecompilefix branch October 27, 2023 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:precompilation Precompilation of modules stdlib:REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants