Skip to content

JRuby's native SortedSet lies about adding an object #5035

@chuckremes

Description

@chuckremes

Environment

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)
    jruby 9.2.0.0-SNAPSHOT (2.4.1) 2018-02-01 aa2ea83 Java HotSpot(TM) 64-Bit Server VM 25.144-b01 on 1.8.0_144-b01 +jit [darwin-x86_64]

  • Operating system and platform (e.g. uname -a)
    Darwin Charless-Air 16.7.0 Darwin Kernel Version 16.7.0: Mon Nov 13 21:56:25 PST 2017; root:xnu-3789.72.11~1/RELEASE_X86_64 x86_64

Other relevant info you may wish to add:

  • Installed or activated gems
  • Application/framework version (e.g. Rails, Sinatra)
  • Environment variables
    RUN ulimit -n 2000 before following the directions to duplicate the error.

Expected Behavior

  • Describe your expectation of how JRuby should behave, perhaps by showing how CRuby/MRI behaves.

Script should exit after about 60 seconds back to a command prompt.

Actual Behavior

The program hangs indefinitely. After diving into the guts of the issue, a Timers class that I wrote is the culprit. It uses SortedSet to keep track of timers. At some point during execution, several timers that are supposedly added to the set are not actually recorded. I discovered this when asserting in my code that @timers.size == @timers.to_a.size and having it fail. I tried to add a similar assert to the Java code but while it compiles it doesn't actually seem to work. Since not all timers fire, another check within my program prevents it from exiting, however the bug is caused by a flaw in SortedSet.

Here's how to reproduce the issue.

  1. % git clone git@github.com:chuckremes/ruby-io.git
  2. `cd ruby-io/examples
  3. git checkout b2be9780d2272c6a2e178f48a74333193ea536b2
  4. ulimit -n 2000 # give yourself a few more file descriptors than the 256 default
  5. ruby echo_tcp.rb
  6. Program will exit when the @Timers object gets out of synch. I recommend adding an assert to the Java code to figure out why the size of the hash and the size of the TreeSet are diverging.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions