Skip to content
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

Mocking Process.clock_gettime causes Concurrent::IVar with timeout to wait indefinitely #425

Closed
olly opened this issue Jun 6, 2024 · 5 comments · Fixed by #427
Closed

Comments

@olly
Copy link

olly commented Jun 6, 2024

Updating Timecop to v0.9.9 caused some of our system integration tests which utilise frozen time to wait indefinitely. I managed to narrow it down to the change introduced in 3a0b567.

We initially noticed it in a system integration test which used capybara & cuprite to drive a browser. However on further investigation I believe the root cause it down to ferrum's use of a Concurrent::IVar.

I've created a minimal test case which can reproduce the issue.

It appears the concurrent-ruby uses monotonic time to determine whether a timeout has been passed, and therefore by stubbing the monotonic clock it never causes a timeout.


I'm not sure what the exact resolution of this should be. I can see the value in being able to stub the monotonic clock, but perhaps it's too low level to stub by default? I imagine if this impacts a number of concurrent-ruby data structures then it might cause Timecop to be unusable in a large number of testing scenarios.


Thanks for all your hard-work on this gem. ❤️

@nerdrew
Copy link
Contributor

nerdrew commented Jun 10, 2024

Can we make stubbing Process.clock_gettime a configurable option when freeze-ing or travel-ing?

@joshuacronemeyer
Copy link
Collaborator

@alexcwatt any chance you can look at this? I think @nerdrew's suggestion is one viable option. Should we make this option disabled by default? Interested in opinions on this.

@joshuacronemeyer
Copy link
Collaborator

thanks @olly for raising this issue. i'm hopeful we can have a solution and get a 0.9.10 release out quickly

@alexcwatt
Copy link
Contributor

@joshuacronemeyer 👀 will take a look

@alexcwatt
Copy link
Contributor

@olly Thanks again for flagging. I cloned your gist, changed Ruby version to 3.2.1 (that's what I have on this MacBook), and was able to repro the issue. Then I upgraded timecop to 0.9.10 and validated the fix - the test doesn't hang.

@joshuacronemeyer I can't close this but based on validation it seems safe to close, and let @olly reopen if there is something we've missed here.

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

Successfully merging a pull request may close this issue.

4 participants