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
fix(ruby): Fix various exceptions in Ruby on 64-bit Windows #8563
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our direct concern is that an
intptr_t
divided by 4 can fit in afixnum
. This seems like a slightly roundabout way of checking that.Perhaps we could do:
I also notice there is some extraneous code left in the function below. And we should change to use
INT2FIX()
so we get a loud error when our check is incorrect. How about we do this:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the preprocessor check: I was actually doing this based on value.h which doesn't depend on
intptr_t
(andINTPTR_MAX
) being defined, but conditionally definesVALUE
(and its size) differently depending on what's available. Ruby has already definedVALUE
as a proxy for a pointer, andSIZEOF_VALUE
as the size thereof, and I think we should use the abstraction it provides. In fact, for better compatibility, I might argue that we also should avoid depending onintptr_t
, and useVALUE
instead:Regarding the two extraneous lines, I'll remove them.
Regarding using
INT2FIX
, I don't think we can do that. The whole point is that on Win64, it may not be a Fixnum, and we have to reinstate the secondary Hash to compensate.Pushed an update with the above suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right re:
INT2FIX
. UsingVALUE
seems reasonable, as it is typedef'd touintptr_t
.This is the check I should have suggested:
In other words, after the secondary map step, the key must be a fixnum for the main object cache to be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't think we can do that either. In the case where the secondary map is in use, the key is an arbitrary object, not a Fixnum. (We know it's not going to get collected because the secondary map is holding on to it.)
Incidentally, that
rb_eval_string("Object.new")
should also be changed to something less heavyweight (i.e. not involving parsing Ruby code) since it's part of the inner loop, called every time the cache is accessed. I changed it to a call torb_class_new_instance
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're absolutely right. Thanks for the changes.