Async Await crash on iOS14 with Xcode 13.2.1

In the debugger console, if you run image list does it show the libswift_Concurrency.dylib as being loaded?

Doug

Nope, 264 items on the list but not that one. Tell me what to do while I am still in debugger.

btw, this is what it tries to de-mangle:

0x1008835d4 <+28>:  adr    x0, #0xa78c               ; demangling cache variable for type metadata for Swift.Optional<Swift.TaskPriority>

That explains the crash, because the runtime is looking for a symbol in libswift_Concurrency.dylib, but that shared library hasn't been loaded. That means either it isn't there in the .app, or it's somehow invalid. If you look at the .app directory on disk, does it have libswift_Concurrency.dylib in its Frameworks directory? If so, is it ~1MB or is it ~11MB?

Doug

1 Like

Yes, it is (in the app that is in the build folder on mac). It is 1MB. I also see it mentioned in CodeResources.

From the build log:

Copying /Applications/Xcode-13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/iphoneos/libswift_Concurrency.dylib to /Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib
/Applications/Xcode-13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip /Applications/Xcode-13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/iphoneos/libswift_Concurrency.dylib -r -o /Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib
Probing signature of /Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib
/usr/bin/codesign -r- --display /Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib
/Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib: code object is not signed at all

Codesigning /Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib
/usr/bin/codesign --force --sign 2BBB636743121E376194A84FCD31546991DBFAB9 --verbose /Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib

hmm.. "code object is not signed at all" ?
Can the issue be because the library is not signed?

(Note in this particular instance to help with debugging in Xcode I am building debug version.)

According to Xcode signing settings the signing is automatic for both debug and release, and it doesn't raise any flags.

hmm.. let me do this test again. I'll try release now.

1 Like

@Douglas_Gregor, I was puzzled by that "not signed at all" message. when I run it manually in terminal that's what I am getting:

/usr/bin/codesign -r- --display /Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib
Executable=/Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib
designated => identifier "com.apple.dt.runtime.swiftConcurrency" and anchor apple generic and certificate leaf[subject.CN] = "Apple Development: ***reducted***" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */

no, probably red herring, as that's just the check. and it's getting signed the next line. something else.

Just curious, how is it working for @Douglas_Gregor but for myself, @tera and others are experiencing/reproduce crash?

No idea 🤔

I have several different Xcodes and often switch between them (I mean just launching different Xcodes, sometimes having two opened at once, I'm not doing anything fancy in terminal "to switch"). When installing new versions of Xcode (betas or releases) Xcode sometimes prompts me to install command line tools (or whatever that was named) which I do but I always wonder if switching between Xcode's is reliable. I also had Xcode 13 beta on this machine.

I have only one Xcode installed (13.2.1) and only one command line tools installed (13.2.1 too).
Xcode was installed via XIP (not from store) btw.

same here

Mine was installed from Appstore, if that helps.

Anything suspicious here?

otool -L /Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/CrashTest2 
/Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/CrashTest2:
	/System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 1856.105.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
	/System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 5205.0.101)
	/usr/lib/swift/libswiftCore.dylib (compatibility version 1.0.0, current version 1300.0.46)
	/usr/lib/swift/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 14.0.0, weak)
	/usr/lib/swift/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 3.0.0, weak)
	/usr/lib/swift/libswiftCoreImage.dylib (compatibility version 1.0.0, current version 2.0.0, weak)
	/usr/lib/swift/libswiftDarwin.dylib (compatibility version 1.0.0, current version 0.0.0, weak)
	/usr/lib/swift/libswiftDataDetection.dylib (compatibility version 1.0.0, current version 697.1.0, weak)
	/usr/lib/swift/libswiftDispatch.dylib (compatibility version 1.0.0, current version 11.0.0)
	/usr/lib/swift/libswiftFileProvider.dylib (compatibility version 1.0.0, current version 378.62.1, weak)
	/usr/lib/swift/libswiftFoundation.dylib (compatibility version 1.0.0, current version 70.101.0)
	/usr/lib/swift/libswiftMetal.dylib (compatibility version 1.0.0, current version 258.14.0, weak)
	/usr/lib/swift/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 2.0.0, weak)
	/usr/lib/swift/libswiftQuartzCore.dylib (compatibility version 1.0.0, current version 3.0.0, weak)
	/usr/lib/swift/libswiftUIKit.dylib (compatibility version 1.0.0, current version 5100.0.0)
	@rpath/libswift_Concurrency.dylib (compatibility version 1.0.0, current version 1300.0.46, weak)

I think this looks fine as long as /Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib exists and otool -l /Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/CrashTest2 | grep -A2 RPATH shows something like this:

          cmd LC_RPATH
      cmdsize 32
         path /usr/lib/swift (offset 12)
--
          cmd LC_RPATH
      cmdsize 40
         path @executable_path/Frameworks (offset 12)

I am a bit surprised that the library is loaded weakly, I did some hacking on LD to make this not weak, and when reproducing this crash, instead of the reports we have above, I got:

Termination Description: DYLD, dependent dylib '@rpath/libswift_Concurrency.dylib' not found for '/private/var/containers/Bundle/Application/AF6C2EFE-2B61-48EF-9EF4-53B7C29B103D/crashtest.app/crashtest'. chained fixups, seg_count does not match number of segments

Which might lead us to something.

Full otool output for those who can read it.
otool -l /Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/CrashTest2
/Users/tera/Library/Developer/Xcode/DerivedData/CrashTest2-dxpfkkbbfiopxcavapqahqofquyf/Build/Products/Release-iphoneos/CrashTest2.app/CrashTest2:

Load command 0
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __PAGEZERO
   vmaddr 0x0000000000000000
   vmsize 0x0000000100000000
  fileoff 0
 filesize 0
  maxprot 0x00000000
 initprot 0x00000000
   nsects 0
    flags 0x0
Load command 1
      cmd LC_SEGMENT_64
  cmdsize 1192
  segname __TEXT
   vmaddr 0x0000000100000000
   vmsize 0x000000000000c000
  fileoff 0
 filesize 49152
  maxprot 0x00000005
 initprot 0x00000005
   nsects 14
    flags 0x0
Section
  sectname __text
   segname __TEXT
      addr 0x0000000100007300
      size 0x0000000000002330
    offset 29440
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __stubs
   segname __TEXT
      addr 0x0000000100009630
      size 0x000000000000033c
    offset 38448
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000408
 reserved1 0 (index into indirect symbol table)
 reserved2 12 (size of stubs)
Section
  sectname __stub_helper
   segname __TEXT
      addr 0x000000010000996c
      size 0x0000000000000354
    offset 39276
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __const
   segname __TEXT
      addr 0x0000000100009cc0
      size 0x00000000000001c0
    offset 40128
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __swift5_entry
   segname __TEXT
      addr 0x0000000100009e80
      size 0x0000000000000004
    offset 40576
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __cstring
   segname __TEXT
      addr 0x0000000100009e90
      size 0x0000000000000f51
    offset 40592
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __objc_methname
   segname __TEXT
      addr 0x000000010000ade1
      size 0x0000000000000d20
    offset 44513
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __swift5_typeref
   segname __TEXT
      addr 0x000000010000bb02
      size 0x000000000000007f
    offset 47874
     align 2^1 (2)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __swift5_fieldmd
   segname __TEXT
      addr 0x000000010000bb84
      size 0x000000000000003c
    offset 48004
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __swift5_capture
   segname __TEXT
      addr 0x000000010000bbc0
      size 0x0000000000000040
    offset 48064
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __swift5_types
   segname __TEXT
      addr 0x000000010000bc00
      size 0x000000000000000c
    offset 48128
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __swift5_reflstr
   segname __TEXT
      addr 0x000000010000bc0c
      size 0x0000000000000007
    offset 48140
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __unwind_info
   segname __TEXT
      addr 0x000000010000bc14
      size 0x000000000000017c
    offset 48148
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __eh_frame
   segname __TEXT
      addr 0x000000010000bd90
      size 0x000000000000026c
    offset 48528
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 2
      cmd LC_SEGMENT_64
  cmdsize 472
  segname __DATA_CONST
   vmaddr 0x000000010000c000
   vmsize 0x0000000000004000
  fileoff 49152
 filesize 16384
  maxprot 0x00000003
 initprot 0x00000003
   nsects 5
    flags 0x10
Section
  sectname __got
   segname __DATA_CONST
      addr 0x000000010000c000
      size 0x0000000000000090
    offset 49152
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 69 (index into indirect symbol table)
 reserved2 0
Section
  sectname __const
   segname __DATA_CONST
      addr 0x000000010000c090
      size 0x0000000000000180
    offset 49296
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_classlist
   segname __DATA_CONST
      addr 0x000000010000c210
      size 0x0000000000000018
    offset 49680
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x10000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_protolist
   segname __DATA_CONST
      addr 0x000000010000c228
      size 0x0000000000000020
    offset 49704
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_imageinfo
   segname __DATA_CONST
      addr 0x000000010000c248
      size 0x0000000000000008
    offset 49736
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 3
      cmd LC_SEGMENT_64
  cmdsize 792
  segname __DATA
   vmaddr 0x0000000100010000
   vmsize 0x0000000000004000
  fileoff 65536
 filesize 16384
  maxprot 0x00000003
 initprot 0x00000003
   nsects 9
    flags 0x0
Section
  sectname __la_symbol_ptr
   segname __DATA
      addr 0x0000000100010000
      size 0x0000000000000228
    offset 65536
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000007
 reserved1 87 (index into indirect symbol table)
 reserved2 0
Section
  sectname __objc_const
   segname __DATA
      addr 0x0000000100010228
      size 0x00000000000008a8
    offset 66088
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_selrefs
   segname __DATA
      addr 0x0000000100010ad0
      size 0x0000000000000038
    offset 68304
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x10000005
 reserved1 0
 reserved2 0
Section
  sectname __objc_protorefs
   segname __DATA
      addr 0x0000000100010b08
      size 0x0000000000000020
    offset 68360
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_classrefs
   segname __DATA
      addr 0x0000000100010b28
      size 0x0000000000000010
    offset 68392
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x10000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_data
   segname __DATA
      addr 0x0000000100010b38
      size 0x00000000000011d0
    offset 68408
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __data
   segname __DATA
      addr 0x0000000100011d08
      size 0x00000000000000da
    offset 72968
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __swift51_hooks
   segname __DATA
      addr 0x0000000100011de8
      size 0x00000000000000b8
    offset 73192
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __bss
   segname __DATA
      addr 0x0000000100011ea0
      size 0x00000000000000d8
    offset 0
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Load command 4
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __LINKEDIT
   vmaddr 0x0000000100014000
   vmsize 0x0000000000010000
  fileoff 81920
 filesize 58256
  maxprot 0x00000001
 initprot 0x00000001
   nsects 0
    flags 0x0
Load command 5
            cmd LC_DYLD_INFO_ONLY
        cmdsize 48
     rebase_off 81920
    rebase_size 432
       bind_off 82352
      bind_size 1576
  weak_bind_off 0
 weak_bind_size 0
  lazy_bind_off 83928
 lazy_bind_size 2240
     export_off 86168
    export_size 392
Load command 6
     cmd LC_SYMTAB
 cmdsize 24
  symoff 86656
   nsyms 657
  stroff 97792
 strsize 22160
Load command 7
            cmd LC_DYSYMTAB
        cmdsize 80
      ilocalsym 0
      nlocalsym 542
     iextdefsym 542
     nextdefsym 5
      iundefsym 547
      nundefsym 110
         tocoff 0
           ntoc 0
      modtaboff 0
        nmodtab 0
   extrefsymoff 0
    nextrefsyms 0
 indirectsymoff 97168
  nindirectsyms 156
      extreloff 0
        nextrel 0
      locreloff 0
        nlocrel 0
Load command 8
          cmd LC_LOAD_DYLINKER
      cmdsize 32
         name /usr/lib/dyld (offset 12)
Load command 9
     cmd LC_UUID
 cmdsize 24
    uuid F1302A6D-5B60-3B7C-B879-706A7F8C4E5D
Load command 10
      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 2
    minos 13.0
      sdk 15.2
   ntools 1
     tool 3
  version 711.0
Load command 11
      cmd LC_SOURCE_VERSION
  cmdsize 16
  version 0.0
Load command 12
       cmd LC_MAIN
   cmdsize 24
  entryoff 31532
 stacksize 0
Load command 13
          cmd LC_ENCRYPTION_INFO_64
      cmdsize 24
     cryptoff 16384
    cryptsize 32768
      cryptid 0
          pad 0
Load command 14
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/Foundation.framework/Foundation (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 1856.105.0
compatibility version 300.0.0
Load command 15
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libobjc.A.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 228.0.0
compatibility version 1.0.0
Load command 16
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 1311.0.0
compatibility version 1.0.0
Load command 17
          cmd LC_LOAD_DYLIB
      cmdsize 80
         name /System/Library/Frameworks/UIKit.framework/UIKit (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 5205.0.101
compatibility version 1.0.0
Load command 18
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name /usr/lib/swift/libswiftCore.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 1300.0.46
compatibility version 1.0.0
Load command 19
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 72
         name /usr/lib/swift/libswiftCoreFoundation.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 14.0.0
compatibility version 1.0.0
Load command 20
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 72
         name /usr/lib/swift/libswiftCoreGraphics.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 3.0.0
compatibility version 1.0.0
Load command 21
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 64
         name /usr/lib/swift/libswiftCoreImage.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 2.0.0
compatibility version 1.0.0
Load command 22
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 64
         name /usr/lib/swift/libswiftDarwin.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 0.0.0
compatibility version 1.0.0
Load command 23
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 72
         name /usr/lib/swift/libswiftDataDetection.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 697.1.0
compatibility version 1.0.0
Load command 24
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name /usr/lib/swift/libswiftDispatch.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 11.0.0
compatibility version 1.0.0
Load command 25
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 72
         name /usr/lib/swift/libswiftFileProvider.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 378.62.1
compatibility version 1.0.0
Load command 26
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name /usr/lib/swift/libswiftFoundation.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 70.101.0
compatibility version 1.0.0
Load command 27
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 64
         name /usr/lib/swift/libswiftMetal.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 258.14.0
compatibility version 1.0.0
Load command 28
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 64
         name /usr/lib/swift/libswiftObjectiveC.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 2.0.0
compatibility version 1.0.0
Load command 29
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 64
         name /usr/lib/swift/libswiftQuartzCore.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 3.0.0
compatibility version 1.0.0
Load command 30
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name /usr/lib/swift/libswiftUIKit.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 5100.0.0
compatibility version 1.0.0
Load command 31
          cmd LC_LOAD_WEAK_DYLIB
      cmdsize 64
         name @rpath/libswift_Concurrency.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 1300.0.46
compatibility version 1.0.0
Load command 32
          cmd LC_RPATH
      cmdsize 32
         path /usr/lib/swift (offset 12)
Load command 33
          cmd LC_RPATH
      cmdsize 40
         path @executable_path/Frameworks (offset 12)
Load command 34
      cmd LC_FUNCTION_STARTS
  cmdsize 16
  dataoff 86560
 datasize 96
Load command 35
      cmd LC_DATA_IN_CODE
  cmdsize 16
  dataoff 86656
 datasize 0
Load command 36
      cmd LC_CODE_SIGNATURE
  cmdsize 16
  dataoff 119952
 datasize 20224

I was able to make this crash with the debugger attached in Xcode on an iOS 13 device by unchecking all the scheme options that lead to custom libraries being injected when launching the binary with DYLD_INSERT_LIBRARIES. Here is a project with that scheme shared GitHub - keith/backdeploy-concurrency-crash: https://forums.swift.org/t/async-await-crash-on-ios14-with-xcode-13-2-1/54541/33

My assumption based on my previous comment is DYLD changes behavior somehow based on those libraries being loaded as well. I would appreciate if someone could verify that running this project on their device also causes the crash even when attached in Xcode (you'll have to update provisioning info). I am testing on an iOS 13.6 device. In the crashed state image list does not show the concurrency library as loaded, but I assume since it's linked weakly that is accepted and leads to this crash later.

1 Like

So I noticed in this case that the dylib bundled with the app contains multiple architectures:

DerivedData/CrashTest2/Build/Products/Debug-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib: Mach-O universal binary with 2 architectures: [arm64:Mach-O 64-bit dynamically linked shared library arm64] [arm64e:Mach-O 64-bit dynamically linked shared library arm64e]
DerivedData/CrashTest2/Build/Products/Debug-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib (for architecture arm64):     Mach-O 64-bit dynamically linked shared library arm64
DerivedData/CrashTest2/Build/Products/Debug-iphoneos/CrashTest2.app/Frameworks/libswift_Concurrency.dylib (for architecture arm64e):    Mach-O 64-bit dynamically linked shared library arm64e

If I explicitly remove the arm64e slice from this with:

lipo -remove arm64e /path/to/dylib -output foo
mv foo /path/to/dylib

And re-run without Xcode overwriting this, it works successfully on my 13.6 device. I guess I'm not sure if this would be the same behavior on 14.x given the minimum OS version of that slice specific says 14.0, but I don't have a device on that OS version to test.

2 Likes

What are those options?

I can confirm both your findings: launching your project in Xcode crashes it into debugger and stripping the architecture fixes the bug, so the app can now be opened on iPhone. Tested on iOS 14.5. Well done!

1 Like

@Keith - I took your project and ran lipo to remove arm64e and ran the build in my device running iOS14.8 and can confirm that it did not crash by running with Xcode and also by running from homescreen (without Xcode). Awesome!!

By default at least the main thread checker, and the the other options in the Options tab of the scheme editor. I didn't do them one by one to see which translate to injecting some libraries, but it did seem to require they all be disabled.

Please note that I'm not recommending any of these solutions, I'm just hoping this debugging is helpful for the folks who know more about all the moving pieces here.

2 Likes

Thank you both for testing it!

2 Likes

So what happens next?