-
Notifications
You must be signed in to change notification settings - Fork 185
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
New test failure in the Zeitwerk test suite #2431
Comments
Like to have CI green. Lately, TruffleRuby has been flaky in the concurrency test. Don't know why, opened an issue oracle/truffleruby#2431 When we figure it out, I'll restore it.
This is a shell script that essentially does the same as the flaky test: #!/bin/sh
cat <<EOS > m.rb
module M
sleep 0.5
def self.works?
true
end
end
EOS
ruby -I. <<EOS
autoload :M, "m"
t = Thread.new { M }
p M.works?
EOS
rm m.rb If it passes, you see "true" printed. Otherwise, |
With CRuby, that passes even with |
Thanks a lot for the report. In short this is not yet implemented in TruffleRuby (IIRC), because of unclear semantics. Re Zeitwerk CI, could you exclude this test for TruffleRuby and keep running other tests? If it passed before I would think it was just lucky timings. |
BTW to improve the reliability of that test I believe you would need a sleep (smaller, e.g. of 0.1) between the Thread.new and |
Problem is, this is a fundamental property of Zeitwerk, which is a fundamental property of CRuby: You won't see a class half-defined due to context switching while autoloading. Meaning, what the test does (of course, a class may be reopened elsewhere later, not in a generic sense).
You're right. |
Test revised here: fxn/zeitwerk@016404c. Thanks for the comment about that :). |
Hey! I have documented this in the README. I believe it is accurate, but let me know if it should word it in a different way :). |
That looks accurate, I'll try to fix this issue soon. |
Like to have CI green. Lately, TruffleRuby has been flaky in the concurrency test. Don't know why, opened an issue oracle/truffleruby#2431 When we figure it out, I'll restore it.
Some more details about how CRuby handles this: ruby/ruby#5788
|
I'm slowly figuring out how it works, I guess it's not a bad implementation, but I think |
FWIW, I found https://bugs.ruby-lang.org/issues/15663#change-77214 where I asked some autoload questions and which makes it somewhat clear it's so complex nobody understands it fully. |
I am not familiar with the implementation, but isn't |
@fxn
The general strategy for autoload seems to not publish a constant's value while the file is being loaded (so other threads cannot see it's set and continue executing, they have to block and wait), and instead the autoload logic stashes the value somewhere so only that thread can see it, and then publish the constant at once when the file has been loaded. |
@eregon But if |
Something that could be relevant in @ioquatix |
So, let me repeat the question. The example sets autoloads for two constants, pointing to the same file. Since that is synchronized, why aren't the autoloads? I'd expect the second one to trigger a This argument is incorrect, as shown by the tests, but in what sense? |
Like to have CI green. Lately, TruffleRuby has been flaky in the concurrency test. Don't know why, opened an issue oracle/truffleruby#2431 When we figure it out, I'll restore it.
Like to have CI green. Lately, TruffleRuby has been flaky in the concurrency test. Don't know why, opened an issue oracle/truffleruby#2431 When we figure it out, I'll restore it.
Hi!
The suite of Zeitwerk has this test to check autoloading blocks context switching (autoloading is thread-safe):
It has passed regularly for a long time, but it started to fail in a flaky way both in
truffleruby
and intruffleruby-head
. See for example this build, or this build.Does it ring a bell?
The text was updated successfully, but these errors were encountered: