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

Regression: error : strip exited with code 139 #19157

Open
dotMorten opened this issue Oct 11, 2023 · 78 comments
Open

Regression: error : strip exited with code 139 #19157

dotMorten opened this issue Oct 11, 2023 · 78 comments
Labels
bug If an issue is a bug or a pull request a bug fix
Milestone

Comments

@dotMorten
Copy link
Contributor

dotMorten commented Oct 11, 2023

Please file a feedback ticket with Apple if you run into this issue

See this comment for more information: #19157 (comment)


Steps to Reproduce

  1. Create a new .NET MAUI App (net8 rc2)
  2. Add package Esri.ArcGISRuntime v200.2.0 <PackageReference Include="Esri.ArcGISRuntime" Version="200.2.0" />
  3. Build and deploy to a physical device with XCode 15 installed (This didn't happen with xcode 14)
  4. Observe build error:
1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.4.8968-net8-rc2\tools\msbuild\iOS\Xamarin.Shared.targets(2750,3): error : strip exited with code 139

Note that if you skip step 2, there is no issue. Something about this library causes the stripper to crash.

Workaround

Add

    <PropertyGroup >
        <MtouchNoSymbolStrip Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">True</MtouchNoSymbolStrip>
    </PropertyGroup>

This is quite a showstopper for us, as this prevents any of our users from using our nuget packages.
We are fairly certain the issue is connected to the XCode 15 upgrade.

Expected Behavior

App builds and deploys.

Actual Behavior

Crash in the stripper

Environment

VS Preview 17.8 p3+remote macos host, or just .NET 8 RC2 commandline on macos with XCode.
We have reproduced on multiple machines, Windows and Mac.

Build Logs

1>/usr/bin/ditto /Users/mort5161/Library/Caches/Xamarin/mtbs/builds/MauiApp10/45615ce3ae59fa5d7b49616b08a491ce70088b1a274c6bd0fc1cb4b5a8be76d0/C:/Users/mort5161/.nuget/packages/esri.arcgisruntime.runtimes.ios/200.2.0/framework/ios-arm64/native/ArcGIS-arm64.framework/ /Users/mort5161/Library/Caches/Xamarin/mtbs/builds/MauiApp10/45615ce3ae59fa5d7b49616b08a491ce70088b1a274c6bd0fc1cb4b5a8be76d0/bin/Debug/net8.0-ios/ios-arm64/device-builds/iphone11.6-16.7/MauiApp10.app/Frameworks/ArcGIS-arm64.framework --arch arm64
1>/usr/bin/ditto /Users/mort5161/Library/Caches/Xamarin/mtbs/builds/MauiApp10/45615ce3ae59fa5d7b49616b08a491ce70088b1a274c6bd0fc1cb4b5a8be76d0/C:/Users/mort5161/.nuget/packages/esri.arcgisruntime.runtimes.ios/200.2.0/framework/ios-arm64/native/Runtimecore.framework/ /Users/mort5161/Library/Caches/Xamarin/mtbs/builds/MauiApp10/45615ce3ae59fa5d7b49616b08a491ce70088b1a274c6bd0fc1cb4b5a8be76d0/bin/Debug/net8.0-ios/ios-arm64/device-builds/iphone11.6-16.7/MauiApp10.app/Frameworks/Runtimecore.framework --arch arm64
1>Tool xcrun execution finished (exit code = 139).
1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.4.8968-net8-rc2\tools\msbuild\iOS\Xamarin.Shared.targets(2750,3): error : strip exited with code 139
1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.4.8968-net8-rc2\tools\msbuild\iOS\Xamarin.Shared.targets(2750,3): error :

Example Project (If Possible)

Repro project. Just try and deploy to an iPhone device:
MauiArcGISApp1.zip

@rolfbjarne
Copy link
Member

I can reproduce the problem, and it seems to be a buffer overrun in the strip command. I'm still investigating to figure out if this is something we can work around somehow.

@rolfbjarne rolfbjarne added the bug If an issue is a bug or a pull request a bug fix label Oct 12, 2023
@rolfbjarne rolfbjarne added this to the .NET 8 milestone Oct 12, 2023
@madmapper
Copy link

Thanks for spotting this @dotMorten - we are in the middle of updating an app with Runtime 200 and this was driving me nuts

@adamdeets-hdr
Copy link

Seeing the same issue.

@madmapper
Copy link

FYI unchecking "Strip native debugging symbols" in the Project Properties accomplishes the same thing and everything seems to work as expected.
image

@dotMorten
Copy link
Contributor Author

FYI unchecking "Strip native debugging symbols" in the Project Properties accomplishes the same thing

Yup that's the same as setting MtouchNoSymbolStrip (but the designer always does it bad with weird conditions so I like doing it in the project directly).
Just note that this is not a workaround you really want - this should be considered a temporary fix to unblock our work, until this issue has been addressed.

A better workaround is probably to move back to xcode 14 for now.

@dotMorten
Copy link
Contributor Author

Just posting the comments from Discord triage here (thanks @rolfbjarne):

Crash report using locally built strip (click to expand)
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               strip [86963]
Path:                  /Users/USER/Library/Developer/Xcode/DerivedData/cctools-ecihfcsnwddndhafbgntrrwrjzti/Build/Products/Debug/strip
Identifier:            strip
Version:               ???
Code Type:             ARM-64 (Native)
Parent Process:        zsh [77528]
Responsible:           iTerm2 [1785]
User ID:               501

Date/Time:             2023-10-12 16:47:41.8244 +0200
OS Version:            macOS 13.6 (22G120)
Report Version:        12
Anonymous UUID:        F22C0F06-0F16-E475-C0CB-264A0FF4F6A3

Sleep/Wake UUID:       231EDA49-965B-462F-B819-4068587485EA

Time Awake Since Boot: 160000 seconds
Time Since Wake:       32896 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00000002fd865d7c
Exception Codes:       0x0000000000000001, 0x00000002fd865d7c

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [86963]

VM Region Info: 0x2fd865d7c is not in any region.  Bytes after previous region: 2835570045  Bytes before following region: 54802358916
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      unused __TEXT               25482c000-254830000    [   16K] r--/r-- SM=COW  ...ed lib __TEXT
--->  GAP OF 0xd6b7d0000 BYTES
      commpage (reserved)         fc0000000-1000000000   [  1.0G] ---/--- SM=NUL  ...(unallocated)

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   strip                         	       0x102967bd0 strip_symtab + 16332 (strip.c:4334)
1   strip                         	       0x10295fee0 strip_object + 4080 (strip.c:1421)
2   strip                         	       0x10295ed8c strip_arch + 3296 (strip.c:1047)
3   strip                         	       0x10295dc70 strip_file + 268 (strip.c:746)
4   strip                         	       0x10295d6fc main + 3404 (strip.c:670)
5   dyld                          	       0x180bfbf28 start + 2236


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000001   x1: 0x0000000148110001   x2: 0x0000000000000018   x3: 0xffffffffffffff88
    x4: 0x000000000000005f   x5: 0x00000000000000d7   x6: 0x0000000000000001   x7: 0x0000000000000bd0
    x8: 0x0000000000002252   x9: 0x0000000158008000  x10: 0x000000006961775f  x11: 0x0000000000031a88
   x12: 0x0000000000000018  x13: 0x0000000000006360  x14: 0x0000000102a4ec78  x15: 0x0000000000000000
   x16: 0x0000000180f7fb30  x17: 0x00000001e0b03eb8  x18: 0x0000000000000000  x19: 0x000000010295c9b0
   x20: 0x00000001029c4000  x21: 0x00000001029c5910  x22: 0x000000016d4a30d0  x23: 0x0000000180c763c6
   x24: 0x000000016d4a3050  x25: 0x0000000000000001  x26: 0x0000000000000000  x27: 0x0000000000000000
   x28: 0x0000000000000000   fp: 0x000000016d4a2750   lr: 0x6e4b000102967adc
    sp: 0x000000016d4a2530   pc: 0x0000000102967bd0 cpsr: 0x60001000
   far: 0x00000002fd865d7c  esr: 0x92000046 (Data Abort) byte write Translation fault

Binary Images:
       0x10295c000 -        0x1029abfff strip (*) <8c1ad0f9-0260-3651-a493-86eaa10b50b0> /Users/USER/Library/Developer/Xcode/DerivedData/cctools-ecihfcsnwddndhafbgntrrwrjzti/Build/Products/Debug/strip
       0x180bf6000 -        0x180c84587 dyld (*) <49204446-242b-3d1e-9704-32f8ac99723e> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???

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: 29
    thread_create: 0
    thread_set_state: 236

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

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Kernel Alloc Once                   32K        1 
MALLOC                           154.2M       14 
MALLOC guard page                   96K        5 
MALLOC_MEDIUM (reserved)         240.0M        2         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                       56.0M        1 
Stack                             8176K        1 
__AUTH                              46K       11 
__AUTH_CONST                        72K       38 
__DATA                             193K       37 
__DATA_CONST                       199K       40 
__DATA_DIRTY                        78K       22 
__LINKEDIT                       802.3M        2 
__OBJC_RO                         66.4M        1 
__OBJC_RW                         2012K        1 
__TEXT                            5600K       42 
dyld private memory                272K        2 
mapped file                       12.2M        1 
shared memory                       16K        1 
===========                     =======  ======= 
TOTAL                              1.7G      223 
TOTAL, minus reserved VM space     1.1G      223 



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

{"app_name":"strip","timestamp":"2023-10-12 16:47:42.00 +0200","app_version":"","slice_uuid":"8c1ad0f9-0260-3651-a493-86eaa10b50b0","build_version":"","platform":1,"share_with_app_devs":1,"is_first_party":1,"bug_type":"309","os_version":"macOS 13.6 (22G120)","roots_installed":0,"incident_id":"DB17380A-FB8B-4C80-8089-0FC2724F5519","name":"strip"}
{
  "uptime" : 160000,
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "Mac14,12",
  "coalitionID" : 959,
  "osVersion" : {
    "train" : "macOS 13.6",
    "build" : "22G120",
    "releaseType" : "User"
  },
  "captureTime" : "2023-10-12 16:47:41.8244 +0200",
  "incident" : "DB17380A-FB8B-4C80-8089-0FC2724F5519",
  "pid" : 86963,
  "translated" : false,
  "cpuType" : "ARM-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2023-10-12 16:47:41.7251 +0200",
  "procStartAbsTime" : 3960627086216,
  "procExitAbsTime" : 3960629463314,
  "procName" : "strip",
  "procPath" : "\/Users\/USER\/Library\/Developer\/Xcode\/DerivedData\/cctools-ecihfcsnwddndhafbgntrrwrjzti\/Build\/Products\/Debug\/strip",
  "parentProc" : "zsh",
  "parentPid" : 77528,
  "coalitionName" : "com.googlecode.iterm2",
  "crashReporterKey" : "F22C0F06-0F16-E475-C0CB-264A0FF4F6A3",
  "responsiblePid" : 1785,
  "responsibleProc" : "iTerm2",
  "codeSigningID" : "strip-555549448c1ad0f902603651a49386eaa10b50b0",
  "codeSigningTeamID" : "",
  "codeSigningFlags" : 570425861,
  "codeSigningValidationCategory" : 10,
  "codeSigningTrustLevel" : 0,
  "wakeTime" : 32896,
  "sleepWakeUUID" : "231EDA49-965B-462F-B819-4068587485EA",
  "sip" : "enabled",
  "vmRegionInfo" : "0x2fd865d7c is not in any region.  Bytes after previous region: 2835570045  Bytes before following region: 54802358916\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      unused __TEXT               25482c000-254830000    [   16K] r--\/r-- SM=COW  ...ed lib __TEXT\n--->  GAP OF 0xd6b7d0000 BYTES\n      commpage (reserved)         fc0000000-1000000000   [  1.0G] ---\/--- SM=NUL  ...(unallocated)",
  "exception" : {"codes":"0x0000000000000001, 0x00000002fd865d7c","rawCodes":[1,12843375996],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_INVALID_ADDRESS at 0x00000002fd865d7c"},
  "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":86963},
  "vmregioninfo" : "0x2fd865d7c is not in any region.  Bytes after previous region: 2835570045  Bytes before following region: 54802358916\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      unused __TEXT               25482c000-254830000    [   16K] r--\/r-- SM=COW  ...ed lib __TEXT\n--->  GAP OF 0xd6b7d0000 BYTES\n      commpage (reserved)         fc0000000-1000000000   [  1.0G] ---\/--- SM=NUL  ...(unallocated)",
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":236,"task_for_pid":29},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":3477797,"threadState":{"x":[{"value":1},{"value":5504040961},{"value":24},{"value":18446744073709551496},{"value":95},{"value":215},{"value":1},{"value":3024},{"value":8786},{"value":5771395072},{"value":1767995231},{"value":203400},{"value":24},{"value":25440},{"value":4339330168},{"value":0},{"value":6458702640,"symbolLocation":0,"symbol":"_platform_strcmp"},{"value":8064614072},{"value":0},{"sourceLine":407,"value":4338338224,"sourceFile":"strip.c","symbol":"main","symbolLocation":0},{"value":4338761728},{"value":4338768144},{"value":6128546000},{"value":6455518150},{"value":6128545872},{"value":1},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":7947445971763755740},"cpsr":{"value":1610616832},"fp":{"value":6128543568},"sp":{"value":6128543024},"esr":{"value":2449473606,"description":"(Data Abort) byte write Translation fault"},"pc":{"value":4338383824,"matchesCrashFrame":1},"far":{"value":12843375996}},"queue":"com.apple.main-thread","frames":[{"imageOffset":48080,"sourceLine":4334,"sourceFile":"strip.c","symbol":"strip_symtab","imageIndex":0,"symbolLocation":16332},{"imageOffset":16096,"sourceLine":1421,"sourceFile":"strip.c","symbol":"strip_object","imageIndex":0,"symbolLocation":4080},{"imageOffset":11660,"sourceLine":1047,"sourceFile":"strip.c","symbol":"strip_arch","imageIndex":0,"symbolLocation":3296},{"imageOffset":7280,"sourceLine":746,"sourceFile":"strip.c","symbol":"strip_file","imageIndex":0,"symbolLocation":268},{"imageOffset":5884,"sourceLine":670,"sourceFile":"strip.c","symbol":"main","imageIndex":0,"symbolLocation":3404},{"imageOffset":24360,"symbol":"start","symbolLocation":2236,"imageIndex":1}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4338335744,
    "size" : 327680,
    "uuid" : "8c1ad0f9-0260-3651-a493-86eaa10b50b0",
    "path" : "\/Users\/USER\/Library\/Developer\/Xcode\/DerivedData\/cctools-ecihfcsnwddndhafbgntrrwrjzti\/Build\/Products\/Debug\/strip",
    "name" : "strip"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6454992896,
    "size" : 583048,
    "uuid" : "49204446-242b-3d1e-9704-32f8ac99723e",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  }
],
  "sharedCache" : {
  "base" : 6454329344,
  "size" : 3553476608,
  "uuid" : "c26be8cd-619e-3513-8673-3ff826317005"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=807.8M resident=0K(0%) swapped_out_or_unallocated=807.8M(100%)\nWritable regions: Total=786.4M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=786.4M(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nKernel Alloc Once                   32K        1 \nMALLOC                           154.2M       14 \nMALLOC guard page                   96K        5 \nMALLOC_MEDIUM (reserved)         240.0M        2         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nSTACK GUARD                       56.0M        1 \nStack                             8176K        1 \n__AUTH                              46K       11 \n__AUTH_CONST                        72K       38 \n__DATA                             193K       37 \n__DATA_CONST                       199K       40 \n__DATA_DIRTY                        78K       22 \n__LINKEDIT                       802.3M        2 \n__OBJC_RO                         66.4M        1 \n__OBJC_RW                         2012K        1 \n__TEXT                            5600K       42 \ndyld private memory                272K        2 \nmapped file                       12.2M        1 \nshared memory                       16K        1 \n===========                     =======  ======= \nTOTAL                              1.7G      223 \nTOTAL, minus reserved VM space     1.1G      223 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "queue" : "com.apple.main-thread"
  }
},
  "logWritingSignature" : "e244ac45ba14187a789b5cee536003d494cdd86c",
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "6112d17137f5d11121dcd4e2",
      "factorPackIds" : {

      },
      "deploymentId" : 240000413
    },
    {
      "rolloutId" : "60186475825c62000ccf5450",
      "factorPackIds" : {

      },
      "deploymentId" : 240000062
    }
  ],
  "experiments" : [
    {
      "treatmentId" : "6dd670af-0633-45e4-ae5f-122ae4df02be",
      "experimentId" : "64406ba83deb637ac8a04419",
      "deploymentId" : 900000017
    }
  ]
}
}

It's a buffer overrun:

t's a buffer overrun
diff --git a/misc/strip.c b/misc/strip.c
index 2a04cec..0c004bb 100644
--- a/misc/strip.c
+++ b/misc/strip.c
@@ -4058,6 +4058,7 @@ enum bool *nlist_outofsync_with_dyldinfo)
            new_strsize = rnd32(new_strsize, sizeof(int32_t));
        else
            new_strsize = rnd32(new_strsize, sizeof(int64_t));
+       new_strsize *= 2;
        new_strings = (char *)allocate(new_strsize);

        /*

looks like the code that computes the size of all the strings doesn't quite match the code that copies strings around

@dotMorten
Copy link
Contributor Author

With the latest RC2.1 workload update that shipped yesterday, it appears that Xcode 15 is now required, so we no longer can work around this issue. This makes it a complete showstopper today, rather than in May when XCode 15 will be required by the app store.

@dalexsoto
Copy link
Member

dalexsoto commented Nov 1, 2023

@dotMorten I know it's not ideal but can you try Xcode 15.1 Beta 2 to see if it is solved there? We do need some validation.

@rolfbjarne
Copy link
Member

This is not fixed in Xcode 15.1 beta 2 :/

@rolfbjarne
Copy link
Member

I submitted a ticket using Apple's feedback assistant (FB13327641), let's see what they say.

If I have time, I'll try to see if there's a way to work around it (won't be this week unfortunately).

@dalexsoto
Copy link
Member

Thanks a lot @rolfbjarne!

@rolfbjarne
Copy link
Member

I think I figured out the problem with strip, and created a pull request: apple-oss-distributions/cctools#2

@rolfbjarne
Copy link
Member

@dotMorten can you try adding this to your csproj to see if it fixes the problem?

<PropertyGroup>
    <_ExportSymbolsExplicitly>false</_ExportSymbolsExplicitly>
</PropertyGroup>

@dotMorten
Copy link
Contributor Author

@rolfbjarne That does appear to workaround it as well. What does this do?

@rolfbjarne
Copy link
Member

For every P/Invoke, we tell the native linker that it can't remove the symbol in question.

We used to do this by passing -usymbol for each symbol to the native linker, but in .NET 8 we switched to creating a file with all the symbols, and passing the file to the native linker with -exported_symbols_list [file].

Setting _ExportSymbolsExplicitly=false switches back to the old behavior, passing symbols with -usymbol.

@arnsteinjo
Copy link

Adding
<PropertyGroup> <_ExportSymbolsExplicitly>false</_ExportSymbolsExplicitly> </PropertyGroup>

fixes the issue on iOS, but now I am unable to load resources (Images, Fonts, ...) for Android so best to use a conditional:
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0-ios'">

@rolfbjarne rolfbjarne modified the milestones: .NET 8, Future Nov 9, 2023
@dotMorten
Copy link
Contributor Author

Not sure why, but today with .NET 8 RTM + XCode 15.0.1 I'm not seeing this issue. Can anyone else confirm this?

@rolfbjarne
Copy link
Member

I can't reproduce either.

Note that this doesn't mean all is good: the bug is a memory corruption inside strip, which means we get random behavior, and today that random behavior might be "works as expected."

@rolfbjarne
Copy link
Member

rolfbjarne commented Sep 20, 2024

This seems to have cropped up again in Xcode 16.0 :/

If anyone runs into this, please file a feedback ticket with Apple.

Feel free to reference the pull request with the fix: apple-oss-distributions/cctools#2, and also the existing feedback ticket I raised (FB13327641).

@dotMorten
Copy link
Contributor Author

dotMorten commented Sep 26, 2024

Yup I'm seeing it too! Submitted FB15289922

@carljohansen
Copy link

I have created a duplicate Apple feedback ticket (every little helps). But I have to say: surely a behemoth like Microsoft has great high-level contacts at Apple? I bet that an email from one senior manager to another would accomplish more than we lowly developers can.

@MichelePannacciTerex
Copy link

Well, with Xcode 16.1 I no longer have the problem. strip works as expected.

@Jeanjean
Copy link

Jeanjean commented Oct 31, 2024

Well, with Xcode 16.1 I no longer have the problem. strip works as expected.

Hmm, I've updated my build pipeline to:

  • Xcode 16.1,
  • .Net SDK 8.0.403 and
  • maui-android & maui-ios workloads version 8.0.403

But when running dotnet publish I'm still getting

Optimizing assemblies for size. This process might take a while.
  Tool xcrun execution finished (exit code = 139).
          
/Users/builder/clone/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/tools/msbuild/iOS/Xamarin.Shared.targets(2848,3): error : strip exited with code 139 [/Users/builder/clone/xxx/xxx.csproj::TargetFramework=net8.0-ios]
/Users/builder/clone/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/tools/msbuild/iOS/Xamarin.Shared.targets(2848,3): error :          [/Users/builder/clone/xxx/xxx.csproj::TargetFramework=net8.0-ios]

What am I missing?

@MichelePannacciTerex
Copy link

Well, with Xcode 16.1 I no longer have the problem. strip works as expected.

Hmm, I've updated my build pipeline to:

  • Xcode 16.1,
  • .Net SDK 8.0.403 and
  • maui-android & maui-ios workloads version 8.0.403

But when running dotnet publish I'm still getting

Optimizing assemblies for size. This process might take a while.
  Tool xcrun execution finished (exit code = 139).
          
/Users/builder/clone/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/tools/msbuild/iOS/Xamarin.Shared.targets(2848,3): error : strip exited with code 139 [/Users/builder/clone/xxx/xxx.csproj::TargetFramework=net8.0-ios]
/Users/builder/clone/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/tools/msbuild/iOS/Xamarin.Shared.targets(2848,3): error :          [/Users/builder/clone/xxx/xxx.csproj::TargetFramework=net8.0-ios]

What am I missing?

I'm on .net 9 RC2 and never had this problem building against .net 8.

@MichaelAzzer
Copy link

Well, with Xcode 16.1 I no longer have the problem. strip works as expected.

Yes it works for me also with .net 9rc2 but it need to restart mac after installing xcode16.1 and set it as default
Thank you 😊

@dotMorten
Copy link
Contributor Author

I'm still seeing it with 16.1

@activa
Copy link

activa commented Nov 5, 2024

So what's the short term official solution here? A lot of people haven't been able to build production apps on iOS for a month but there's not a single mention of this issue on the MAUI documentation pages.

@SaqibS
Copy link

SaqibS commented Nov 5, 2024

Likewise - our app was building fine on .NET 8, but after updating to .NET 9 RC2, with either Xcode 16 or 16.1, we start to see this error.

rolfbjarne added a commit to rolfbjarne/cctools that referenced this issue Nov 5, 2024
@rolfbjarne
Copy link
Member

rolfbjarne commented Nov 5, 2024

Here's a repository that can hopefully be used to compile your own strip tool: https://github.com/rolfbjarne/RolfKvinge.StripReplacement.

I might release this on NuGet, but that won't be for a little while at least (until we've released support for Xcode 16.1, which will bring a necessary fix).

@alexander-efremov
Copy link

@rolfbjarne could you share an instruction to build and use the tool?

@ALL: does anyone tried to use XCode 16.2 Beta 2?

@rolfbjarne
Copy link
Member

@rolfbjarne could you share an instruction to build and use the tool?

There are instructions in the README: https://github.com/rolfbjarne/RolfKvinge.StripReplacement#to-build

@bwinklesky
Copy link

Giving this issue a bump. Upgraded to XCode 16 and running into this issue.

@MichelePannacciTerex
Copy link

Giving this issue a bump. Upgraded to XCode 16 and running into this issue.

Hi, the solution is right above your post. Unfortunately the issue comes from Apple but it is Microsoft here...

@ahmad-crossplatform
Copy link

If you have sentry in your project , then removing it will probably fix the issue .

@bwinklesky
Copy link

Giving this issue a bump. Upgraded to XCode 16 and running into this issue.

Hi, the solution is right above your post. Unfortunately the issue comes from Apple but it is Microsoft here...

That's not a solution.

@activa
Copy link

activa commented Nov 14, 2024

Hi, the solution is right above your post. Unfortunately the issue comes from Apple but it is Microsoft here...

That's not a solution.

Correct, blaming it on Apple and throwing your hands up in the air is not a solution. It may be an issue in a tool provided by Apple but it doesn't affect Apple so they don't care, nor should they. So it's up to Microsoft to provide a workaround

@MichaelAzzer
Copy link

MichaelAzzer commented Nov 14, 2024 via email

@cleardemon
Copy link

If anyone is building their MAUI iOS app with GitHub Actions, using Microsoft hosted runners, and running into this problem, I have a workaround.

  1. Use @rolfbjarne's build instructions to compile a new version of strip with his fix in (thanks Rolf!)
  2. Copy that output of strip (from external/cctools/build/Release/strip) to your Git repo for your project (e.g., I used a folder macOS-StripHack in the root of the repo).
  3. Amend your workflow to include the following steps (adapt as necessary to your project):
      - name: Setup Xcode
        uses: maxim-lobanov/setup-xcode@v1
        with:
          xcode-version: '16.0'
      - name: Install strip hack (remove if not needed)
        run: |
          cp "$(xcrun -f strip)" "$(xcrun -f strip)"-old
          cp ./macOS-StripHack/strip "$(xcrun -f strip)"
          chmod +x "$(xcrun -f strip)"
      - name: Setup .NET
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: 8.0.403
      - name: Install MAUI
        run: dotnet workload install maui --version 8.0.403
  1. Somewhere near the end of your workflow, add the following (to tidy up):
      - name: Remove strip hack (remove if not needed)
        if: ${{ always() }}
        run: |
          mv -f "$(xcrun -f strip)"-old "$(xcrun -f strip)"

Then run the workflow, and that should be problem solved.

Observations

A major contributor to this failure happening seems to be including Sentry.io in the project, but removing that from production is not viable. That's not to say Sentry itself as it fault, I just don't understand the details enough.

I have not tried using Xcode 16.1, but it seems .NET 8 is not ready for Xcode 16.1 at the time of writing.

This assumes you are building strip on Apple Silicon (since the hosted runners all use M-series chips, too).

I previously made this post with an error in a script, which is noticed after posting and deleted it. This version does work! 😄

@codercampos
Copy link

Run into this today. This might be the case for Azure Devops agents too. I'm giving it a try right now.

@rolfbjarne
Copy link
Member

Apple might have fixed this for Xcode 16.2, my feedback ticket just got an update:

Please verify this issue with Xcode 16.2 Beta 2 and update your bug report with your results by logging into https://feedbackassistant.apple.com/ or by using the Feedback Assistant app.

Xcode 16.2 Beta 2 (16C5013f)
https://developer.apple.com/download/

If resolved, you can close your feedback by choosing the Close Feedback menu item in the Actions pop-up in Feedback Assistant.

Note: I haven't verified this myself yet, so I can't confirm if it's fixed or not.

@codercampos
Copy link

codercampos commented Nov 15, 2024

I ran a pipeline in Azure DevOps that implements @rolfbjarne solution. Everything went good.

Here is a sample of the task:

- task: CmdLine@2
  inputs:
    script: |
      git clone --recurse-submodules https://github.com/rolfbjarne/RolfKvinge.StripReplacement
      cd RolfKvinge.StripReplacement
      make
      echo "Will overwrite this file: $(xcrun -f strip)"
      cp external/cctools/build/Release/strip "$(xcrun -f strip)"

Everything went good.

Apple might have fixed this for Xcode 16.2, my feedback ticket just got an update:

Please verify this issue with Xcode 16.2 Beta 2 and update your bug report with your results by logging into https://feedbackassistant.apple.com/ or by using the Feedback Assistant app.

Xcode 16.2 Beta 2 (16C5013f)
https://developer.apple.com/download/

If resolved, you can close your feedback by choosing the Close Feedback menu item in the Actions pop-up in Feedback Assistant.

Note: I haven't verified this myself yet, so I can't confirm if it's fixed or not.

I can test this but I think .NET 8 and 9 are not ready for that Xcode version. We are stuck until then.

EDIT:

Is not available yet in macOS agents. I might download it later though.

@carljohansen
Copy link

Apple might have fixed this for Xcode 16.2, my feedback ticket just got an update:

I just built my .NET 9 project with XCode 16.2 Beta 2 and VS 17.12.0. I didn't get the strip error! I was getting it with XCode 16.1.

@postalservice14
Copy link

postalservice14 commented Nov 15, 2024

Is not available yet in macOS agents. I might download it later though.

Azure devops macos-15 vmImage now has XCode 16.2 Beta 2! The docs don't reflect it yet, but you don't need to replace strip any longer when using the following task:

  - script: |
        sudo xcode-select -s /Applications/Xcode_16.2_beta_2.app/Contents/Developer
    displayName: 'Select Xcode 16.2 Beta 2 Release Candidate'

@bwinklesky
Copy link

bwinklesky commented Nov 15, 2024

Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
11:09:12     Optimizing assemblies for size. This process might take a while.
11:09:36     IL stripping assemblies
11:09:55     Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.0/18.0.9617/targets/Xamarin.Shared.Sdk.targets(1277,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.

Xcode 16.2 Beta 2 produces this for me. I assume it's related

@MichelePannacciTerex
Copy link

Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
11:09:12     Optimizing assemblies for size. This process might take a while.
11:09:36     IL stripping assemblies
11:09:55     Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.0/18.0.9617/targets/Xamarin.Shared.Sdk.targets(1277,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.

Xcode 16.2 Beta 2 produces this for me. I assume it's related

error code 139 is a SIGSEV (call for termination) but strip has nothing to in this case.

@bwinklesky
Copy link

bwinklesky commented Nov 15, 2024

Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
11:09:12     Optimizing assemblies for size. This process might take a while.
11:09:36     IL stripping assemblies
11:09:55     Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.0/18.0.9617/targets/Xamarin.Shared.Sdk.targets(1277,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.

Xcode 16.2 Beta 2 produces this for me. I assume it's related

error code 139 is a SIGSEV (call for termination) but strip has nothing to in this case.

What is this error then? It's the same code compiling against version 9 SDK. AOT seems like it would theoretically use strip.

@MichelePannacciTerex
Copy link

MichelePannacciTerex commented Nov 15, 2024

Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
11:09:12     Optimizing assemblies for size. This process might take a while.
11:09:36     IL stripping assemblies
11:09:55     Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.0/18.0.9617/targets/Xamarin.Shared.Sdk.targets(1277,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.

Xcode 16.2 Beta 2 produces this for me. I assume it's related

error code 139 is a SIGSEV (call for termination) but strip has nothing to in this case.

What is this error then? It's the same code compiling against version 9 SDK. AOT seems like it would theoretically use strip.

But it's not strip that failing here. Had same exact problem once yesterday. I've deleted the bin and the obj folders then it worked.

@rolfbjarne
Copy link
Member

Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
11:09:12     Optimizing assemblies for size. This process might take a while.
11:09:36     IL stripping assemblies
11:09:55     Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.0/18.0.9617/targets/Xamarin.Shared.Sdk.targets(1277,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.

Xcode 16.2 Beta 2 produces this for me. I assume it's related

error code 139 is a SIGSEV (call for termination) but strip has nothing to in this case.

What is this error then? It's the same code compiling against version 9 SDK. AOT seems like it would theoretically use strip.

I can confirm this has nothing to do with strip, it's an unrelated problem that just looks similar. If you can still reproduce with a clean build as another commenter suggested, please file a new issue and we'll have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug If an issue is a bug or a pull request a bug fix
Projects
None yet
Development

No branches or pull requests