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

C-y kills Ammonite #180

Closed
Blaisorblade opened this issue Aug 19, 2015 · 6 comments
Closed

C-y kills Ammonite #180

Blaisorblade opened this issue Aug 19, 2015 · 6 comments

Comments

@Blaisorblade
Copy link
Contributor

Most Scala REPLs (including Ammonite right now) tend* to die after I type C-y (that is, Ctrl-y) and resume, instead of pasting what I just C-k'ed, with an InterruptedException on reading.

I tracked this down to C-y causing (by default) a delayed suspend, that is a suspend when the process reads from input (like C-z). This can be disabled through stty dsusp undef, also used in JLine, but that's commented out with a "blows up on ubuntu" comment. Alternatively, one could catch the InterruptedException, match on the error message and ignore the exceptions with the right message (although that's probably not extremely robust) — you often don't want to ignore all InterruptedException.

*That is, they repeatably die until this bug is somewhen fixed — both SBT and scala had it at some point.

@Blaisorblade
Copy link
Contributor Author

Stack trace from inside sbt:

$ fg
sbt
[error] (run-main-0) java.io.IOException: Resource temporarily unavailable
java.io.IOException: Resource temporarily unavailable
    at java.io.FileInputStream.readBytes(Native Method)
    at java.io.FileInputStream.read(FileInputStream.java:272)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:273)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
    at sun.nio.cs.StreamDecoder.read0(StreamDecoder.java:126)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:112)
    at java.io.InputStreamReader.read(InputStreamReader.java:168)
    at ammonite.terminal.TermCore$$anonfun$readLine$1.apply$mcI$sp(TermCore.scala:213)
    at ammonite.terminal.TermCore$$anonfun$readLine$1.apply(TermCore.scala:213)
    at ammonite.terminal.TermCore$$anonfun$readLine$1.apply(TermCore.scala:213)
    at ammonite.terminal.LazyList.head$lzycompute(Utils.scala:89)
    at ammonite.terminal.LazyList.head(Utils.scala:87)
    at ammonite.terminal.FilterTools$$anon$2.rec$1(FilterTools.scala:28)
    at ammonite.terminal.FilterTools$$anon$2.isDefinedAt(FilterTools.scala:31)
    at ammonite.terminal.FilterTools$$anon$2.isDefinedAt(FilterTools.scala:23)
    at ammonite.terminal.FilterTools$$anon$1$$anonfun$isDefinedAt$1.apply(FilterTools.scala:13)
    at ammonite.terminal.FilterTools$$anon$1$$anonfun$isDefinedAt$1.apply(FilterTools.scala:13)
    at scala.collection.IndexedSeqOptimized$class.prefixLengthImpl(IndexedSeqOptimized.scala:38)
    at scala.collection.IndexedSeqOptimized$class.exists(IndexedSeqOptimized.scala:46)
    at scala.collection.mutable.WrappedArray.exists(WrappedArray.scala:35)
    at ammonite.terminal.FilterTools$$anon$1.isDefinedAt(FilterTools.scala:13)
    at ammonite.terminal.TermCore$DelegateFilter$class.isDefinedAt(TermCore.scala:105)
    at ammonite.terminal.GUILikeFilters$SelectionFilter.isDefinedAt(GUILikeFilters.scala:15)
    at ammonite.terminal.GUILikeFilters$SelectionFilter.isDefinedAt(GUILikeFilters.scala:15)
    at scala.PartialFunction$class.applyOrElse(PartialFunction.scala:123)
    at ammonite.terminal.GUILikeFilters$SelectionFilter.applyOrElse(GUILikeFilters.scala:15)
    at scala.PartialFunction$OrElse.apply(PartialFunction.scala:167)
    at ammonite.terminal.TermCore$.readChar$1(TermCore.scala:176)
    at ammonite.terminal.TermCore$.readLine(TermCore.scala:213)
    at ammonite.repl.frontend.FrontEnd$Ammonite$.readLine(FrontEnd.scala:148)
    at ammonite.repl.frontend.FrontEnd$Ammonite$.action(FrontEnd.scala:63)
    at ammonite.repl.Repl.action(Repl.scala:43)
    at ammonite.repl.Repl.loop$1(Repl.scala:76)
    at ammonite.repl.Repl.run(Repl.scala:94)
    at ammonite.repl.Repl$.run(Repl.scala:174)
    at ammonite.repl.Repl$$anonfun$main$1.apply(Repl.scala:142)
    at ammonite.repl.Repl$$anonfun$main$1.apply(Repl.scala:142)
    at scala.Option.foreach(Option.scala:257)
    at ammonite.repl.Repl$.main(Repl.scala:142)
    at ammonite.repl.Repl.main(Repl.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)

@Blaisorblade
Copy link
Contributor Author

I just verified that stty dsusp undef simply fails under Ubuntu 14.04 (inside/outside tmux). Can we just run the command and ignore failure? If this doesn't work, we could try to learn that dsusp is not supported (visible at least from stty -a, not sure whether also visible through infocmp).

@lihaoyi
Copy link
Member

lihaoyi commented Aug 19, 2015

Can we just run the command and ignore failure? If this doesn't work, we could try to learn that dsusp is not supported (visible at least from stty -a, not sure whether also visible through infocmp).

Sure! I'm not sure if you already found this but it sounds like you have

https://github.com/lihaoyi/Ammonite/blob/master/terminal/src/main/scala/ammonite/terminal/Utils.scala#L66-L67

Feel free to try out whatever fix you want and send a PR

@Blaisorblade
Copy link
Contributor Author

On it (yes, I found that snippet). Tests on project repl seem to fail on current master (no CI?) — it looks like my fix doesn't cause further regressions.

@lihaoyi
Copy link
Member

lihaoyi commented Aug 21, 2015

Current master should work. Where are you seeing it broken?

@Blaisorblade
Copy link
Contributor Author

Re the bug, see the PR #190.

Re the test failures, I looked into them. #192 might be a real bug.

The rest is mostly spurious failures — they affect at most Ammonite developers. Even then, some are worth a look:

  • Tests use sources as test data? #191
  • ProjectTests.finagle tries binding port 8080, even when it's already busy, and fails the test (it doesn't even error out, which would be more accurate).
  • With a 64bit machine and only 1G of RAM for SBT, some tests fail (EulerTests.p5, AdvancedTests.compilerPlugin); I fixed my SBT config, but this is arguably worth documenting (more likely not).

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

No branches or pull requests

2 participants