jruby: mri-extra - flaky TestOpen3 pipe tests

Bug #2054943 reported by Vladimir Petko
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
java-common (Ubuntu)
Fix Released
Undecided
Unassigned
jruby (Debian)
New
Unknown
jruby (Ubuntu)
New
Undecided
Unassigned
openjdk-21 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

The autopkgtests for jruby fail `mri-extra` with the following errors:

  1) Failure:
TestOpen3#test_pipeline_start [/tmp/autopkgtest.Dz4xQk/autopkgtest_tmp/test/mri/test_open3.rb:303]:
Failed assertion, no message given.

  2) Failure:
TestOpen3#test_pipeline_w [/tmp/autopkgtest.Dz4xQk/autopkgtest_tmp/test/mri/test_open3.rb:288]:
<true> expected but was
<false>.

  3) Failure:
TestOpen3#test_capture3_flip [/tmp/autopkgtest.Dz4xQk/autopkgtest_tmp/test/mri/test_open3.rb:190]:

The minimal reproducer of those:
----
require 'open3'

RUBY = 'jruby'
Open3.pipeline_r([RUBY, '-e', 'print "1"'],
                     [RUBY, '-e', 'print STDIN.read + "2"']) {|o,ts|
      print(o.read)
    }
---

executing the above sample results in the following output:
# jruby test.rb
12# jruby test.rb
12# jruby test.rb
12# jruby test.rb
12# jruby test.rb
2# jruby test.rb
12# jruby test.rb
2# jruby test.rb
12# jruby test.rb
2# jruby test.rb
2# jruby test.rb
2# jruby test.rb
2# jruby test.rb
12# jruby test.rb
12# jruby test.rb
2Errno::EPIPE: Broken pipe - <STDOUT>
   write at org/jruby/RubyIO.java:1569
   write at org/jruby/RubyIO.java:1458
   write at org/jruby/RubyIO.java:2829
   print at org/jruby/RubyIO.java:1831
   print at org/jruby/RubyKernel.java:649
  <main> at -e:1

Note: the failure occurs both with Java 21
The root cause is that pipes are created non-blocking with Java 21.

The workaround for the stream issue is below:
----

require 'fcntl'
flags = write.fcntl(Fcntl::F_GETFL)
# We must first set nonblock because the Java and JRuby objects wrapping the stream do not know it is already non-blocking
write.fcntl(Fcntl::F_SETFL, flags | (Fcntl::O_NONBLOCK))
write.fcntl(Fcntl::F_SETFL, flags & (~Fcntl::O_NONBLOCK))
----

Related branches

Vladimir Petko (vpa1977)
description: updated
summary: - flaky jruby TestOpen3 pipe tests
+ jruby: mri-extra - flaky TestOpen3 pipe tests
tags: added: update-excusse
tags: added: update-excuse
removed: update-excusse
description: updated
Revision history for this message
Vladimir Petko (vpa1977) wrote :

Note: spec-ruby and mri-stdlib fail occasionally during autopkgtest run in cloud, but pass locally.

Revision history for this message
Vladimir Petko (vpa1977) wrote :
Revision history for this message
Vladimir Petko (vpa1977) wrote :
Vladimir Petko (vpa1977)
description: updated
Vladimir Petko (vpa1977)
description: updated
Vladimir Petko (vpa1977)
description: updated
Changed in jruby (Debian):
status: Unknown → New
Revision history for this message
Vladimir Petko (vpa1977) wrote :

openjdk-21 has fixed pipe issue in 21.0.3~7ea-1.
https://launchpad.net/ubuntu/+source/openjdk-21/21.0.3~7ea-1

Changed in java-common (Ubuntu):
status: New → Fix Released
Changed in openjdk-21 (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.