You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ jruby -vjruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [darwin-x86_64]
$ uname -aDarwin Macintosh.local 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64
Expected Behavior
Given this test.rb file:
a=StringIO.new100.times.mapdoThread.startdo# 'hello' seems to work but not *%w(hello)100.times{a.puts *%w(hello)}endend.each(&:join)
Its execution should succeed:
$ jruby test.rb
Actual Behavior
Exception in thread "Ruby-0-Thread-100: test.rb:1" Exception in thread "Ruby-0-Thread-99: test.rb:1" java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.jruby.util.ByteList.grow(ByteList.java:1102)
at org.jruby.util.ByteList.length(ByteList.java:584)
at org.jruby.RubyString.resize(RubyString.java:995)
at org.jruby.ext.stringio.StringIO.strioExtend(StringIO.java:701)
at org.jruby.ext.stringio.StringIO.write(StringIO.java:1024)
at org.jruby.ext.stringio.StringIO$INVOKER$i$1$0$write.call(StringIO$INVOKER$i$1$0$write.gen)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:161)
at org.jruby.RubyIO.write(RubyIO.java:2567)
at org.jruby.ext.stringio.StringIO$GenericWritable.puts(StringIO.java:1213)
at org.jruby.ext.stringio.StringIO$GenericWritable$INVOKER$s$0$0$puts.call(StringIO$GenericWritable$INVOKER$s$0$0$puts.gen)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:67)
at test.invokeOther1:puts(test.rb:4)
at test.RUBY$block$\=test\,rb$2(test.rb:4)
at org.jruby.runtime.CompiledIRBlockBody.yieldDirect(CompiledIRBlockBody.java:156)
at org.jruby.runtime.IRBlockBody.yieldSpecific(IRBlockBody.java:76)
at org.jruby.runtime.Block.yieldSpecific(Block.java:136)
at org.jruby.RubyFixnum.times(RubyFixnum.java:299)
at org.jruby.RubyFixnum$INVOKER$i$0$0$times.call(RubyFixnum$INVOKER$i$0$0$times.gen)
at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:139)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:145)
at test.invokeOther4:times(test.rb:4)
at test.RUBY$block$\=test\,rb$1(test.rb:4)
at org.jruby.runtime.CompiledIRBlockBody.callDirect(CompiledIRBlockBody.java:145)
at org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:67)
at org.jruby.runtime.Block.call(Block.java:126)
at org.jruby.RubyProc.call(RubyProc.java:324)
at org.jruby.RubyProc.call(RubyProc.java:249)
at org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:104)
at java.lang.Thread.run(Thread.java:745)
The text was updated successfully, but these errors were encountered:
I can play devil's advocate and ask "should it be threadsafe?" However, IO is thread-safe, and StringIO is intended to mimic it, so I agree we should deal with this.
FWIW, I don't believe MRI's StringIO is really safe, but it probably won't fail as severely as this.
Environment
Expected Behavior
Given this
test.rb
file:Its execution should succeed:
$ jruby test.rb
Actual Behavior
The text was updated successfully, but these errors were encountered: