Skip to content

JRuby thread safety test nondeterministically fails #383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JacobEvelyn opened this issue May 6, 2025 · 4 comments
Open

JRuby thread safety test nondeterministically fails #383

JacobEvelyn opened this issue May 6, 2025 · 4 comments

Comments

@JacobEvelyn
Copy link
Member

JacobEvelyn commented May 6, 2025

In this CI run, running against 403a4e7 with this JRuby version:

jruby 10.0.0.0 (3.4.2) 2025-04-13 6ed59bc847 OpenJDK 64-Bit Server VM 21.0.7+6-LTS on 21.0.7+6-LTS +indy +jit [x86_64-linux]

we got the following test failure:

Failures:

  1) thread safety when the method takes one positional argument when the method has already been called with another argument behaves like provides thread safety guarantees when checking condition: are different values returned? returns different values to each thread, and memoizes one of them
     Failure/Error: expect(thread_return_values.uniq.size).to be > 1

       expected: > 1
            got:   1
     Shared Example Group: "provides thread safety guarantees" called from ./spec/thread_safety_spec.rb:102
     # ./spec/thread_safety_spec.rb:74:in 'block in <main>'

Finished in 3 minutes 48.4 seconds (files took 1.67 seconds to load)
616 examples, 1 failure

Failed examples:

rspec './spec/thread_safety_spec.rb[1:2:1:1:2:1]' # thread safety when the method takes one positional argument when the method has already been called with another argument behaves like provides thread safety guarantees when checking condition: are different values returned? returns different values to each thread, and memoizes one of them

Randomized with seed 5952
@JacobEvelyn
Copy link
Member Author

This failed again in this CI run, running against 5720bf6 on the same JRuby version as above:

jruby 10.0.0.0 (3.4.2) 2025-04-13 6ed59bc847 OpenJDK 64-Bit Server VM 21.0.7+6-LTS on 21.0.7+6-LTS +indy +jit [x86_64-linux]

with the following test failure:

Failures:

  1) thread safety when the method takes required and optional positional arguments when the method has already been called with other arguments behaves like provides thread safety guarantees when checking condition: are different values returned? returns different values to each thread, and memoizes one of them
     Failure/Error: expect(thread_return_values.uniq.size).to be > 1

       expected: > 1
            got:   1
     Shared Example Group: "provides thread safety guarantees" called from ./spec/thread_safety_spec.rb:136
     # ./spec/thread_safety_spec.rb:74:in 'block in <main>'

Finished in 3 minutes 36.3 seconds (files took 1.61 seconds to load)
616 examples, 1 failure

Failed examples:

rspec './spec/thread_safety_spec.rb[1:4:1:1:2:1]' # thread safety when the method takes required and optional positional arguments when the method has already been called with other arguments behaves like provides thread safety guarantees when checking condition: are different values returned? returns different values to each thread, and memoizes one of them

Randomized with seed 49988

@ms-ati
Copy link
Contributor

ms-ati commented May 7, 2025

Ah. A possible path is to conditionally include concurrent-ruby on JRuby, or even just use it if its already included, so that we use thread-safe Array and Hash?

@JacobEvelyn
Copy link
Member Author

I'm hesitant to introduce a dependency, which would be a departure from how this library has existed thus far. @ms-ati do you have a clear understanding of what's causing the bug? I haven't investigated it.

@JacobEvelyn
Copy link
Member Author

Note that this may be caused by the same underlying issue as #264

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants