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

RascalLibraryURIResolver prints on System.err and System.out, asyncronously due to lazy class loading and lazy static initializers. This is what breaks assumptions inside the Evaluator (where System.err and System.out have been wrapped). #1961

Open
jurgenvinju opened this issue Jun 5, 2024 · 7 comments
Assignees
Labels

Comments

@jurgenvinju
Copy link
Member

rascal>import lang::rascal::tutor::Indexer;
☐ Parsed ExtractInfo.rsc                                                                                       πŸ•˜ 0:00:00.386 
β˜‘ Generating $GENERATED_PARSER$41854358                                                                        πŸ•› 0:00:00.436 
β˜‘ Generating $GENERATED_PARSER$1920113068                                                                      πŸ•› 0:00:00.435 
β˜‘ Generating $GENERATED_PARSER$1151540380                                                                      πŸ•› 0:00:00.549 
β˜‘ Generating $GENERATED_PARSER$741664820                                                                       πŸ•› 0:00:00.005 
β˜‘ Loading modules                                                                                              πŸ•” 0:00:08.687 
ok
rascal>

The Parsed ExtractInfo.rsc bar is not supposed to be there. It should be one step of Loading modules.

@jurgenvinju jurgenvinju added the bug label Jun 5, 2024
@jurgenvinju jurgenvinju self-assigned this Jun 5, 2024
@jurgenvinju
Copy link
Member Author

jurgenvinju commented Jun 5, 2024

rascal>import util::Reflective;
☐ Loading modules                                                                                              πŸ•‘ 0:00:00.000 
β˜‘ Loading modules                                                                                              πŸ•— 0:00:01.849 

The first line is actually a System.err.println from RascalLibraryURIResolver "[INFO] blablabla" which was not expected at that time and place. The bar accidentally overwrites the [INFO] line, but since the output was not observed by the wrapper, the line offsets is off by one now and the latest version of the progress bar is printed one line below.

@jurgenvinju jurgenvinju changed the title "Loading modules" job misses a beat RascalLibraryURIResolver prints on System.err and System.out, asyncronously due to lazy class loading and lazy static initializers. This is what breaks assumptions inside the Evaluator (where System.err and System.out have been wrapped). Jun 5, 2024
@jurgenvinju
Copy link
Member Author

  1. RascalLibraryURIResolver is printing in System.err as a result of static initialization blocks
  2. This can happen even after printing the prompt and executing a command
  3. The output is mixed asynchronously with other output (such as progress bars)
  4. The output breaks invariants of the TerminalProgressBarMonitor, leading to duplicate printing of bars and/or loss of output.

@jurgenvinju
Copy link
Member Author

In debug mode there are many System.err printlns in the interpreter. These also break the terminal output and progress monitors invariants.

@jurgenvinju
Copy link
Member Author

Still it the printing on System.err by RascalLibraryURIResolver is questionable. We'd do well by removing this scheme altogether via #1916 and then this problem is fixed as well.

@DavyLandman
Copy link
Member

I think we should indeed avoid any direct writes to System.err in our codebase. But then again, where to write to? as there can be more than 1 evaluator active per jvm.

@jurgenvinju
Copy link
Member Author

Yes. This code is executed during the static initialization of the URIResolverRegistry's plugins so shared between all the evaluator's in a single JVM. Still lazily though, and perhaps on a parallel thread. So there's that. It must go.

@jurgenvinju
Copy link
Member Author

See #1962 for a beginning of a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants