You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Running .NET 7 single file binary on Apple M1 chip causes app to be "killed" #79267
Originally posted by rcdailey December 5, 2022
I have a Github Workflow that compiles my .NET 7 console application using a windows agent. It runs this in a powershell script:
Note: if we use x64 (pass -r osx-x64), the error disappears on the same M1 machine (x64 process runs under Rosetta2 emulation). So this is arm64 specific issue with compression enabled. Possibly happening since #67118.
Thanks for the quick turnaround on this. Will this be fixed in .net 7 as a hot fix release? Until then, is there a workaround that I can use to get this working?
Are these instructions the guidance I should follow for signing my OSX application?
I haven't seen that link before, so I cannot say if/how that works. The simpler solution I was pointing to was to publish the macOS artifacts from macOS machine and pack it as a tar file (to preserve permission bits) and ask user to run codesign --force --deep -s - ./recyclarr after extracting the tarball on their system.
I wanted to sign the application via my GitHub workflow. I went ahead and purchased an apple developer membership so that I can do that. Seems like I need to do it by hand and dotnet tooling only does adhoc signing.
Yes, the entire signing and notarization process is quite involved. Here is a flat script with raw steps I've pieced together for PublistSingleFile=true, you can fit it into your workflow YAML: https://gist.github.com/am11/924f18ea3a276e24390547da622290df
This is the .app version, you can also have .dmg, .pkg and .zip version to distribute signed software on macOS. This zip has to be created by ditto(1) utility which is usually present in PATH.
Is notarization required in order to distribute my executable to users without causing them trouble? The end goal, in my opinion, is for the application to execute normally as it would on Linux (which doesn't require all of this process).
The signing part seems easy; I just want to know if I can stop there or if I should do notarization as well. I do not plan to distribute my application via the Mac/Apple store.
I don't want my users to have to sign my application, my goal is to make my application ready to un-tarball and run with no extra fuss. Given that requirement, it's not really true that we don't need any of the process, right? If I'm wrong, where am I confused?
You can use the posted script if you want app bundle (.app) model, then you don't need to manually zip or tar anything. You can skip notarization step 4 if you don't want "full trust".
I went ahead and purchased an apple developer membership so that I can do that.
Signing is a partial trust. You don't need to purchase anything for it, just sign up for a free developer certificate (Apple ID).
Notarization is full trust; Apple vouches for your app. That has a recurring cost.
So if you have purchased something and you don't need notarization, you can revert the transaction and get the reimbursement.
The Developer ID certificate option was not even available on the developer apple website without a membership. Where am I supposed to go to get a "free developer certificate"? The only alternative I was able to find was signing with a self-signed cert, but that would not get rid of the prompts users see when they run my app.
Sorry for all the confusion on my part. I'm learning a lot, though, so thank you for this.
@am11 Are these instructions the guidance I should follow for signing my OSX application? It seems like a lot of work. I was hoping that dotnet publish did most of this for me; but I'm not sure. I am not able to find much official documentation on how to do this step by step.
Similarly, this is why we don't do anything in dotnet publish itself. If Apple changes the requirements, which they have often done, dotnet publish may do the wrong thing. Apple releases do not necessarily align with dotnet releases so there is no guarantee that any fix would be available.
Lastly, we don't support signing on non-Apple platforms simply because Apple does not support signing on non-Apple platforms.
Thanks for all the support. I know I've taken this issue on quite a detour. At this point I've learned a lot and I will take further questions to the Apple dev forums. Thanks so much for everything and I apologize for going off topic.
Thanks for discussion! I know this is a sore spot, so I'm very interested in your feedback. Once you figure out what you need, I would love to know what, if anything, we could do to make this simpler without making promises that we can't keep (e.g., by supporting code signing on non-Apple platforms).
Activity
vitek-karas commentedon Dec 6, 2022
Comment by @am11 :
this seems related to #49855.
I get
bus error (138)on osx-arm64 even with hello-world app, e.g. using daily builds:vitek-karas commentedon Dec 6, 2022
/cc @elinor-fung
am11 commentedon Dec 6, 2022
It is failing in
PEImageLayout::ApplyBaseRelocations:cc @janvorli
am11 commentedon Dec 6, 2022
Note: if we use x64 (pass
-r osx-x64), the error disappears on the same M1 machine (x64 process runs under Rosetta2 emulation). So this is arm64 specific issue with compression enabled. Possibly happening since #67118.rcdailey commentedon Dec 6, 2022
Thanks for the quick turnaround on this. Will this be fixed in .net 7 as a hot fix release? Until then, is there a workaround that I can use to get this working?
rcdailey commentedon Dec 6, 2022
I should also add, I observed this same behavior almost a year ago on .net 6 as well.
am11 commentedon Dec 6, 2022
If flipping
EnableCompressionInSingleFilefromtruetofalsefixes the problem in your project, then that'd be the known workaround. 🙂fix: Disable compression in single file builds to fix Apple M1 crash
rcdailey commentedon Dec 7, 2022
@am11 sadly, this did not work. Here is the build I tested:
https://github.com/recyclarr/recyclarr/actions/runs/3630695323
My project is entirely open source so you are welcome to experiment with it. I'm still looking for a workaround!
agocke commentedon Dec 7, 2022
@VSadov for investigation
agocke commentedon Dec 7, 2022
I would definitely take this for back port to 7
15 remaining items
am11 commentedon Dec 17, 2022
I haven't seen that link before, so I cannot say if/how that works. The simpler solution I was pointing to was to publish the macOS artifacts from macOS machine and pack it as a tar file (to preserve permission bits) and ask user to run
codesign --force --deep -s - ./recyclarrafter extracting the tarball on their system.rcdailey commentedon Dec 18, 2022
I wanted to sign the application via my GitHub workflow. I went ahead and purchased an apple developer membership so that I can do that. Seems like I need to do it by hand and dotnet tooling only does adhoc signing.
am11 commentedon Dec 18, 2022
Yes, the entire signing and notarization process is quite involved. Here is a flat script with raw steps I've pieced together for
PublistSingleFile=true, you can fit it into your workflow YAML: https://gist.github.com/am11/924f18ea3a276e24390547da622290dfThis is the .app version, you can also have .dmg, .pkg and .zip version to distribute signed software on macOS. This zip has to be created by ditto(1) utility which is usually present in PATH.
rcdailey commentedon Dec 18, 2022
Is notarization required in order to distribute my executable to users without causing them trouble? The end goal, in my opinion, is for the application to execute normally as it would on Linux (which doesn't require all of this process).
The signing part seems easy; I just want to know if I can stop there or if I should do notarization as well. I do not plan to distribute my application via the Mac/Apple store.
am11 commentedon Dec 18, 2022
We don't need any of this process, not even signing, if that's your goal all along. Your app is fine: #79267 (comment)
rcdailey commentedon Dec 18, 2022
I don't want my users to have to sign my application, my goal is to make my application ready to un-tarball and run with no extra fuss. Given that requirement, it's not really true that we don't need any of the process, right? If I'm wrong, where am I confused?
am11 commentedon Dec 18, 2022
You can use the posted script if you want app bundle (.app) model, then you don't need to manually zip or tar anything. You can skip notarization step 4 if you don't want "full trust".
Signing is a partial trust. You don't need to purchase anything for it, just sign up for a free developer certificate (Apple ID).
Notarization is full trust; Apple vouches for your app. That has a recurring cost.
So if you have purchased something and you don't need notarization, you can revert the transaction and get the reimbursement.
rcdailey commentedon Dec 18, 2022
The Developer ID certificate option was not even available on the developer apple website without a membership. Where am I supposed to go to get a "free developer certificate"? The only alternative I was able to find was signing with a self-signed cert, but that would not get rid of the prompts users see when they run my app.
Sorry for all the confusion on my part. I'm learning a lot, though, so thank you for this.
EDIT: Found some instruction here, but:
agocke commentedon Dec 19, 2022
Sorry, this is a rough edge at the moment. Unfortunately we don't really have any say in the Mac requirements. They are fully controlled by Apple. This is why we don't have any documentation on signing -- Apple is the ultimate authority on how to sign on their platform. The only documentation I have found from them is https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html
Similarly, this is why we don't do anything in
dotnet publishitself. If Apple changes the requirements, which they have often done,dotnet publishmay do the wrong thing. Apple releases do not necessarily align withdotnetreleases so there is no guarantee that any fix would be available.Lastly, we don't support signing on non-Apple platforms simply because Apple does not support signing on non-Apple platforms.
rcdailey commentedon Dec 19, 2022
Thanks for all the support. I know I've taken this issue on quite a detour. At this point I've learned a lot and I will take further questions to the Apple dev forums. Thanks so much for everything and I apologize for going off topic.
agocke commentedon Dec 19, 2022
Thanks for discussion! I know this is a sore spot, so I'm very interested in your feedback. Once you figure out what you need, I would love to know what, if anything, we could do to make this simpler without making promises that we can't keep (e.g., by supporting code signing on non-Apple platforms).
am11 commentedon Jan 9, 2023
This is resolved. The fix for
EnableCompressionInSingleFile=trueis available in .NET SDK 8 daily build (8.0.100-alpha.1.23059.8).Backport to .NET 7: #80283.
ci: Re-enable compressed builds on MacOS