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
[class] relax assumption about origin of a class (can come from an dynamic image) #6035
Conversation
not sure if it's the right fix, please review and comment 🙂 |
{ | ||
return klass->type_token && !klass->image->dynamic && !mono_class_is_ginst (klass); | ||
return klass->type_token && !mono_class_is_ginst (klass); |
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.
this is the actual change
…namic image) check got introduced with ffc3aaa (in most places). fixes https://bugzilla.xamarin.com/show_bug.cgi?id=41130
d9f587c
to
43ae5c3
Compare
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.
So I don't think this approach is correct - SRE MonoImages don't have metadata.
In particular, calls like mono_class_get_first_field_idx
must assert for dynamic images:
- For one thing - metadata tokens in SRE are not consecutive for fields of the same class (create two TypeBuilders and interleave their DefineField calls and you'll get metadata tokens that go 1, 3, 5, 7... and 2, 4, 6, 8...).
- For another thing the changes in
class.c
are benign but misleading - they typically domono_class_get_first_field_idx
and then do calls tomono_metadata_field_info
with consecutive indices. None of that code gets called for SRE images (SRE does its own MonoClass setup), but if it did, it would be looking into tables that haven't been initialized. (For SRE Save they'll be filled when you call Save(), for SRE Run they may never be filled in).
I think we probably need to relax some mono_class_has_static_metadata
check someplace so that the Ldfld
example works, but changing it pervasively doesn't seem right.
Quick update. I took the test case So the problem is just the |
So the problem is in In this case it's called on a
The problem (as I mentioned above) is that for dynamic classes the offset of a Note that this is not a problem for methods because I think there are two possible ways to go:
|
Related: https://bugzilla.xamarin.com/show_bug.cgi?id=33208 Overall the constraints are:
I tried to get something that accomplishes both of those things in #3908 but I never got it reviewed or merged. It might be worth reviving. But I don't think I properly considered an example like the one in 41130. |
check got introduced with ffc3aaa (in most places).
fixes https://bugzilla.xamarin.com/show_bug.cgi?id=41130