Heroku + jirb => readline crashes on backspace #151

Closed
carlhoerberg opened this Issue Apr 29, 2012 · 3 comments

Comments

Projects
None yet
2 participants
Member

carlhoerberg commented Apr 29, 2012

If you use the Heroku buildpack (https://github.com/jruby/heroku-buildpack-jruby) and start a irb session and press backspace it crashes:

$ heroku run jirb
Running jirb attached to terminal... up, run.1
irb(main):001:0> aConsoleReader.java:1414:in `backspace': java.lang.ArithmeticException: / by zero
    from ConsoleReader.java:1436:in `backspace'
    from ConsoleReader.java:628:in `readLine'
    from ConsoleReader.java:457:in `readLine'
    from Readline.java:237:in `s_readline'
    from Readline$s$s_readline.gen:65535:in `call'
    from CachingCallSite.java:332:in `cacheAndCall'
    from CachingCallSite.java:203:in `call'
    from FCallTwoArgNode.java:38:in `interpret'
    from LocalAsgnNode.java:123:in `interpret'
    from IfNode.java:111:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:147:in `call'
    from DefaultMethod.java:183:in `call'
    from CachingCallSite.java:292:in `cacheAndCall'
    from CachingCallSite.java:135:in `call'
    from CallNoArgNode.java:63:in `interpret'
    from DAsgnNode.java:110:in `interpret'
    from IfNode.java:111:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:111:in `INTERPRET_BLOCK'
    from Interpreted19Block.java:212:in `evalBlockBody'
    from Interpreted19Block.java:163:in `yield'
    from Interpreted19Block.java:136:in `yieldSpecific'
    from Block.java:99:in `yieldSpecific'
    from ZYieldNode.java:25:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from EnsureNode.java:96:in `interpret'
    from BeginNode.java:83:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:212:in `call'
    from DefaultMethod.java:207:in `call'
    from CachingCallSite.java:322:in `cacheAndCall'
    from CachingCallSite.java:178:in `callBlock'
    from CachingCallSite.java:187:in `callIter'
    from FCallOneArgBlockNode.java:34:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from ASTInterpreter.java:111:in `INTERPRET_BLOCK'
    from Interpreted19Block.java:212:in `evalBlockBody'
    from Interpreted19Block.java:200:in `yield'
    from Interpreted19Block.java:131:in `call'
    from Block.java:89:in `call'
    from RubyProc.java:270:in `call'
    from RubyProc.java:258:in `call19'
    from RubyProc$i$0$0$call19.gen:65535:in `call'
    from DynamicMethod.java:203:in `call'
    from DynamicMethod.java:199:in `call'
    from CachingCallSite.java:292:in `cacheAndCall'
    from CachingCallSite.java:135:in `call'
    from CallNoArgNode.java:63:in `interpret'
    from LocalAsgnNode.java:123:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:147:in `call'
    from DefaultMethod.java:183:in `call'
    from CachingCallSite.java:292:in `cacheAndCall'
    from CachingCallSite.java:135:in `call'
    from VCallNode.java:86:in `interpret'
    from IfNode.java:111:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from WhileNode.java:131:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:147:in `call'
    from DefaultMethod.java:183:in `call'
    from CachingCallSite.java:292:in `cacheAndCall'
    from CachingCallSite.java:135:in `call'
    from CallNoArgNode.java:63:in `interpret'
    from LocalAsgnNode.java:123:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from IfNode.java:117:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:190:in `call'
    from DefaultMethod.java:199:in `call'
    from CachingCallSite.java:312:in `cacheAndCall'
    from CachingCallSite.java:169:in `call'
    from CallOneArgNode.java:57:in `interpret'
    from ReturnNode.java:92:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from CaseNode.java:138:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:190:in `call'
    from DefaultMethod.java:199:in `call'
    from CachingCallSite.java:312:in `cacheAndCall'
    from CachingCallSite.java:169:in `call'
    from CallOneArgNode.java:57:in `interpret'
    from LocalAsgnNode.java:123:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from RescueNode.java:216:in `executeBody'
    from RescueNode.java:120:in `interpretWithJavaExceptions'
    from RescueNode.java:110:in `interpret'
    from BeginNode.java:83:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from WhileNode.java:131:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:147:in `call'
    from DefaultMethod.java:183:in `call'
    from CachingCallSite.java:292:in `cacheAndCall'
    from CachingCallSite.java:135:in `call'
    from VCallNode.java:86:in `interpret'
    from LocalAsgnNode.java:123:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from CallOneArgNode.java:57:in `interpret'
    from OrNode.java:95:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from AndNode.java:91:in `interpret'
    from OrNode.java:95:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from UntilNode.java:116:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:147:in `call'
    from DefaultMethod.java:183:in `call'
    from CachingCallSite.java:292:in `cacheAndCall'
    from CachingCallSite.java:135:in `call'
    from VCallNode.java:86:in `interpret'
    from DAsgnNode.java:110:in `interpret'
    from IfNode.java:111:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from RescueNode.java:216:in `executeBody'
    from RescueNode.java:120:in `interpretWithJavaExceptions'
    from RescueNode.java:110:in `interpret'
    from BeginNode.java:83:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from ASTInterpreter.java:111:in `INTERPRET_BLOCK'
    from Interpreted19Block.java:212:in `evalBlockBody'
    from Interpreted19Block.java:163:in `yield'
    from Interpreted19Block.java:136:in `yieldSpecific'
    from Block.java:99:in `yieldSpecific'
    from RubyKernel.java:1410:in `loop'
    from RubyKernel$s$0$0$loop.gen:65535:in `call'
    from CachingCallSite.java:302:in `cacheAndCall'
    from CachingCallSite.java:144:in `callBlock'
    from CachingCallSite.java:153:in `callIter'
    from FCallNoArgBlockNode.java:32:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from ASTInterpreter.java:111:in `INTERPRET_BLOCK'
    from Interpreted19Block.java:212:in `evalBlockBody'
    from Interpreted19Block.java:163:in `yield'
    from Block.java:130:in `yield'
    from RubyContinuation.java:106:in `enter'
    from RubyKernel.java:1204:in `rbCatch19Common'
    from RubyKernel.java:1197:in `rbCatch19'
    from RubyKernel$s$rbCatch19.gen:65535:in `call'
    from CachingCallSite.java:322:in `cacheAndCall'
    from CachingCallSite.java:178:in `callBlock'
    from CachingCallSite.java:187:in `callIter'
    from FCallOneArgBlockNode.java:34:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:169:in `call'
    from DefaultMethod.java:191:in `call'
    from CachingCallSite.java:302:in `cacheAndCall'
    from CachingCallSite.java:144:in `callBlock'
    from CachingCallSite.java:153:in `callIter'
    from CallNoArgBlockNode.java:64:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:147:in `call'
    from DefaultMethod.java:183:in `call'
    from CachingCallSite.java:292:in `cacheAndCall'
    from CachingCallSite.java:135:in `call'
    from CallNoArgNode.java:63:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from ASTInterpreter.java:111:in `INTERPRET_BLOCK'
    from Interpreted19Block.java:212:in `evalBlockBody'
    from Interpreted19Block.java:163:in `yield'
    from Block.java:130:in `yield'
    from RubyContinuation.java:106:in `enter'
    from RubyKernel.java:1204:in `rbCatch19Common'
    from RubyKernel.java:1197:in `rbCatch19'
    from RubyKernel$s$rbCatch19.gen:65535:in `call'
    from CachingCallSite.java:322:in `cacheAndCall'
    from CachingCallSite.java:178:in `callBlock'
    from CachingCallSite.java:187:in `callIter'
    from FCallOneArgBlockNode.java:34:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from EnsureNode.java:96:in `interpret'
    from BeginNode.java:83:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:74:in `INTERPRET_METHOD'
    from InterpretedMethod.java:190:in `call'
    from DefaultMethod.java:199:in `call'
    from CachingCallSite.java:312:in `cacheAndCall'
    from CachingCallSite.java:169:in `call'
    from jruby/bin/jirb:13:in `__file__'
    from jruby/bin/jirb:-1:in `load'
    from Ruby.java:697:in `runScript'
    from Ruby.java:690:in `runScript'
    from Ruby.java:597:in `runNormally'
    from Ruby.java:446:in `runFromMain'
    from Main.java:369:in `doRunFromMain'
    from Main.java:258:in `internalRun'
    from Main.java:224:in `run'
    from Main.java:208:in `run'
    from Main.java:188:in `main'

jline thinks that the console is 0 chars wide..

https://github.com/jline/jline/blob/master/src/main/java/jline/ConsoleReader.java#L1414

Member

carlhoerberg commented Apr 29, 2012

probably a jline issue, don't know how to reproduce it in a pure java environment =/

Member

carlhoerberg commented May 15, 2012

the problem seems to lay with Heroku. stty -a returns zero columns and row which confuses jline (https://github.com/jline/jline/blob/master/src/main/java/jline/UnixTerminal.java#L218)

$ heroku run "stty -a < /dev/tty"
Running stty -a < /dev/tty attached to terminal... up, run.1
speed 38400 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
Owner

BanzaiMan commented Oct 13, 2012

Looks like your patch is incorporated to a jline release (and subsequently JRuby).

@BanzaiMan BanzaiMan closed this Oct 13, 2012

eregon added a commit that referenced this issue Oct 28, 2015

Squashed 'spec/ruby/' changes from fa9e1cd..92311a8
92311a8 Module#prepend is private in ruby 2.0
e3283d5 Module#include and #prepend should be defined directly on Module
1afea36 Specify TCPServer#accept and #accept_nonblock when closed
c4bb84f Add spec for String#force_encoding called on a frozen string.
0f1e1db Add spec for alias and undef raising a NameError which is not a NoMethodError
86e10f3 New spec for Kernel#exit across threads
dfb2aa0 Refactor a couple Module#prepend specs
a6bd065 Add a spec for Range#dup
8aa7b1e Super from a class method must work with prepended modules.
591ff4f Add a few more specs for defined? with scoped constants.
b99f44c Add a few spec about the return value with ensure
ee87540 Add yield-to-lambda cases that were not all consistent in JRuby.
156bb2b proc.call on object that calls #to_ary which returns nil should return original object
9145998 Add spec for alias on top level
a924c74 Add specs for results of begin-end blocks
193cf30 New spec for setting visibility from a block
f987230 Clarify private spec
22e0298 Add spec for nested methods in a "def expr.meth"
142a876 Add spec for nested methods in instance_eval
8d7b807 Ensure the variable can be read from Binding#eval after Binding#local_variable_set
fe35f8a Actually use a shadowed variable in Binding#local_variables spec
092639a Remove inappropriate spec
842d3aa Fix UnboundMethod#super_method to not be order dependent
bfd0a7e Merge pull request #155 from wied03/master
f6ebc9b Follow up for ruby/spec#153
5b76fa0 Merge pull request #154 from wied03/master
948839f Test struct methods ending in ?, !
adbb7de Exact match for without_test_modules
58f9bad Fix style in Module#ancestors spec
da511ce Merge pull request #153 from wied03/tighten_ancestors
01ba680 Exclude more test modules
278546d Tighten up ancestors specs
c49e802 Add a few more check that methods do not end up defined on Object
a81b5d3 Merge pull request #150 from wied03/instance_eval_class_mod
e27298c Merge pull request #148 from wied03/module_instance_methods
35164b4 Test instance eval/exec on classes and modules
7a45ecb Ensure including a module doesn't prevent instance_methods from working
b188d8e Merge pull request #147 from wied03/multiple_remove_meth
f554ff9 Clarify the file organization
004151e Specify that Class#new yield the new Class
dba4b94 Merge pull request #149 from wied03/mod_class_to_s
98235ef A start at module/class#to_s
4d1cf90 Merge pull request #152 from kachick/struct-new-passes-subclass-to-block
8fdfc4f Add a spec for block parameter in Struct.new
f390fcb Improve definition spaces for some Struct.new behaviors
7df9151 Merge pull request #151 from wied03/struct_with_block
4890c67 Improve struct with block tests
9ff4c13 Fully test multiple remove_methods at once
122e1e1 Merge pull request #145 from wied03/master
6b57785 Another case that wasn't working on Opal
4025c0e Only allow #extend to throw the error in Kernel#extend
7551ce6 Kernel#extend raises a TypeError when the argument is not a Module
df5dfc6 Merge pull request #143 from ruby/elia/unnecessary-mutable-string-use
a7acf82 Object instead of a String for singleton spec
c9cc7ae OpenStruct#new_ostruct_member is now a protected method
1b42fb9 Do not access private internal state in the OpenStruct#new_ostruct_member spec
c7f0b73 remove ruby_bug related to old releases
5786f3a remove duplicate specs Float#<=>.
f5323b8 remove trailing spaces
1508e8b Merge pull request #142 from ruby/elia/time_yday
2463dda Simplify the Time#yday
7472ad9 Test Time#yday for each day of each month
c9ff9cf Merge pull request #141 from ruby/elia/not_match_spec
aa56fe8 Minor fixes
17c66fa Add initial specs for Kernel#!~
391d026 Merge pull request #139 from wied03/master
af22315 Merge pull request #140 from wied03/defined_improve
db9a977 Test more granular defined? scenarios
49012ea Added another exception inspect case that wasn't covered
7512517 Update to latest ruby releases
d50b1bd Fix specdoc in Regexp#options
23585e7 Merge pull request #137 from wied03/master
fcf6a05a Cover another regexp case that was failing in Opal
bde1725 Opal is treating // as if it was created with Regexp.allocate, so add a non encoding based options test of // that it can execute and also test that match fails the same way options does
7819cb3 FreeBSD and NetBSD supports birthtime

git-subtree-dir: spec/ruby
git-subtree-split: 92311a8114663b4ae81a086699c4510271fff1ab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment