Errno::EBADF: Bad file descriptor on JRuby 1.7.10
Running diffs for a larger amount (several thousands) of texts under JRuby 1.7.10 throws Bad file descriptor errors:
Errno::EBADF: Bad file descriptor - Bad file descriptor
getStackTrace at java/lang/Thread.java:1588
getBacktraceData at org/jruby/runtime/backtrace/TraceType.java:175
getBacktrace at org/jruby/runtime/backtrace/TraceType.java:39
prepareBacktrace at org/jruby/RubyException.java:224
preRaise at org/jruby/exceptions/RaiseException.java:213
preRaise at org/jruby/exceptions/RaiseException.java:194
<init> at org/jruby/exceptions/RaiseException.java:110
newRaiseException at org/jruby/Ruby.java:3774
newErrnoEBADFError at org/jruby/Ruby.java:3322
finalize at org/jruby/util/io/OpenFile.java:490
cleanup at org/jruby/util/io/OpenFile.java:401
ioClose at org/jruby/RubyIO.java:2120
close at org/jruby/RubyIO.java:2097
cleanupPOpen at org/jruby/RubyIO.java:4477
popen3_19 at org/jruby/RubyIO.java:4435
callBlock at org/jruby/runtime/callsite/CachingCallSite.java:79
call at org/jruby/runtime/callsite/CachingCallSite.java:85
callVarargs at org/jruby/runtime/callsite/CachingCallSite.java:116
popen3 at /home/paul/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/open3.rb:74
popen3 at /home/paul/.rvm/rubies/jruby-1.7.10/lib/ruby/1.9/open3.rb:74
call at org/jruby/internal/runtime/methods/JittedMethod.java:101
call at org/jruby/internal/runtime/methods/DefaultMethod.java:167
call at org/jruby/internal/runtime/methods/WrapperMethod.java:90
callBlock at org/jruby/runtime/callsite/CachingCallSite.java:79
callIter at org/jruby/runtime/callsite/CachingCallSite.java:90
callVarargsIter at org/jruby/runtime/callsite/CachingCallSite.java:126
diff at /home/paul/.rvm/gems/jruby-1.7.10/gems/diffy-3.0.1/lib/diffy/diff.rb:55
diff at /home/paul/.rvm/gems/jruby-1.7.10/gems/diffy-3.0.1/lib/diffy/diff.rb:55
call at org/jruby/internal/runtime/methods/JittedMethod.java:141
call at org/jruby/runtime/callsite/CachingCallSite.java:134
This might be related to jruby/jruby/issues/781.
Yeah, sounds like this is probably a jruby bug. The line in the stack trace (https://github.com/samg/diffy/blob/master/lib/diffy/diff.rb#L55) opens a pipe to the diff executable and reads the output and it seems like a race condition collecting spawned child process output (as suggested in https://github.com/jruby/jruby/issues/779) would be a likely culprit for this error.
If there is a workaround discovered let me know and I'd consider incorporating that into diffy, but it seems like you may have to work with the jruby team to resolve the issue. It's possible that if you're able to reliably trigger this bug with diffy it could help them track down the race condition and resolve it.
I run into the same issue with jruby 1.7.11
popen3 is called but only stdout is read. Why even use it and not just use the backtick method everywhere?