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

Tracing GC on iOS yields mono_coop_cond_signal Cannot transition thread 0x2016c7280 from STATE_BLOCKING with DO_BLOCKING #88642

Closed
kcoop opened this issue Jul 10, 2023 · 8 comments
Assignees
Milestone

Comments

@kcoop
Copy link

kcoop commented Jul 10, 2023

Description

I'm seeing a Mono crash while trying to create a GC .nettrace file with dotnet-dstrace and dotnet-dsrouter in both Debug and Release Maui builds in the iOS simulator.

This appears to be a Mono issue, but I was directed here by the workflow, and I'm also wondering how @jonathanpeppers is successfully diagnosing leaks on iOS.

Steps to Reproduce

  1. Install dotnet-dsrouter, dotnet-trace
$ dotnet tool install --global dotnet-dsrouter
$ dotnet-dsrouter --version
WARNING: dotnet-dsrouter is a development tool not intended for production environments.

7.0.435501+b56bae8476fb1a944de6618b4aa2b602db05b8b3

$ dotnet tool install --global dotnet-trace
$ dotnet-trace --version
7.0.430602+c9c987585e1fa9a8a8a5e1ffb60a70f85b0da4ca
  1. Create a new default vanilla iOS Maui app, MauiTest, no changes.

  2. Install and run app on simulator (udid here is for iPhone 14, ymmv).

$ mlaunch --installsim ./MauiTest/bin/Debug/net7.0-ios/iossimulator-x64/MyApp.app --device :v2:udid=BCBF3C73-A566-44CB-96AB-D537EF55DD58
$ mlaunch --launchsim ./MauiTest/bin/Debug/net7.0-ios/iossimulator-x64/MauiTest.app --device :v2:udid=BCBF3C73-A566-44CB-96AB-D537EF55DD58 --wait-for-exit --stdout=$(tty) --stderr=$(tty) --argument --connection-mode --argument none '--setenv:DOTNET_DiagnosticPorts=127.0.0.1:9000,suspend,listen'
  1. Wait for
The runtime has been configured to pause during startup and is awaiting a Diagnostics IPC ResumeStartup command from a Diagnostic Port.
DOTNET_DiagnosticPorts="127.0.0.1:9000,suspend,listen"
DOTNET_DefaultDiagnosticPortSuspend=0
  1. Start dotnet-dsrouter
$ dotnet-dsrouter server-client -ipcs /tmp/maui-app-port -tcpc 127.0.0.1:9000  -v trace -rt 100 
  1. Run dotnet-trace
$ dotnet-trace collect --providers Microsoft-DotNETRuntimeMonoProfiler:0xC900003:4 --diagnostic-port /tmp/maui-app-port,connect

App crashes:

2023-07-10 15:43:40.871682-0700 MauiTest[88448:2223499] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=88448
2023-07-10 15:43:40.873708-0700 MauiTest[88448:2223499] SecTaskCopyDebugDescription: MauiTest[88448]/0#-1 LF=0
2023-07-10 15:43:40.962905-0700 MauiTest[88448:2223499] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=88448
2023-07-10 15:43:40.963121-0700 MauiTest[88448:2223499] SecTaskCopyDebugDescription: MauiTest[88448]/0#-1 LF=0
2023-07-10 15:43:41.603784-0700 MauiTest[88448:2224176] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=88448
2023-07-10 15:43:41.603959-0700 MauiTest[88448:2224176] SecTaskCopyDebugDescription: MauiTest[88448]/0#-1 LF=0
2023-07-10 15:43:41.818455-0700 MauiTest[88448:2223499] [TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <_UIMoreListTableView: 0x7fd063a8da00; frame = (0 0; 0 0); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x600002dedfe0>; backgroundColor = <UIDynamicSystemColor: 0x600003621a40; name = tableBackgroundColor>; layer = <CALayer: 0x6000027dada0>; contentOffset: {0, 0}; contentSize: {0, 0}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <UIMoreListController: 0x7fd05ca3ba00>>
2023-07-10 15:43:42.073033-0700 MauiTest[88448:2223499] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=88448
2023-07-10 15:43:42.073288-0700 MauiTest[88448:2223499] SecTaskCopyDebugDescription: MauiTest[88448]/0#-1 LF=0
2023-07-10 15:43:42.233265-0700 MauiTest[88448:2223499] error: mono_coop_cond_signal Cannot transition thread 0x2016c7280 from STATE_BLOCKING with DO_BLOCKING

=================================================================
        Native Crash Reporting
=================================================================
Got a SIGABRT 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:
=================================================================
        0x10a82e794 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : mono_dump_native_crash_info
        0x10a7d2aae - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : mono_handle_native_crash
        0x10a9dce38 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : sigabrt_signal_handler.cold.1
        0x10a82e0c8 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : sigabrt_signal_handler
        0x11c8bc5ed - /usr/lib/system/libsystem_platform.dylib : _sigtramp
        0x7fd05d013200 - Unknown
        0x11c246e58 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_c.dylib : abort
        0x10a0644a0 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libxamarin-dotnet-debug.dylib : _ZL12log_callbackPKcS0_S0_iPv
        0x10a877648 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : monoeg_g_logv
        0x10a8777e2 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : monoeg_g_log
        0x10a6cc400 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : mono_threads_transition_do_blocking
        0x10a6cd9c1 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : mono_threads_enter_gc_safe_region_unbalanced_with_info
        0x10a671cdf - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : mono_w32handle_set_signal_state
        0x10a5e4f99 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : mono_w32event_set
        0x109f38a4c - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmono-component-diagnostics_tracing.dylib : ep_buffer_manager_write_event
        0x109f3dc9e - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmono-component-diagnostics_tracing.dylib : ep_session_write_event
        0x109f35e3e - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmono-component-diagnostics_tracing.dylib : write_event_2
        0x109f35ab1 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmono-component-diagnostics_tracing.dylib : ep_write_event
        0x109f54473 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmono-component-diagnostics_tracing.dylib : EventPipeWriteEventMonoProfilerGCHandleDeleted
        0x109f47cd2 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmono-component-diagnostics_tracing.dylib : mono_profiler_gc_handle_deleted
        0x10a666100 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : mono_profiler_raise_gc_handle_deleted
        0x10a0607f7 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libxamarin-dotnet-debug.dylib : xamarin_gchandle_free
        0x10a070cc8 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libxamarin-dotnet-debug.dylib : xamarin_invoke_trampoline
        0x10a077de9 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libxamarin-dotnet-debug.dylib : xamarin_arch_trampoline
        0x10a078fca - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libxamarin-dotnet-debug.dylib : xamarin_x86_64_common_trampoline
        0x129ffa083 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
        0x1188e0d98 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/QuartzCore.framework/QuartzCore : _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE
        0x129fe563c - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIView(Hierarchy) layoutBelowIfNeeded]
        0x129fec40e - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : +[UIView(Animation) performWithoutAnimation:]
        0x129c50a31 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:]
        0x129c15b1f - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UITableView _updateVisibleCellsForRanges:createIfNecessary:]
        0x129c1644c - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UITableView _updateVisibleCellsNow:]
        0x129c37f79 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UITableView layoutSubviews]
        0x129ffa083 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
        0x1188e0d98 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/QuartzCore.framework/QuartzCore : _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE
        0x1188ec849 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/QuartzCore.framework/QuartzCore : _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE
        0x1187fc15e - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/QuartzCore.framework/QuartzCore : _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd
        0x118832805 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/QuartzCore.framework/QuartzCore : _ZN2CA11Transaction6commitEv
        0x1299df578 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : __34-[UIApplication _firstCommitBlock]_block_invoke_2
        0x10cc50986 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
        0x10cc50148 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : __CFRunLoopDoBlocks
        0x10cc4a9cf - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : __CFRunLoopRun
        0x10cc4a264 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : CFRunLoopRunSpecific
        0x121a2a24e - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices : GSEventRunModal
        0x1299bf7bf - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : -[UIApplication _run]
        0x1299c45de - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : UIApplicationMain
        0x10a03364a - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libxamarin-dotnet-debug.dylib : xamarin_UIApplicationMain
        0x10a8415c9 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : do_icall
        0x10a8400d3 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : do_icall_wrapper
        0x10a8324cf - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : interp_exec_method
        0x10a82fe23 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : interp_runtime_invoke
        0x10a655258 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : mono_runtime_invoke_checked
        0x10a65d26c - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : do_exec_main_checked
        0x10a78be12 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libmonosgen-2.0.dylib : mono_jit_exec
        0x10a077c77 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/libxamarin-dotnet-debug.dylib : xamarin_main
        0x1010f4704 - /Users/kencooper/Library/Developer/CoreSimulator/Devices/BCBF3C73-A566-44CB-96AB-D537EF55DD58/data/Containers/Bundle/Application/8ADB0D94-0015-4D33-A829-D875AE29F061/MauiTest.app/MauiTest : main
        0x109bfd384 - Unknown
        0x20162541f - Unknown

=================================================================
        Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x11c90f1f2):0x11c90f1e2  ff ff c3 90 90 90 b8 48 01 00 02 49 89 ca 0f 05  .......H...I....
0x11c90f1f2  73 08 48 89 c7 e9 df 9a ff ff c3 90 90 90 b8 53  s.H............S
0x11c90f202  00 00 02 49 89 ca 0f 05 73 08 48 89 c7 e9 c7 9a  ...I....s.H.....
0x11c90f212  ff ff c3 90 90 90 b8 83 01 00 02 49 89 ca 0f 05  ...........I....

=================================================================
        Managed Stacktrace:
=================================================================
          at <unknown> <0xffffffff>
          at UIKit.UIApplication:xamarin_UIApplicationMain <0x0006a>
          at UIKit.UIApplication:UIApplicationMain <0x00044>
          at UIKit.UIApplication:Main <0x000e0>
          at MauiTest.Program:Main <0x00018>
          at <Module>:runtime_invoke_direct_void_string[] <0x00098>
          at <unknown> <0x00000>
=================================================================

Link to public reproduction project repository

https://github.com/kcoop/MauiTest

Version with bug

7.0.49

Last version that worked well

6.0

Affected platforms

iOS, I was not able test on other platforms

Affected platform versions

iOS 16.4

Did you find any workaround?

No response

Relevant log output

No response

@jonathanpeppers
Copy link
Member

The crash is in libmonosgen-2.0.dylib, so we can move this to dotnet/runtime.

I do a couple things that seem to avoid this issue, maybe?

  • I normally just use MacCatalyst instead of iOS, as you don't need dsrouter in that case. I have always found the same behavior present on that platform as iOS (thus far).
  • For memory, I use --providers Microsoft-DotNETRuntimeMonoProfiler:0xC900001:4

Some links that might help:

@jonathanpeppers jonathanpeppers transferred this issue from dotnet/maui Jul 11, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jul 11, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jul 11, 2023
@kcoop
Copy link
Author

kcoop commented Jul 11, 2023

MacCatalyst!

Very helpful, thanks.

Sounds like you haven’t had good experience using mono-gcdump directly? It’s an extra step to convert, and the interactive mode looked useful.

@jonathanpeppers
Copy link
Member

I don't think mono-gcdump works with .NET 6+.

They are planning to make dotnet-gcdump work with desktop apps running on Mono & also be able to connect to dsrouter, but I'm not sure when that will be finished.

@vcsjones vcsjones removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jul 11, 2023
@kcoop
Copy link
Author

kcoop commented Jul 11, 2023

Good to know, thanks.

Confirmed this works on MacCatalyst (at least for a default Maui app), with one change to the gist.

Initially, monogc-dump failed with a known crash with the provider flags set to Microsoft-DotNETRuntimeMonoProfiler:0xC900001.

Following @filipnavara's guidance here: filipnavara/mono-gcdump#6 (comment), I changed them to 0xC900003.

That sadly caused the app to crash in the app when running the trace. But using the gist's instructions for a first trace, followed by filip's with a second trace while the app was still running, the monogram-dump convert completed, and the .gcdump file is viewable VS.

@kcoop
Copy link
Author

kcoop commented Jul 11, 2023

Amending the above workaround. I am now able generate dumps from my own app. But to do so, I needed the first trace to completely omit the --providers flag and do default tracing, it crashed at startup otherwise. Once I did that, I was able to then run it with the GC flags.

Btw, a leak I'm seeing includes a reference to Microsoft.Maui.Controls.Platform.GestureManager, and from this PR (dotnet/maui#15062) that may now be fixed in .net 8?

@steveisok steveisok removed the untriaged New issue has not been triaged by the area owner label Jul 24, 2023
@steveisok steveisok added this to the 8.0.0 milestone Jul 24, 2023
@steveisok
Copy link
Member

@lateralusX can you see if you get this same kind of crash?

@lateralusX
Copy link
Member

lateralusX commented Jul 24, 2023

Good news is that regular dotnet-gcdump will work with Mono in .net8 :).

I think the issue that gets hit here is due to starting up the runtime in suspend mode and then try to do a gc dump as first session, that will probably cause this issue. Doing a regular trace first will make sure runtime leave its suspend startup state and when a gc dump is done later, it will work as intended, since runtime is up and running, capable of doing gc dumps.

So when doing a gc dump, don't suspend the runtime on startup, you do that by removing the suspend flag:

'--setenv:DOTNET_DiagnosticPorts=127.0.0.1:9000,listen'

Suspending runtime on startup is normally only needed when analyzing startup performance issues and not the default configuration for EventPipe.

@lateralusX
Copy link
Member

Tried this on iOS simulator .net8 without hitting the crash either using dotnet-gcdump or the legacy Microsoft-DotNETRuntimeMonoProfiler to get a gc dump. If runtime is started in suspend mode, dotnet-gcdump will hang since that tool is not prepared to work with runtimes in suspend mode (tool needs to run a resume runtime command), so that means you can't run dotnet-gcdump with runtime setup in suspend mode, that is rather good, since taking a gcdump during runtime startup is probably not what you want anyways. Running with Microsoft-DotNETRuntimeMonoProfiler using dotnet-trace will make the runtime resume, but in .net8 the provider won't try to do a GC until runtime has been fully initialized and that won't be the case when doing startup tracing, so resulting .nettrace file won't include a gc dump. If you on the other hand requests dumps once the runtime is up and running, both dotnet-gcdump as well as Microsoft-DotNETRuntimeMonoProfiler gives expected results.

Since the issue seems to be resolved in .net8 and since we have standard ways to do dumps in .net8 using dotnet-gcdump as well as the issue in .net7 is probably due to starting up runtime in suspend mode, I will close this issue.

@ghost ghost locked as resolved and limited conversation to collaborators Aug 24, 2023
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

5 participants