dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.27k stars 4.73k forks source link

App published for net6.0-macos doesn't work in sandbox #80016

Open lanyusan opened 1 year ago

lanyusan commented 1 year ago

Description

The command dotnet publish -c release -r osx-x64 -p:UseAppHost=true -p:PublishSingleFile=true won't work if target is net6.0-macos.

See

https://github.com/dotnet/runtime/discussions/79948

for earlier discussions.

Reproduction Steps

I am trying to publish an Mac app for code signing.

I have tried with PublishReadyToRun , which caused the error as in:

https://github.com/dotnet/runtime/discussions/79947

Now I am trying to use publish single file with this very simple setup:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>

target framework net6.0-macos, and command dotnet publish -c release -r osx-x64,

which caused the error below:

/usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(104,5): error NETSDK1098: Applications published to a single-file are required to use the application host. You must either set PublishSingleFile to false or set UseAppHost to true.

So I ran this command dotnet publish -c release -r osx-x64 -p:UseAppHost=true, which caused this error:

/usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(904,5): error MSB4018: The "GenerateBundle" task failed unexpectedly. 
/usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(904,5): error MSB4018: System.ArgumentException: Invalid input specification: Must specify the host binary.

Expected behavior

A single file bundle for macos is generated.

Actual behavior

Error reported:

/usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(904,5): error MSB4018: The "GenerateBundle" task failed unexpectedly. 
/usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(904,5): error MSB4018: System.ArgumentException: Invalid input specification: Must specify the host binary.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

ghost commented 1 year ago

Tagging subscribers to this area: @agocke, @vitek-karas, @vsadov See info in area-owners.md if you want to be subscribed.

Issue Details
### Description The command `dotnet publish -c release -r osx-x64 -p:UseAppHost=true -p:PublishSingleFile=true` won't work if target is net6.0-macos. See discussion https://github.com/dotnet/runtime/discussions/79948 ### Reproduction Steps I am trying to publish an Mac app for code signing. I have tried with PublishReadyToRun , which caused the error as in: https://github.com/dotnet/runtime/discussions/79947 Now I am trying to use publish single file with this very simple setup: true and command dotnet publish -c release -r osx-x64, which caused the error below: /usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(104,5): error NETSDK1098: Applications published to a single-file are required to use the application host. You must either set PublishSingleFile to false or set UseAppHost to true. So I ran this command dotnet publish -c release -r osx-x64 -p:UseAppHost=true, which caused this error: /usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(904,5): error MSB4018: The "GenerateBundle" task failed unexpectedly. /usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(904,5): error MSB4018: System.ArgumentException: Invalid input specification: Must specify the host binary. ### Expected behavior A single file bundle for macos is generated. ### Actual behavior Error reported: /usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(904,5): error MSB4018: The "GenerateBundle" task failed unexpectedly. /usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(904,5): error MSB4018: System.ArgumentException: Invalid input specification: Must specify the host binary. ### Regression? _No response_ ### Known Workarounds _No response_ ### Configuration _No response_ ### Other information _No response_
Author: lanyusan
Assignees: -
Labels: `area-Single-File`
Milestone: -
ViktorHofer commented 1 year ago

Does .NET 6 actually support net6.0-macos as a TFM? Can you please point me to some docs about it? cc @am11

am11 commented 1 year ago

Does .NET 6 actually support net6.0-macos as a TFM?

Yes. OS-Specific TFM docs: https://learn.microsoft.com/en-us/dotnet/standard/frameworks#net-5-os-specific-tfms

Basically, <TargetFramework>net6.0-macos</TargetFramework> is same as:

    <TargetFramework>net6.0</TargetFramework>
    <TargetPlatformIdentifier>macos</TargetPlatformIdentifier>

By setting TPI, WorkloadManifestTargetsLocator resolves Microsoft.macos.Sdk.net7 SDK, which further resolves Microsoft.NET.Runtime.MonoTargets.Sdk.net7 and then Xamarin.Shared.Sdk etc.

am11 commented 1 year ago

Mono currently doesn't support singlefilehost (https://github.com/dotnet/runtime/issues/59815 cc @lambdageek) but this hybrid scenario should work (in theory, at least) which currently requires some manual tweaks atm:

am11 commented 1 year ago

I am trying to publish an Mac app for code signing.

If this is the ultimate goal, then I think you can use Apple's Application Bundle (.app) and --self-contained without single-file:

  1. delete <PublishSingleFile>true line from .csproj in your original project
  2. use dotnet publish -c release -r osx-x64 --self-contained.
  3. to sign the .app bundle, try out this script on bin/Release/net6.0-macos/osx-x64/LayerMixer.app (which I put together for another issue (https://github.com/dotnet/runtime/issues/79267)).

I have tested it with net6.0-macos and net7.0-macos.

lanyusan commented 1 year ago

@am11 Thanks for the advice.

I am sorry I haven't made the whole picture clear.

The eventual goal is code signing with sandbox enabled in entitlement file. Sandbox is mandatory for distribution in Mac App store.

I have found out standard publish function integrated in Visual Studio for Mac actually works fine when sandbox is disabled.

But when it is enabled, signed app would crash.

Here is the link to my post to apple support:

https://developer.apple.com/forums/thread/722313

I did some search and found out that when running in sandbox, dylib must be put under Contents/Frameworks.

That is why it is necessary to use single file publish.

Location Description
Contents Top content directory of the bundle
Contents/MacOS Helper apps and tools
Contents/Frameworks Frameworks, dylibs
Contents/PlugIns Plug-ins, both loadable and Extensions
Contents/XPCServices XPC services
Contents/Helpers Helper apps and tools
Contents/Library/Automator Automator actions
Contents/Library/Spotlight Spotlight importers
Contents/Library/LoginItems Installable login items
Contents/Library/LaunchServices Privileged helper tools installed by the ServiceManagement framework
am11 commented 1 year ago

signed app would crash.

How does it crash? I applied this patch in LayerMixer repo you shared:

--- a/LayerMixer.csproj
+++ b/LayerMixer.csproj
@@ -21,7 +21,9 @@
        </PropertyGroup>

 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-<PublishSingleFile>true</PublishSingleFile>
+  <ArchiveOnBuild>true</ArchiveOnBuild>
+  <CodesignKey>MyAppSignCert</CodesignKey>
+  <CodesignEntitlements>Platforms/macos/Entitlements.plist</CodesignEntitlements>
 <!--
        <PublishReadyToRun>true</PublishReadyToRun>
        -->

(where MyAppSignCert is the name of certificate in my keychain; I used self-signed certificate for local testing)

added a file: Platforms/macos/Entitlements.plist with the following contents:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>

    <key>com.apple.application-identifier</key>
    <string>com.abc.def</string>

    <key>com.apple.security.cs.allow-jit</key>
    <true/>
</dict>
</plist>

then to publish, used:

dotnet publish -c Release -r osx-x64 --self-contained

it produced a .pkg installer. The whole process is described for iOS (.ipa): https://learn.microsoft.com/en-us/dotnet/maui/ios/deployment/overview?view=net-maui-7.0 but not for macOS exclusively, so I improvised a bit.

If you run that .pkg installer as described and launch the installed app, does it still crash? All .dylib files are under Contents/MonoBundle. I don't see the UI even in the normal run but its icon shows up in the Dock with normal run as well as after installing the .pkg. So I'm not sure how to tell if it is crashing.

However, I checked with codesign -dvvv and checked the sandboxd warnings / errors (see https://developer.apple.com/library/mac/documentation/security/conceptual/AppSandboxDesignGuide/AppSandboxQuickStart/AppSandboxQuickStart.html), and it does appear fine. So maybe Contents/Frameworks/*.dylib condition is not necessary after all?

lanyusan commented 1 year ago

@am11

I repeated with your config exactly.

An app bundle was created together with the pkg.

I launched the app directly and following error was popped up. I used actual apple developer certificate for signing:

3rd Party Mac Developer Application:[xxx]

I used a Mac air M1.

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               LayerMixer [16394]
Path:                  /Users/USER/*/LayerMixer.app/Contents/MacOS/LayerMixer
Identifier:            com.abc.def
Version:               1.0 (1.0)
Code Type:             X86-64 (Translated)
Parent Process:        launchd [1]
User ID:               502

Date/Time:             2022-12-30 08:26:45.5902 +0800
OS Version:            macOS 13.1 (22C65)
Report Version:        12
Anonymous UUID:        905BE678-C6B0-EAC0-5EB7-83FB26EB8BB9

Sleep/Wake UUID:       CE2BE41E-CF9E-4C6A-9888-85B73ADBF288

Time Awake Since Boot: 280000 seconds
Time Since Wake:       54694 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
Exception Codes:       UNKNOWN_0x32 at 0x000000010b9a2000
Exception Codes:       0x0000000000000032, 0x000000010b9a2000

Termination Reason:    Namespace CODESIGNING, Code 2 Invalid Page

VM Region Info: 0x10b9a2000 is in 0x10b9a2000-0x10b9b6000;  bytes after start: 0  bytes before end: 81919
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      Rosetta Generic             10b9a1000-10b9a2000    [    4K] rw-/rwx SM=PRV  
--->  mapped file                 10b9a2000-10b9b6000    [   80K] r-x/rwx SM=COW  ...ct_id=415a5b3
      VM_ALLOCATE (reserved)      10b9b6000-10b9c6000    [   64K] rw-/rwx SM=NUL  ...(unallocated)

Thread 0 Crashed:
0   <translation info unavailable>         0x1034460c0 ???
1   <translation info unavailable>         0x103449560 ???
2   dyld                                   0x2032c7db7 dyld4::Loader::mapSegments(Diagnostics&, dyld4::RuntimeState&, char const*, unsigned long long, dyld4::Loader::CodeSignatureInFile const&, bool, dyld3::Array<dyld4::Loader::Region> const&, bool, bool, dyld4::Loader::FileValidationInfo const&) + 1435
3   dyld                                   0x2032cf8af invocation function for block in dyld4::JustInTimeLoader::makeJustInTimeLoaderDisk(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, bool, unsigned int, mach_o::Layout const*) + 84
4   dyld                                   0x2032cf1da dyld4::JustInTimeLoader::withRegions(dyld3::MachOFile const*, void (dyld3::Array<dyld4::Loader::Region> const&) block_pointer) + 234
5   dyld                                   0x2032cf7a8 invocation function for block in dyld4::JustInTimeLoader::makeJustInTimeLoaderDisk(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, bool, unsigned int, mach_o::Layout const*) + 509
6   dyld                                   0x2032d6476 dyld4::SyscallDelegate::withReadOnlyMappedFile(Diagnostics&, char const*, bool, void (void const*, unsigned long, bool, dyld4::FileID const&, char const*) block_pointer) const + 138
7   dyld                                   0x2032cf580 dyld4::JustInTimeLoader::makeJustInTimeLoaderDisk(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, bool, unsigned int, mach_o::Layout const*) + 198
8   dyld                                   0x2032c6de6 invocation function for block in dyld4::Loader::getLoader(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&) + 1298
9   dyld                                   0x2032c628f dyld4::Loader::forEachResolvedAtPathVar(dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, dyld4::ProcessConfig::PathOverrides::Type, bool&, void (char const*, dyld4::ProcessConfig::PathOverrides::Type, bool&) block_pointer) + 827
10  dyld                                   0x2032b5d6b dyld4::ProcessConfig::PathOverrides::forEachPathVariant(char const*, dyld3::Platform, bool, bool, bool&, void (char const*, dyld4::ProcessConfig::PathOverrides::Type, bool&) block_pointer) const + 545
11  dyld                                   0x2032c5dd3 dyld4::Loader::forEachPath(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, void (char const*, dyld4::ProcessConfig::PathOverrides::Type, bool&) block_pointer) + 251
12  dyld                                   0x2032c65d7 dyld4::Loader::getLoader(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&) + 797
13  dyld                                   0x2032cd806 invocation function for block in dyld4::JustInTimeLoader::loadDependents(Diagnostics&, dyld4::RuntimeState&, dyld4::Loader::LoadOptions const&) + 435
14  dyld                                   0x2032fc60a invocation function for block in dyld3::MachOFile::forEachDependentDylib(void (char const*, bool, bool, bool, unsigned int, unsigned int, bool&) block_pointer) const + 107
15  dyld                                   0x2032af0b7 dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 245
16  dyld                                   0x2032fc482 dyld3::MachOFile::forEachDependentDylib(void (char const*, bool, bool, bool, unsigned int, unsigned int, bool&) block_pointer) const + 164
17  dyld                                   0x2032cd532 dyld4::JustInTimeLoader::loadDependents(Diagnostics&, dyld4::RuntimeState&, dyld4::Loader::LoadOptions const&) + 152
18  dyld                                   0x2032b39b6 dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 1260
19  dyld                                   0x2032b3281 start + 2289

Thread 1:: com.apple.rosetta.exceptionserver
0   runtime                             0x7ff7ffc48614 0x7ff7ffc44000 + 17940
1   runtime                             0x7ff7ffc60c8c 0x7ff7ffc44000 + 117900
2   runtime                             0x7ff7ffc53e30 0x7ff7ffc44000 + 65072
3   runtime                             0x7ff7ffc54ea4 0x7ff7ffc44000 + 69284
4   runtime                             0x7ff7ffc55f30 0x7ff7ffc44000 + 73520

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x000000020335136c  rbx: 0x000000030a005160  rcx: 0x000000020335136c  rdx: 0x0000000000014000
  rdi: 0x000000010b9a2000  rsi: 0x000000030a005160  rbp: 0x000000030a0043e0  rsp: 0x000000030a0043d0
   r8: 0x0000000000000003   r9: 0x0000000000000000  r10: 0x0000000000040012  r11: 0x000000030a004b50
  r12: 0x0000000000000000  r13: 0x0000000000000000  r14: 0x000000030a0049c0  r15: 0x000000010b9a2000
  rip: <unavailable>       rfl: 0x0000000000000202
 tmp0: 0x0000000103446098 tmp1: 0x0000000103449d48 tmp2: 0x00000002032c7db7

Binary Images:
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
       0x2032ad000 -        0x203344fff dyld (*) <bb7a0970-8c62-3dce-a7a2-5cec9c501f11> /usr/lib/dyld
    0x7ff7ffc44000 -     0x7ff7ffc73fff runtime (*) <d592bc4a-4a21-348f-a406-e12f9cd2f27c> /usr/libexec/rosetta/runtime

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 14
    thread_create: 0
    thread_set_state: 62

VM Region Summary:
ReadOnly portion of Libraries: Total=5188K resident=0K(0%) swapped_out_or_unallocated=5188K(100%)
Writable regions: Total=156.9M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=156.9M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Rosetta Arena                     4096K        2 
Rosetta Generic                    888K      219 
Rosetta IndirectBranch              32K        1 
Rosetta JIT                      128.0M        1 
Rosetta Return Stack                20K        2 
Rosetta Thread Context              20K        2 
Stack                             8176K        1 
Stack Guard                       56.0M        1 
VM_ALLOCATE                       15.4M        6 
VM_ALLOCATE (reserved)              68K        2         reserved VM address space (unallocated)
__DATA                             656K        6 
__DATA_CONST                        48K        2 
__DATA_DIRTY                        16K        1 
__LINKEDIT                        3056K        7 
__TEXT                            2160K        4 
dyld private memory                512K        2 
mapped file                        6.6G       38 
===========                     =======  ======= 
TOTAL                              6.8G      297 
TOTAL, minus reserved VM space     6.8G      297 

-----------
Full Report
-----------

{"app_name":"LayerMixer","timestamp":"2022-12-30 08:26:46.00 +0800","app_version":"1.0","slice_uuid":"4f6b6e0f-2680-3dc1-b55a-8c51a8c9a004","build_version":"1.0","platform":1,"bundleID":"com.abc.def","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 13.1 (22C65)","roots_installed":0,"name":"LayerMixer","incident_id":"CE9590AA-2F88-4199-9849-637E33A2A234"}
{
  "uptime" : 280000,
  "procRole" : "Background",
  "version" : 2,
  "userID" : 502,
  "deployVersion" : 210,
  "modelCode" : "MacBookAir10,1",
  "coalitionID" : 20943,
  "osVersion" : {
    "train" : "macOS 13.1",
    "build" : "22C65",
    "releaseType" : "User"
  },
  "captureTime" : "2022-12-30 08:26:45.5902 +0800",
  "incident" : "CE9590AA-2F88-4199-9849-637E33A2A234",
  "pid" : 16394,
  "translated" : true,
  "cpuType" : "X86-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2022-12-30 08:26:42.5649 +0800",
  "procStartAbsTime" : 6957637601809,
  "procExitAbsTime" : 6957710028665,
  "procName" : "LayerMixer",
  "procPath" : "\/Users\/USER\/*\/LayerMixer.app\/Contents\/MacOS\/LayerMixer",
  "bundleInfo" : {"CFBundleShortVersionString":"1.0","CFBundleVersion":"1.0","CFBundleIdentifier":"com.abc.def"},
  "storeInfo" : {"deviceIdentifierForVendor":"67FDB923-F92B-5325-A5AB-BD94289D72F2","thirdParty":true},
  "parentProc" : "launchd",
  "parentPid" : 1,
  "coalitionName" : "com.abc.def",
  "crashReporterKey" : "905BE678-C6B0-EAC0-5EB7-83FB26EB8BB9",
  "throttleTimeout" : 2147483647,
  "wakeTime" : 54694,
  "sleepWakeUUID" : "CE2BE41E-CF9E-4C6A-9888-85B73ADBF288",
  "sip" : "enabled",
  "vmRegionInfo" : "0x10b9a2000 is in 0x10b9a2000-0x10b9b6000;  bytes after start: 0  bytes before end: 81919\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      Rosetta Generic             10b9a1000-10b9a2000    [    4K] rw-\/rwx SM=PRV  \n--->  mapped file                 10b9a2000-10b9b6000    [   80K] r-x\/rwx SM=COW  ...ct_id=415a5b3\n      VM_ALLOCATE (reserved)      10b9b6000-10b9c6000    [   64K] rw-\/rwx SM=NUL  ...(unallocated)",
  "exception" : {"codes":"0x0000000000000032, 0x000000010b9a2000","rawCodes":[50,4489617408],"type":"EXC_BAD_ACCESS","signal":"SIGKILL (Code Signature Invalid)","subtype":"UNKNOWN_0x32 at 0x000000010b9a2000"},
  "termination" : {"flags":0,"code":2,"namespace":"CODESIGNING","indicator":"Invalid Page"},
  "vmregioninfo" : "0x10b9a2000 is in 0x10b9a2000-0x10b9b6000;  bytes after start: 0  bytes before end: 81919\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      Rosetta Generic             10b9a1000-10b9a2000    [    4K] rw-\/rwx SM=PRV  \n--->  mapped file                 10b9a2000-10b9b6000    [   80K] r-x\/rwx SM=COW  ...ct_id=415a5b3\n      VM_ALLOCATE (reserved)      10b9b6000-10b9c6000    [   64K] rw-\/rwx SM=NUL  ...(unallocated)",
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":62,"task_for_pid":14},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":2661861,"threadState":{"flavor":"x86_THREAD_STATE","rbp":{"value":13052691424},"r12":{"value":0},"rosetta":{"tmp2":{"value":8643182007},"tmp1":{"value":4349795656},"tmp0":{"value":4349780120}},"rbx":{"value":13052694880},"r8":{"value":3},"r15":{"value":4489617408},"r10":{"value":262162},"rdx":{"value":81920},"rdi":{"value":4489617408},"r9":{"value":0},"r13":{"value":0},"rflags":{"value":514},"rax":{"value":8643744620,"symbolLocation":172,"symbol":"_main_thread"},"rsp":{"value":13052691408},"r11":{"value":13052693328},"rcx":{"value":8643744620,"symbolLocation":172,"symbol":"_main_thread"},"r14":{"value":13052692928},"rsi":{"value":13052694880}},"frames":[{"imageOffset":4349780160,"region":"<translation info unavailable>","imageIndex":0},{"imageOffset":4349793632,"region":"<translation info unavailable>","imageIndex":0},{"imageOffset":110007,"symbol":"dyld4::Loader::mapSegments(Diagnostics&, dyld4::RuntimeState&, char const*, unsigned long long, dyld4::Loader::CodeSignatureInFile const&, bool, dyld3::Array<dyld4::Loader::Region> const&, bool, bool, dyld4::Loader::FileValidationInfo const&)","symbolLocation":1435,"imageIndex":1},{"imageOffset":141487,"symbol":"invocation function for block in dyld4::JustInTimeLoader::makeJustInTimeLoaderDisk(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, bool, unsigned int, mach_o::Layout const*)","symbolLocation":84,"imageIndex":1},{"imageOffset":139738,"symbol":"dyld4::JustInTimeLoader::withRegions(dyld3::MachOFile const*, void (dyld3::Array<dyld4::Loader::Region> const&) block_pointer)","symbolLocation":234,"imageIndex":1},{"imageOffset":141224,"symbol":"invocation function for block in dyld4::JustInTimeLoader::makeJustInTimeLoaderDisk(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, bool, unsigned int, mach_o::Layout const*)","symbolLocation":509,"imageIndex":1},{"imageOffset":169078,"symbol":"dyld4::SyscallDelegate::withReadOnlyMappedFile(Diagnostics&, char const*, bool, void (void const*, unsigned long, bool, dyld4::FileID const&, char const*) block_pointer) const","symbolLocation":138,"imageIndex":1},{"imageOffset":140672,"symbol":"dyld4::JustInTimeLoader::makeJustInTimeLoaderDisk(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, bool, unsigned int, mach_o::Layout const*)","symbolLocation":198,"imageIndex":1},{"imageOffset":105958,"symbol":"invocation function for block in dyld4::Loader::getLoader(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&)","symbolLocation":1298,"imageIndex":1},{"imageOffset":103055,"symbol":"dyld4::Loader::forEachResolvedAtPathVar(dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, dyld4::ProcessConfig::PathOverrides::Type, bool&, void (char const*, dyld4::ProcessConfig::PathOverrides::Type, bool&) block_pointer)","symbolLocation":827,"imageIndex":1},{"imageOffset":36203,"symbol":"dyld4::ProcessConfig::PathOverrides::forEachPathVariant(char const*, dyld3::Platform, bool, bool, bool&, void (char const*, dyld4::ProcessConfig::PathOverrides::Type, bool&) block_pointer) const","symbolLocation":545,"imageIndex":1},{"imageOffset":101843,"symbol":"dyld4::Loader::forEachPath(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&, void (char const*, dyld4::ProcessConfig::PathOverrides::Type, bool&) block_pointer)","symbolLocation":251,"imageIndex":1},{"imageOffset":103895,"symbol":"dyld4::Loader::getLoader(Diagnostics&, dyld4::RuntimeState&, char const*, dyld4::Loader::LoadOptions const&)","symbolLocation":797,"imageIndex":1},{"imageOffset":133126,"symbol":"invocation function for block in dyld4::JustInTimeLoader::loadDependents(Diagnostics&, dyld4::RuntimeState&, dyld4::Loader::LoadOptions const&)","symbolLocation":435,"imageIndex":1},{"imageOffset":325130,"symbol":"invocation function for block in dyld3::MachOFile::forEachDependentDylib(void (char const*, bool, bool, bool, unsigned int, unsigned int, bool&) block_pointer) const","symbolLocation":107,"imageIndex":1},{"imageOffset":8375,"symbol":"dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const","symbolLocation":245,"imageIndex":1},{"imageOffset":324738,"symbol":"dyld3::MachOFile::forEachDependentDylib(void (char const*, bool, bool, bool, unsigned int, unsigned int, bool&) block_pointer) const","symbolLocation":164,"imageIndex":1},{"imageOffset":132402,"symbol":"dyld4::JustInTimeLoader::loadDependents(Diagnostics&, dyld4::RuntimeState&, dyld4::Loader::LoadOptions const&)","symbolLocation":152,"imageIndex":1},{"imageOffset":27062,"symbol":"dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*)","symbolLocation":1260,"imageIndex":1},{"imageOffset":25217,"symbol":"start","symbolLocation":2289,"imageIndex":1}]},{"id":2662027,"name":"com.apple.rosetta.exceptionserver","frames":[{"imageOffset":17940,"imageIndex":2},{"imageOffset":117900,"imageIndex":2},{"imageOffset":65072,"imageIndex":2},{"imageOffset":69284,"imageIndex":2},{"imageOffset":73520,"imageIndex":2}]}],
  "usedImages" : [
  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 8643072000,
    "size" : 622592,
    "uuid" : "bb7a0970-8c62-3dce-a7a2-5cec9c501f11",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 140703124701184,
    "size" : 196608,
    "uuid" : "d592bc4a-4a21-348f-a406-e12f9cd2f27c",
    "path" : "\/usr\/libexec\/rosetta\/runtime",
    "name" : "runtime"
  }
],
  "sharedCache" : {
  "base" : 140703352537088,
  "size" : 21474836480,
  "uuid" : "16923f88-e9fc-38d2-947c-df242e486636"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=5188K resident=0K(0%) swapped_out_or_unallocated=5188K(100%)\nWritable regions: Total=156.9M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=156.9M(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nRosetta Arena                     4096K        2 \nRosetta Generic                    888K      219 \nRosetta IndirectBranch              32K        1 \nRosetta JIT                      128.0M        1 \nRosetta Return Stack                20K        2 \nRosetta Thread Context              20K        2 \nStack                             8176K        1 \nStack Guard                       56.0M        1 \nVM_ALLOCATE                       15.4M        6 \nVM_ALLOCATE (reserved)              68K        2         reserved VM address space (unallocated)\n__DATA                             656K        6 \n__DATA_CONST                        48K        2 \n__DATA_DIRTY                        16K        1 \n__LINKEDIT                        3056K        7 \n__TEXT                            2160K        4 \ndyld private memory                512K        2 \nmapped file                        6.6G       38 \n===========                     =======  ======= \nTOTAL                              6.8G      297 \nTOTAL, minus reserved VM space     6.8G      297 \n",
  "legacyInfo" : {
  "threadTriggered" : {

  }
},
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "62b4513af75dc926494899c6",
      "factorPackIds" : {
        "COREOS_ICD" : "62fbe3cfa9a700130f60b3ea"
      },
      "deploymentId" : 240000018
    },
    {
      "rolloutId" : "63582c5f8a53461413999550",
      "factorPackIds" : {

      },
      "deploymentId" : 240000002
    }
  ],
  "experiments" : [

  ]
}
}

Model: MacBookAir10,1, BootROM 8419.60.44, proc 8:4:4 processors, 8 GB, SMC 
Graphics: Apple M1, Apple M1, Built-In
Display: Color LCD, 2560 x 1600 Retina, Main, MirrorOff, Online
Memory Module: LPDDR4, Micron
AirPort: spairport_wireless_card_type_wifi (0x14E4, 0x4378), wl0: Sep  3 2022 03:37:22 version 18.20.379.4.7.8.143 FWID 01-e3c71b50
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB31Bus
USB Device: USB31Bus
Thunderbolt Bus: MacBook Air, Apple Inc.
Thunderbolt Bus: MacBook Air, Apple Inc.
am11 commented 1 year ago

Interesting. to troubleshoot:

  1. Could you check the output of: xattr /Users/USER/*/LayerMixer.app/Contents/MacOS/LayerMixer and if you see quarantine attribute, remove it with xattr -d com.apple.quarantine /Users/USER/*/LayerMixer.app/Contents/MacOS/LayerMixer

  2. [ if 1. solves the crash issue skip this ] also check if everything looks alright with codesign (no need to post the output here): codesign -dvvv /Users/USER/*/LayerMixer.app/Contents/MacOS/LayerMixer

    • if you do find something out of order (compared to some other apps) then just force re-sign it to see if that solves the problem: codesign --force --deep -s - /Users/USER/*/LayerMixer.app/Contents/MacOS/LayerMixer

according to google, this is happening after some recent updates. e.g. https://developer.apple.com/forums/thread/722313.

vitek-karas commented 1 year ago

Support for true single-file with Mono is currently not in the plan (at least for 8). But it seems that this issues is not exactly about that. I changed the title to reflect the discussion of how to run the app in sandbox.

I changed the area to mono since it probably belongs in there more than current single-file - Hopefully somebody from mono side will know who to ask specifically.

lanyusan commented 1 year ago

@am11

Followed your steps:

xattr command has not output.

codesign -dvv shows:

Identifier=com.abc.def
Format=app bundle with Mach-O thin (x86_64)
CodeDirectory v=20500 size=34135 flags=0x10000(runtime) hashes=1056+7 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=832a04...
CandidateCDHashFull sha256=832a0477f80fe6f4a...
Hash choices=sha256
CMSDigest=832a0477f80fe6f4a6d8c...
CMSDigestType=2
Launch Constraints:
    None
CDHash=832a0477f80fe6f4...
Signature size=9134
Authority=3rd Party Mac Developer Applicationxxx
Authority=Apple Worldwide Developer Relations Certification Authority
Authority=Apple Root CA
Timestamp=Jan 4, 2023 at 09:23:00
Info.plist entries=11
TeamIdentifier=xxxx
Runtime Version=13.1.0
Sealed Resources version=2 rules=13 files=205
Internal requirements count=1 size=216

codesign --force --deep -s ran successfully. app still crashes with same crash repot.

Thanks a lot for spending time on this issue.

This dotnet app we are working on is a rebuild of our legacy Electron app, which hit some performance walls, not for the UI part but for the underlying computation heavy tasks.

We decide to evaluate SwiftUI instead for Mac and put dotnet macos version on hold for a while.

Thanks again.

SamMonoRT commented 1 year ago

cc @akoeplinger @kotlarmilos - something we should look into. Based on last comment from @lanyusan, seems it is not blocking any more. Moving to 9.0.0 milestone.