Skip to content
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

[mono] Context->method_inst is non-NULL but garbage on AOT #62334

Open
thaystg opened this issue Dec 3, 2021 · 4 comments
Open

[mono] Context->method_inst is non-NULL but garbage on AOT #62334

thaystg opened this issue Dec 3, 2021 · 4 comments
Assignees
Labels
area-Codegen-AOT-mono disabled-test The test is disabled in source code against the issue
Milestone

Comments

@thaystg
Copy link
Member

thaystg commented Dec 3, 2021

The new test from #60770

Loader/classloader/DefaultInterfaceMethods/regressions/github60486/github60486.sh

Test from #60770 is failing on the AOT lane - looks like context->method_inst is non-NULL but garbage:

https://helix.dot.net/api/2019-06-17/jobs/37967d43-ee2b-411f-aa01-5e4f6f0fab43/workitems/Loader.classloader/console

Look at collect_ginst_images in frame 6

      Thread 1 (Thread 0x7f5b14887740 (LWP 15280)):
      #0  0x00007f5b1426032a in __waitpid (pid=15312, stat_loc=0x7fff9c8a4840, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
      #1  0x00007f5b11ea4917 in dump_native_stacktrace (signal=<optimized out>, mctx=<optimized out>) at /__w/1/s/src/mono/mono/mini/mini-posix.c:842
      #2  mono_dump_native_crash_info (signal=<optimized out>, mctx=0x7fff9c8a53b0, info=<optimized out>) at /__w/1/s/src/mono/mono/mini/mini-posix.c:869
      #3  0x00007f5b11e46a1e in mono_handle_native_crash (signal=0x7f5b116e9be9 "SIGSEGV", mctx=0x7fff9c8a53b0, info=0x7fff9c8a5670) at /__w/1/s/src/mono/mono/mini/mini-exceptions.c:2947
      #4  0x00007f5b11da6741 in mono_sigsegv_signal_handler_debug (_dummy=11, _info=0x7fff9c8a5670, context=0x7fff9c8a5540, debug_fault_addr=0x17) at /__w/1/s/src/mono/mono/mini/mini-runtime.c:3709
      #5  <signal handler called>
      #6  collect_ginst_images (ginst=0x13, data=0x7fff9c8a5af8) at /__w/1/s/src/mono/mono/metadata/metadata.c:3031
      #7  collect_method_images (method=0x55dba8cdb080, data=0x7fff9c8a5af8) at /__w/1/s/src/mono/mono/metadata/metadata.c:3074
      #8  mono_metadata_get_mem_manager_for_method (method=0x55dba8cdb080) at /__w/1/s/src/mono/mono/metadata/metadata.c:3324
      #9  0x00007f5b11c6a4ff in mono_class_inflate_generic_method_full_checked (method=0x55dba84312c0, klass_hint=<optimized out>, context=0x7fff9c8a5da8, error=0x7fff9c8a5db8) at /__w/1/s/src/mono/mono/metadata/class.c:1210
      #10 0x00007f5b11e43871 in get_method_from_stack_frame (ji=0x55dba8ceac00, generic_info=0x55dba8407e28) at /__w/1/s/src/mono/mono/mini/mini-exceptions.c:899
      #11 0x00007f5b11e44323 in ves_icall_get_frame_info (skip=-1, need_file_info=1 '\001', method=0x7fff9c8a6370, iloffset=0x7fff9c8a6360, native_offset=0x7fff9c8a6364, file=0x7fff9c8a6378, line=0x7fff9c8a6368, column=0x7fff9c8a636c) at /__w/1/s/src/mono/mono/mini/mini-exceptions.c:1465
      #12 0x0000000041bfc3da in ?? ()
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Dec 3, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@thaystg thaystg changed the title [mono] Context->method_inst is non-NULL but garbage [mono] Context->method_inst is non-NULL but garbage on AOT Dec 3, 2021
@lambdageek
Copy link
Member

We backported the original fix to mono/mono#21356 - will need to update there too

@lambdageek lambdageek added this to the 7.0.0 milestone Dec 3, 2021
@lambdageek lambdageek added disabled-test The test is disabled in source code against the issue and removed untriaged New issue has not been triaged by the area owner labels Dec 3, 2021
@lambdageek
Copy link
Member

/cc @vargaz

@lambdageek
Copy link
Member

lambdageek commented Dec 3, 2021

frame 10 is get_method_from_stack_frame

context = mono_get_generic_context_from_stack_frame (ji, generic_info);
method = jinfo_get_method (ji);
method = mono_method_get_declaring_generic_method (method);
method = mono_class_inflate_generic_method_checked (method, &context, error);

which calls mono_get_generic_context_from_stack_frame
that has new code

context.method_inst = mrgctx->method_inst;
if (!mini_method_is_default_method (method))
g_assert (context.method_inst);

which is setting method_inst to something from mrgctx

And then that context is passed to mono_class_inflate_generic_method_checked and from there we get the stack trace in the crash

bholmes added a commit to Unity-Technologies/runtime that referenced this issue Jan 31, 2022
The context is a MonoMethodRuntimeGenericContext when the method is a
default interface method.

Also re-enable broken DIM tests.

Fixes dotnet/runtime dotnet#62334
lambdageek pushed a commit to monojenkins/mono that referenced this issue Feb 2, 2022
The context is a MonoMethodRuntimeGenericContext when the method is a
default interface method.

Related to dotnet/runtime#62334
bholmes added a commit to Unity-Technologies/mono that referenced this issue Feb 3, 2022
The context is a MonoMethodRuntimeGenericContext when the method is a
default interface method.

Related to dotnet/runtime#62334
lambdageek pushed a commit that referenced this issue Feb 4, 2022
…ods (#64566)

The context is a MonoMethodRuntimeGenericContext when the method is a
default interface method.

Also re-enable broken DIM tests.

Fixes dotnet/runtime #62334
lambdageek pushed a commit to mono/mono that referenced this issue Feb 8, 2022
…ace 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 dotnet/runtime#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 dotnet/runtime#62334

Co-authored-by: thaystg <thaystg@users.noreply.github.com>
Co-authored-by: Bill Holmes <bill.holmes@unity3d.com>
schoudhary-rythmos pushed a commit to Unity-Technologies/mono that referenced this issue Mar 4, 2022
The context is a MonoMethodRuntimeGenericContext when the method is a
default interface method.

Related to dotnet/runtime#62334
schoudhary-rythmos pushed a commit to Unity-Technologies/mono that referenced this issue Mar 4, 2022
The context is a MonoMethodRuntimeGenericContext when the method is a
default interface method.

Related to dotnet/runtime#62334
@SamMonoRT SamMonoRT modified the milestones: 7.0.0, 8.0.0 Aug 4, 2022
@SamMonoRT SamMonoRT modified the milestones: 8.0.0, 9.0.0 Jul 25, 2023
@SamMonoRT SamMonoRT assigned ivanpovazan and unassigned jandupej Oct 25, 2023
@ivanpovazan ivanpovazan modified the milestones: 9.0.0, Future Feb 9, 2024
ThomasKuehne pushed a commit to ThomasKuehne/mono that referenced this issue Mar 23, 2024
…ace method (mono#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 dotnet/runtime#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 dotnet/runtime#62334

Co-authored-by: thaystg <thaystg@users.noreply.github.com>
Co-authored-by: Bill Holmes <bill.holmes@unity3d.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Codegen-AOT-mono disabled-test The test is disabled in source code against the issue
Projects
None yet
Development

No branches or pull requests

5 participants