-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Possible autoload issue #2874
Comments
So far this does not appear to be related to autoload, and more likely related to threading. If I capture a heap dump at the point where this constant is found missing, I can see that indeed there is no BuiltIn constant defined in Matchers. However the logic for BuiltIn is loaded as a normal module. It's a module that itself defines several autoloads, but that should not be coming into play here. I also confirmed that theory by defining BuiltIn.autoload to just do the require immediately, thereby skipping any lazy loading logic. The issue remains. I suspect that multi-threaded access of a class's constants has a bug, perhaps two threads attempting to initialize the same class's constant table are creating two different constant maps. |
Ah-ha, I was wrong! Autoload is involved, but not at the BuiltIn level...the RSpec::Matchers constant is "autoloaded", albeit not the usual way (which is why I couldn't see it):
This logic is not thread-safe, but I have yet to determine if it's JRuby's fault or RSpecs. |
Ahh yes, now I understand. This is an RSpec bug. /cc @myronmarston @samphippen This logic is essentially the same problem as using defined?(SomeConst) to determine whether a library has been loaded. Here's a possible sequence leading to the error above.
Synchronizing const_missing does not help, because once the Matchers module is defined we won't even call it. Autoload is not at fault here obviously, but neither is require logic, since no amount of locking can prevent this code from possibly seeing a partially-initialized Matchers module. RSpec needs to change how it manages these constants. And finally, a detail I should have checked immediately...this happens in MRI too:
|
Filed rspec/rspec-dev#121. |
The script shown in this bug comment fails on JRuby: rubinius/rubinius#2934 (comment)
Failure:
Rubinius fails in a similar way. Could be an autoload threading problem. Investigating.
The text was updated successfully, but these errors were encountered: