-
-
Notifications
You must be signed in to change notification settings - Fork 922
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
Hash#any? not always returning proper keys/values #5398
Comments
cc @ChrisBr Hashing hasn't really changed, has it? |
I confirmed the logic for hashing a thread does not appear to have changed...or at least RubyThread#hashCode has not changed since 2017. |
Could be a problem with Hash#any? not passing the args through properly? Here's the errors that result from running what @enebo described:
The line in question, in share_lock.rb, is the def busy_for_sharing?(purpose)
(@exclusive_thread && @exclusive_thread != Thread.current) ||
@waiting.any? { |t, (_, c)| t != Thread.current && !c.include?(purpose) }
end So there's a possibility the variables are not being destructured right, or the data stored in the hash is not structured right. |
Hmm, no idea! I will have a look at it tonight or over the weekend... |
I do not think this is destructuring issue per se but that the @waiting values end up wrong...when it runs correctly I think eventually we end up with key/values like: #Thread:0x63b86a9d / [:unload, [:unload, :load]] but when we crash we end up with #Thread:0x686d396a / : [:load, [:load]]. I am guessing some virtue of the test eventually removes all these single element nested array? I have not actually tried to understand the point of this test yet so perhaps I should now :) I should add my glance ot hashCode being called and I see nothing obviously wrong but that this seems to break right from the point of the new hashing stuff forward commit-wise. |
On second thought I realize @waiting is a hash so the first 't' is the key. So there is something weirder going on than I think... |
Move structuring out of any block params to print out k and value for any? and I see nil, nil as the key and value. If I print out the hash immediately before any? I can see a hash with at least an entry which appears to look fine. Another weird item is it appears to not happen 100% of the runs. I half feel like somehow our hashing changes because the thread state changes and it cannot find the key so we end up with nil,nil???? |
I believe I figured this out....I notice inspect() uses our standard visitor and it has explicit logic when walking entries to skip pairs which contain null. I am guessing once we delete hash elements we gain holes in the hash? Once I add a continue for this in any_p_* the test passes. |
Dumping progress on regression in activesupport test.
checkout rails v5.1.6 and cd into activesupport.
run:
Somewhere around new hashing algorithm this test seems to fail. Possible bisects it failed at are (none of these commits compiled properly):
The text was updated successfully, but these errors were encountered: