Skip to content

Mac Catalyst app with interpreter enabled crashes when profiling with Instruments #116820

Open
@rolfbjarne

Description

@rolfbjarne

Test case:

  1. Download & extract zip: https://www.dropbox.com/scl/fi/x30q5zuu87fyp7qfu7s3y/monotouch-test-crash-instruments.zip?rlkey=s006hk3c7giwzddmfrb5n96il&st=6qe2zrcc&dl=0

  2. Run the sign-me.sh script (not entirely sure if this is necessary, but shouldn't hurt)

  3. Open this file in Instruments (using the Allocations template):

    bin/Debug/net9.0-maccatalyst/maccatalyst-arm64/monotouchtest.app/Contents/MacOS/monotouchtest

  4. Profile with Instruments.

App will crash soon after launch:

Thread 0 Crashed:: tid_103 Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x19a8e9388 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x19a92288c pthread_kill + 296
2   libsystem_c.dylib             	       0x19a7f3d04 raise + 32
3   libmonosgen-2.0.dylib         	       0x118de37c8 mono_sigsegv_signal_handler_debug + 528
4   libsystem_platform.dylib      	       0x19a95c624 _sigtramp + 56
5   liboainject.dylib             	       0x1186da3f0 0x1186d8000 + 9200
6   liboainject.dylib             	       0x1186d8b48 0x1186d8000 + 2888
7   libsystem_malloc.dylib        	       0x19a7551a0 _malloc_zone_malloc_instrumented_or_legacy + 268
8   libmonosgen-2.0.dylib         	       0x118f67a40 monoeg_g_memdup + 44
9   libmonosgen-2.0.dylib         	       0x118fc5984 ves_icall_RuntimeType_GetNamespace_raw + 148
10  monotouchtest                 	       0x10cb1cdf4 wrapper_managed_to_native_System_RuntimeType_GetNamespace_System_Runtime_CompilerServices_QCallTypeHandle_System_Runtime_CompilerServices_ObjectHandleOnStack + 132 (<unknown>:1)
11  monotouchtest                 	       0x10cb1ced4 System_RuntimeType_get_Namespace + 132 (<unknown>:1)
[...]

Full crash report: https://gist.github.com/rolfbjarne/afb515f9296f2dbf48d0dd3aed4a3b82

I built the app with dylibs, so for testing it should be possible to replace libmonosgen-2.0.dylib with a different one, run the sign-me.sh and try again.

Further notes:

  • Disabling the interpreter makes everything work.
  • I get the crash as long as the interpreter is enabled, even if no assemblies are actually interpreted at build time.
$ dotnet --info
.NET SDK:
 Version:           9.0.107
 Commit:            38e51fe4e1
 Workload version:  9.0.100-manifests.047e0683
 MSBuild version:   17.12.35+13c590f8d

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  15.5
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /Users/rolf/work/dotnet/macios/msbuild/macios/builds/downloads/dotnet-sdk-9.0.107-servicing.25272.8/sdk/9.0.107/

.NET workloads installed:
 [macos]
   Installation Source: SDK 9.0.100
   Manifest Version:    15.5.9194-ci.ciformat/9.0.100
   Manifest Path:       /Users/rolf/work/dotnet/macios/msbuild/macios/builds/downloads/dotnet-sdk-9.0.107-servicing.25272.8/sdk-manifests/9.0.100/microsoft.net.sdk.macos/WorkloadManifest.json
   Install Type:        FileBased

 [ios]
   Installation Source: SDK 9.0.100
   Manifest Version:    18.5.9194-ci.ciformat/9.0.100
   Manifest Path:       /Users/rolf/work/dotnet/macios/msbuild/macios/builds/downloads/dotnet-sdk-9.0.107-servicing.25272.8/sdk-manifests/9.0.100/microsoft.net.sdk.ios/WorkloadManifest.json
   Install Type:        FileBased

 [maccatalyst]
   Installation Source: SDK 9.0.100
   Manifest Version:    18.5.9194-ci.ciformat/9.0.100
   Manifest Path:       /Users/rolf/work/dotnet/macios/msbuild/macios/builds/downloads/dotnet-sdk-9.0.107-servicing.25272.8/sdk-manifests/9.0.100/microsoft.net.sdk.maccatalyst/WorkloadManifest.json
   Install Type:        FileBased

 [tvos]
   Installation Source: SDK 9.0.100
   Manifest Version:    18.5.9194-ci.ciformat/9.0.100
   Manifest Path:       /Users/rolf/work/dotnet/macios/msbuild/macios/builds/downloads/dotnet-sdk-9.0.107-servicing.25272.8/sdk-manifests/9.0.100/microsoft.net.sdk.tvos/WorkloadManifest.json
   Install Type:        FileBased

Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.5
  Architecture: arm64
  Commit:       e36e4d1a8f

.NET SDKs installed:
  9.0.107 [/Users/rolf/work/dotnet/macios/msbuild/macios/builds/downloads/dotnet-sdk-9.0.107-servicing.25272.8/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.5 [/Users/rolf/work/dotnet/macios/msbuild/macios/builds/downloads/dotnet-sdk-9.0.107-servicing.25272.8/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.5 [/Users/rolf/work/dotnet/macios/msbuild/macios/builds/downloads/dotnet-sdk-9.0.107-servicing.25272.8/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  /Users/rolf/work/dotnet/macios/msbuild/macios/global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions