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][gshared] generic instance function pointer crash #66337

Closed
lambdageek opened this issue Mar 8, 2022 · 5 comments
Closed

[mono][gshared] generic instance function pointer crash #66337

lambdageek opened this issue Mar 8, 2022 · 5 comments
Assignees
Milestone

Comments

@lambdageek
Copy link
Member

using System;
public unsafe class C {
    public static void GenericMethod<T>() {
        Console.WriteLine ($"T was {typeof(T).FullName}");
    }
    public void M() {
        delegate* <void> fp = &GenericMethod<string>;
        fp ();
    }

    public void N<T>() {
       delegate* <void> fp = &GenericMethod<T>;
       fp ();
    }

    public static void Main() {
        var c = new C();
        c.M();
        c.N<string>();
    }
}

Expected:

T was System.String
T was System.String

Actual: Crash.
Backtrace:

(lldb) monobt
* thread #1
  * frame #0: 0x00007ff81f7313da libsystem_kernel.dylib`__semwait_signal + 10
    frame #1: 0x00007ff81f6468a9 libsystem_c.dylib`nanosleep + 196
    frame #2: 0x000000010c8192b5 libcoreclr.dylib`monoeg_g_usleep(microseconds=1000000) at gdate-unix.c:78:9 [opt]
    frame #3: 0x000000010c776f7a libcoreclr.dylib`mono_handle_native_crash(signal="SIGSEGV", mctx=0x00007ff7b3fe7d08, info=0x00007ff7b3fe8328) at mini-exceptions.c:3003:4 [opt]
    frame #4: 0x000000010c6cf35b libcoreclr.dylib`mono_sigsegv_signal_handler_debug(_dummy=11, _info=0x00007ff7b3fe8328, context=0x00007ff7b3fe8390, debug_fault_addr=0x00000000ffffff18) at mini-runtime.c:3727:3 [opt]
    frame #5: 0x00007ff81f780e2d libsystem_platform.dylib`_sigtramp + 29
    frame #6: 0x10c06ee84<0x10c06ee84 - rgctx_fetch_trampoline_mrgctx_0 trampoline>
    frame #7: 0x000000010c6d2472 libcoreclr.dylib`mono_jit_runtime_invoke(method=<unavailable>, obj=<unavailable>, params=0x00007ff7b3fe85f8, exc=<unavailable>, error=<unavailable>) at mini-runtime.c:3513:12 [opt]
    frame #8: 0x000000010c5f11c8 libcoreclr.dylib`mono_runtime_invoke_checked [inlined] do_runtime_invoke(method=0x00007f9e18f055d8, obj=0x0000000000000000, params=0x00007ff7b3fe85f8, exc=0x0000000000000000, error=0x00007ff7b3fe8638) at object.c:2399:11 [opt]
    frame #9: 0x000000010c5f1192 libcoreclr.dylib`mono_runtime_invoke_checked(method=0x00007f9e18f055d8, obj=0x0000000000000000, params=0x00007ff7b3fe85f8, error=0x00007ff7b3fe8638) at object.c:2567:9 [opt]
    frame #10: 0x000000010c5f915c libcoreclr.dylib`do_exec_main_checked(method=0x00007f9e18f055d8, args=<unavailable>, error=0x00007ff7b3fe8638) at object.c:0 [opt]
    frame #11: 0x000000010c5f80a0 libcoreclr.dylib`mono_runtime_run_main_checked [inlined] mono_runtime_exec_main_checked(method=<unavailable>, args=<unavailable>, error=<unavailable>) at object.c:4513:9 [opt] [artificial]
    frame #12: 0x000000010c731492 libcoreclr.dylib`mono_jit_exec at driver.c:1379:13 [opt]
    frame #13: 0x000000010c731484 libcoreclr.dylib`mono_jit_exec(domain=<unavailable>, assembly=<unavailable>, argc=1, argv=0x00006000010c9930) at driver.c:1324:7 [opt]
    frame #14: 0x000000010c734a66 libcoreclr.dylib`mono_main [inlined] main_thread_handler(user_data=<unavailable>) at driver.c:1456:3 [opt]
    frame #15: 0x000000010c734a2e libcoreclr.dylib`mono_main(argc=<unavailable>, argv=<unavailable>) at driver.c:2683:3 [opt]
    frame #16: 0x000000010c7afb03 libcoreclr.dylib`monovm_execute_assembly(argc=<unavailable>, argv=0x0000000000000000, managedAssemblyPath="/Users/alklig/work/dotnet-runtime/runtime-bugs/artifacts/bin/HelloWorld/x64/Release/osx-x64/publish/HelloWorld.dll", exitCode=0x00007ff7b3fe8910) at monovm.c:268:14 [opt]
    frame #17: 0x000000010c15879d libhostpolicy.dylib`run_app_for_context(hostpolicy_context_t const&, int, char const**) + 1293
    frame #18: 0x000000010c159601 libhostpolicy.dylib`corehost_main + 241
    frame #19: 0x000000010c0e6555 libhostfxr.dylib`fx_muxer_t::handle_exec_host_command(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, host_startup_info_t const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::unordered_map<known_options, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, known_options_hash, std::__1::equal_to<known_options>, std::__1::allocator<std::__1::pair<known_options const, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > > const&, int, char const**, int, host_mode_t, bool, char*, int, int*) + 1621
    frame #20: 0x000000010c0e533d libhostfxr.dylib`fx_muxer_t::execute(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, char const**, host_startup_info_t const&, char*, int, int*) + 621
    frame #21: 0x000000010c0e1d38 libhostfxr.dylib`hostfxr_main_startupinfo + 152
    frame #22: 0x000000010bf23795 HelloWorld`exe_start(int, char const**) + 1573
    frame #23: 0x000000010bf239af HelloWorld`main + 143
    frame #24: 0x00000001169e94fe dyld`start + 462
@lambdageek lambdageek added this to the 7.0.0 milestone Mar 8, 2022
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Mar 8, 2022
@lambdageek
Copy link
Member Author

/cc @vargaz @SamMonoRT

@lambdageek
Copy link
Member Author

Works with --interp, except there are some warnings:

Object.runtime_invoke_direct_void: Store local stack type mismatch 1 7
Object.runtime_invoke_direct_void: Store local stack type mismatch 1 7
C.Main: Store local stack type mismatch 1 7
C.Main: Store local stack type mismatch 1 7
C.M: Store local stack type mismatch 1 7
T was System.String
C.N: Store local stack type mismatch 1 7
T was System.String

@lambdageek
Copy link
Member Author

This is the same issue as mono/mono#20962

@jeffschwMSFT jeffschwMSFT removed the untriaged New issue has not been triaged by the area owner label Mar 28, 2022
@SamMonoRT
Copy link
Member

@BrzVlad -- I assume this is fixed by #66350 ? IF so, please close this issue.

@BrzVlad
Copy link
Member

BrzVlad commented Aug 4, 2022

yes

@BrzVlad BrzVlad closed this as completed Aug 4, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants