diff options
author | monojenkins <jo.shields+jenkins@xamarin.com> | 2022-02-08 17:20:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-08 17:20:30 +0300 |
commit | ffae74c99a7d0466b101baae8c4a212e04cb34bb (patch) | |
tree | 6d40d3b8b9e9d5fb106820c7daf93aa2f3425f7a | |
parent | 7b8551f81ed91bd9220bd8935772a4586c8be016 (diff) |
[mono] Fix StackTrace from a dim and Vtable offsets for static interface method (#21356)
* [mono] Fix StackTrace from a dim and Vtable offsets for static interface method
- Fix StackTrace when called from a DIM.
- Fix the other test case that was added for @bholmes, and this case when the method `TestMethod5` was being called it was executing `TestMethod10`, and this was fixed skipping static interface methods when was calculating vtable offsets.
The fix was completely done by @vargaz, I just opened the PR.
Thanks @vargaz .
Fix https://github.com/dotnet/runtime/issues/60486
* mono_get_generic_info_from_stack_frame fix for default interface methods
The context is a MonoMethodRuntimeGenericContext when the method is a
default interface method.
Related to https://github.com/dotnet/runtime/issues/62334
Co-authored-by: thaystg <thaystg@users.noreply.github.com>
Co-authored-by: Bill Holmes <bill.holmes@unity3d.com>
-rw-r--r-- | mono/metadata/object.c | 2 | ||||
-rw-r--r-- | mono/mini/mini-exceptions.c | 13 |
2 files changed, 12 insertions, 3 deletions
diff --git a/mono/metadata/object.c b/mono/metadata/object.c index fb01a31cb5b..da03eae13e2 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -1567,6 +1567,8 @@ build_imt_slots (MonoClass *klass, MonoVTable *vt, MonoDomain *domain, gpointer* * add_imt_builder_entry anyway. */ method = mono_class_get_method_by_index (mono_class_get_generic_class (iface)->container_class, method_slot_in_interface); + if (m_method_is_static (method)) + continue; if (mono_method_get_imt_slot (method) != slot_num) { vt_slot ++; continue; diff --git a/mono/mini/mini-exceptions.c b/mono/mini/mini-exceptions.c index 144a61ad654..a5280f3a29d 100644 --- a/mono/mini/mini-exceptions.c +++ b/mono/mini/mini-exceptions.c @@ -832,7 +832,7 @@ mono_get_generic_info_from_stack_frame (MonoJitInfo *ji, MonoContext *ctx) } method = jinfo_get_method (ji); - if (mono_method_get_context (method)->method_inst) { + if (mono_method_get_context (method)->method_inst || mini_method_is_default_method (method)) { /* A MonoMethodRuntimeGenericContext* */ return info; } else if ((method->flags & METHOD_ATTRIBUTE_STATIC) || m_class_is_valuetype (method->klass)) { @@ -860,12 +860,13 @@ mono_get_generic_context_from_stack_frame (MonoJitInfo *ji, gpointer generic_inf method = jinfo_get_method (ji); g_assert (method->is_inflated); - if (mono_method_get_context (method)->method_inst) { + if (mono_method_get_context (method)->method_inst || mini_method_is_default_method (method)) { MonoMethodRuntimeGenericContext *mrgctx = (MonoMethodRuntimeGenericContext *)generic_info; klass = mrgctx->class_vtable->klass; context.method_inst = mrgctx->method_inst; - g_assert (context.method_inst); + if (!mini_method_is_default_method (method)) + g_assert (context.method_inst); } else { MonoVTable *vtable = (MonoVTable *)generic_info; @@ -878,6 +879,12 @@ mono_get_generic_context_from_stack_frame (MonoJitInfo *ji, gpointer generic_inf else method_container_class = method->klass; + if (mini_method_is_default_method (method)) { + if (mono_class_is_ginst (klass) || mono_class_is_gtd (klass)) + context.class_inst = mini_class_get_context (klass)->class_inst; + return context; + } + /* class might refer to a subclass of method's class */ while (!(klass == method->klass || (mono_class_is_ginst (klass) && mono_class_get_generic_class (klass)->container_class == method_container_class))) { klass = m_class_get_parent (klass); |