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

Comments

Projects
None yet
2 participants
@Blaisorblade
Contributor

Blaisorblade commented Aug 19, 2015

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

This comment has been minimized.

Contributor

Blaisorblade commented Aug 19, 2015

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

This comment has been minimized.

Contributor

Blaisorblade commented Aug 19, 2015

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

This comment has been minimized.

Owner

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

This comment has been minimized.

Contributor

Blaisorblade commented Aug 21, 2015

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

This comment has been minimized.

Owner

lihaoyi commented Aug 21, 2015

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

@Blaisorblade

This comment has been minimized.

Contributor

Blaisorblade commented Aug 22, 2015

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:

  • #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).

@lihaoyi lihaoyi closed this in #190 Aug 22, 2015

lihaoyi added a commit that referenced this issue Aug 22, 2015

Merge pull request #190 from Blaisorblade/topic/ctrl-y
Disable Ctrl-y wherever possible (fix #180)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment