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 6.12.0.206 crashes on a simple console app with nested .NET tasks. #21762

Open
GarfieldJiang opened this issue May 3, 2024 · 1 comment

Comments

@GarfieldJiang
Copy link

Steps to Reproduce

  1. Create a ConsoleApp in IDE (like rider)
  2. Write the following code.
using System;
using System.Threading.Tasks;

public static class Program
{
    public static async Task Main()
    {
        Console.WriteLine(TaskScheduler.Current);
        var res = await Task.Run(() =>
        {
            var s = 0;
            s = 5050;
            s += 10;
            Task.Run(async () =>
            {    
                Console.WriteLine("Inner task starts");
                await Task.Delay(1000);
                Console.WriteLine("Inner task ends");
            });
            Console.WriteLine("outer task ends");
            return s;
        });
        Console.WriteLine(res);
    }
}
  1. Run it.

Current Behavior

It crashes.

Expected Behavior

It should work well (Use .NET fiddle to test)

On which platforms did you notice this

[x] macOS
[ ] Linux
[ ] Windows

Version Used:

6.12.0.206 or 180

Stacktrace

Please paste the stack trace here if available.
/usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen /Users/jianghan/RiderProjects/ConsoleApp1/ConsoleApp1/bin/Debug/net48/ConsoleApp1.exe
System.Threading.Tasks.ThreadPoolTaskScheduler
outer task ends
Inner task starts
5060
* Assertion at object.c:585, condition `is_ok (error)' not met, function:mono_runtime_class_init_full, (null) assembly:/usr/local/Cellar/mono/6.12.0.206/lib/mono/4.5/mscorlib.dll type:ThreadAbortException member:(null)


=================================================================
        Native Crash Reporting
=================================================================
Got a abrt while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
        Native stacktrace:
=================================================================
        0x10ac999e5 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : mono_dump_native_crash_info
        0x10ac42f00 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : mono_handle_native_crash
        0x10ac991a1 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : sigabrt_signal_handler
        0x7ff80f50037d - /usr/lib/system/libsystem_platform.dylib : _sigtramp
        0x7ff80f2f2e85 - /usr/lib/system/libsystem_malloc.dylib : nanov2_realloc
        0x7ff80f3f1a4d - /usr/lib/system/libsystem_c.dylib : abort
        0x10ae373b2 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : monoeg_g_printv
        0x10ae1f474 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : mono_log_write_logfile
        0x10ae37712 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : monoeg_g_logv_nofree
        0x10ae37864 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : monoeg_assertion_message
        0x10ad75083 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : mono_runtime_class_init_full
        0x10abc458f - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : mono_resolve_patch_target
        0x10ac32643 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : init_method
        0x10ac33585 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : load_method
        0x10ac30925 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : mono_aot_get_method_from_token
        0x10ac45e46 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : mono_aot_trampoline
        0x10afdbb13 - Unknown
        0x10dce312b - /usr/local/Cellar/mono/6.12.0.206/lib/mono/4.5/mscorlib.dll.dylib : System_Threading_Timer_Change_long_long_bool
        0x10de66a3f - /usr/local/Cellar/mono/6.12.0.206/lib/mono/4.5/mscorlib.dll.dylib : System_Runtime_CompilerServices_AsyncTaskMethodBuilder_Start_TStateMachine_REF_TStateMachine_REF_
        0x10b4d11f3 - Unknown
        0x10dd040dc - /usr/local/Cellar/mono/6.12.0.206/lib/mono/4.5/mscorlib.dll.dylib : System_Threading_Tasks_Task_ExecutionContextCallback_object
        0x10dcd2493 - /usr/local/Cellar/mono/6.12.0.206/lib/mono/4.5/mscorlib.dll.dylib : System_Threading_ExecutionContext_Run_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool
        0x10dd0401d - /usr/local/Cellar/mono/6.12.0.206/lib/mono/4.5/mscorlib.dll.dylib : System_Threading_Tasks_Task_ExecuteEntry_bool
        0x10dcdaabd - /usr/local/Cellar/mono/6.12.0.206/lib/mono/4.5/mscorlib.dll.dylib : System_Threading__ThreadPoolWaitCallback_PerformWaitCallback
        0x10abc94f0 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : mono_jit_runtime_invoke
        0x10ad786c1 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : do_runtime_invoke
        0x10ad9abc0 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : worker_callback
        0x10acec34f - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : worker_thread
        0x10ad9834d - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : start_wrapper_internal
        0x10ad981e9 - /usr/local/Cellar/mono/6.12.0.206/bin/mono-sgen : start_wrapper
        0x7ff80f4d3202 - /usr/lib/system/libsystem_pthread.dylib : _pthread_start
        0x7ff80f4cebab - /usr/lib/system/libsystem_pthread.dylib : thread_start

=================================================================
        Telemetry Dumper:
=================================================================
Pkilling 0x123145566117888x from 0x123145573519360x
Pkilling 0x140704515538560x from 0x123145573519360x
Entering thread summarizer pause from 0x123145573519360x
Finished thread summarizer pause from 0x123145573519360x.
Failed to create breadcrumb file (null)/crash_hash_0x2ab06f5085

Waiting for dumping threads to resume

=================================================================
        External Debugger Dump:
=================================================================

=================================================================
        Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x7ff80f49a7a6):0x7ff80f49a796  ff ff c3 90 90 90 b8 48 01 00 02 49 89 ca 0f 05  .......H...I....
0x7ff80f49a7a6  73 08 48 89 c7 e9 d4 99 ff ff c3 90 90 90 b8 53  s.H............S
0x7ff80f49a7b6  00 00 02 49 89 ca 0f 05 73 08 48 89 c7 e9 bc 99  ...I....s.H.....
0x7ff80f49a7c6  ff ff c3 90 90 90 b8 83 01 00 02 49 89 ca 0f 05  ...........I....

=================================================================
        Managed Stacktrace:
=================================================================
          at <unknown> <0xffffffff>
          at System.Threading.Timer:Change <0x000da>
          at System.Threading.Timer:Init <0x000a5>
          at System.Threading.Timer:.ctor <0x0005b>
          at System.Threading.Timer:.ctor <0x000a2>
          at System.Threading.Tasks.Task:Delay <0x002f3>
          at System.Threading.Tasks.Task:Delay <0x00032>
          at <<Main>b__0_1>d:MoveNext <0x00092>
          at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start <0x0007e>
          at <>c:<Main>b__0_1 <0x00142>
          at System.Threading.Tasks.Task`1:InnerInvoke <0x00069>
          at System.Threading.Tasks.Task:Execute <0x00037>
          at System.Threading.Tasks.Task:ExecutionContextCallback <0x0005b>
          at System.Threading.ExecutionContext:RunInternal <0x00191>
          at System.Threading.ExecutionContext:Run <0x00042>
          at System.Threading.Tasks.Task:ExecuteWithThreadLocal <0x000f6>
          at System.Threading.Tasks.Task:ExecuteEntry <0x000dc>
          at System.Threading.Tasks.Task:System.Threading.IThreadPoolWorkItem.ExecuteWorkItem <0x00026>
          at System.Threading.ThreadPoolWorkQueue:Dispatch <0x00279>
          at System.Threading._ThreadPoolWaitCallback:PerformWaitCallback <0x0001c>
          at <Module>:runtime_invoke_bool <0x000a5>
=================================================================

@GarfieldJiang
Copy link
Author

So this is simply ignored?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant