Comments (6)
After iprintln
'ing an ast with lineLimit=-1
, the following is appended for me instead of the cancelled
:
Exception in thread "main" java.lang.NumberFormatException: For input string: "30m"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.parseInt(Integer.java:652)
at java.base/java.lang.Integer.<init>(Integer.java:1105)
at org.fusesource.jansi.AnsiOutputStream.write(AnsiOutputStream.java:122)
at java.base/java.io.FilterOutputStream.write(FilterOutputStream.java:137)
at java.base/sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:233)
at java.base/sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:303)
at java.base/sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:281)
at java.base/sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
at java.base/sun.nio.cs.StreamEncoder.write(StreamEncoder.java:135)
at java.base/java.io.OutputStreamWriter.write(OutputStreamWriter.java:226)
at org.rascalmpl.repl.WrappedFilterWriter.write(WrappedFilterWriter.java:37)
at java.base/java.io.PrintWriter.write(PrintWriter.java:542)
at java.base/java.io.PrintWriter.write(PrintWriter.java:559)
at java.base/java.io.PrintWriter.print(PrintWriter.java:686)
at java.base/java.io.PrintWriter.println(PrintWriter.java:822)
at org.rascalmpl.repl.BaseREPL.run(BaseREPL.java:367)
at org.rascalmpl.vscode.lsp.terminal.LSPTerminalREPL.main(LSPTerminalREPL.java:345)
Suppressed: java.lang.NumberFormatException: For input string: "30m
t java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.parseInt(Integer.java:652)
at java.base/java.lang.Integer.<init>(Integer.java:1105)
at org.fusesource.jansi.AnsiOutputStream.write(AnsiOutputStream.java:122)
at java.base/java.io.FilterOutputStream.write(FilterOutputStream.java:137)
at java.base/java.io.FilterOutputStream.write(FilterOutputStream.java:108)
at org.fusesource.jansi.AnsiOutputStream.close(AnsiOutputStream.java:506)
at java.base/sun.nio.cs.StreamEncoder.implClose(StreamEncoder.java:341)
at java.base/sun.nio.cs.StreamEncoder.close(StreamEncoder.java:161)
at java.base/java.io.OutputStreamWriter.close(OutputStreamWriter.java:255)
at java.base/java.io.FilterWriter.close(FilterWriter.java:114)
at java.base/java.io.PrintWriter.close(PrintWriter.java:415)
at org.rascalmpl.repl.BaseREPL.run(BaseREPL.java:366)
... 1 more
Control is never returned, :quit
does not work.
from rascal.
@DavyLandman is this a nice one for you?
from rascal.
- This behavior is consistent for any value that is printed
- Without
lineLimit=-1
it works much better.
from rascal.
Looks like were stacking a number of issues here:
try (PrintWriter err = new PrintWriter(errorWriter, true)) {
err.println("Unexpected (uncaught) exception, closing the REPL: ");
if (!err.checkError()) {
err.print(e.toString());
e.printStackTrace(err);
}
else {
System.err.print(e.toString());
e.printStackTrace();
}
err.flush();
}
errorWriter.flush();
throw e;
This code closes the error stream accidentally due to the try
block "auto-close" feature. Pretty sure that's not supposed to happen.
The error that happens is not always printed because of this.
The actual error is that an ANSI escape seems to be started, but not correctly finished, which makes the ANSI parser crash. There is an unexpected m
in the input after 30
.
from rascal.
Indeed, -1
should not be a valid argument. I think we should make sure that <=0
is an illegal argument.
I don't have the time to look at that remark about closing the stream @jurgenvinju is this something that is only hit in a certain edge case? or in case of every exception?
from rascal.
Indeed, -1 should not be a valid argument. I think we should make sure that <=0 is an illegal argument.
-1
is a valid documented argument to iprint
and iprintln
's lineLimit
parameter. It certainly is not the cause of the issue; but it is triggering the issue.
public void iprint(IValue arg, IInteger lineLimit){
StandardTextWriter w = new StandardTextWriter(true, 2);
Writer output = out;
if (lineLimit.signum() > 0) {
output = new LimitedLineWriter(output, lineLimit.longValue());
}
So here we see that the writer is only wrapped if the lineLimit
is positive.
The rest of the code goes as follows:
try {
w.write(arg, output);
}
catch (/*IOLimitReachedException*/ RuntimeException e) {
// ignore, it's what we wanted
}
catch (IOException e) {
RuntimeExceptionFactory.io(values.string("Could not print indented value"));
}
finally {
try {
output.flush();
output.close();
}
catch (IOException e) {
}
}
I suspect that the LimitedLineWriter has an error:
- it does not close the wrapped stream on
close()
- this hides the real problem which is that
iprint
always tries to close the stream - but you should not close either stderr or stdout, that breaks the REPL.
- the unwrapped stream is properly cascading the close.
- so the fix is probably to not close the stream anymore.
- the question is: why did I write it like this and why has this not bothered anyone before?
- none of the other print methods close the stream.
from rascal.
Related Issues (20)
- Remove lib scheme, only allow it in RASCAL.mf file as a reference to a dependency of the project HOT 3
- diffJavaM3 signature
- createM3FromMavenProject unused parameter HOT 2
- Grammar reifier forgets non-terminals if there exists a layout non-terminal with the same name.
- Merging grammars with overlapping non-terminal names in different roles breaks the parser generator HOT 1
- Wrong warning "unknown keyword argument" HOT 1
- Need to run on JRE 17 (link with classes compiled with JDK 17)
- unnecessary `isEmpty` check inside `isSameFile` HOT 3
- strange NPE in java-air HOT 3
- List assignable with negative index throws Java ArrayIndexOutOfBoundsException or Rascal IndexOutOfBounds HOT 1
- Writing ADT not overwritten default values HOT 1
- Low transparency failure to resolve libraries HOT 4
- Default pom.xml file for a Rascal project does not include META-INF folder in jar HOT 1
- Documentation building process HOT 2
- (off topic) Modern parser generator for Haskell HOT 4
- Get function for maps with default value HOT 3
- Negative numbers after ? seem to be ambiguous HOT 1
- parse error in Rascal module in terminal reported with internal stack trace
- Splicing concrete list after empty list-variable loses layout after the inserted spliced list
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rascal.