C++ crash on iOS 13 built with Xcode 15 beta 7

See details: https://github.com/Tencent/wcdb/issues/971

Xcode 14.3.1 is ok

Thread 1 Queue : com.apple.main-thread (serial)
#0	0x0000000000000000 in 0x00000000 ()
#1	0x0000000106fb5f98 in _GLOBAL__sub_I_SyntaxCommonConst.cpp ()
#2	0x000000010a44b2c4 in ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) ()
#3	0x000000010a44b6b0 in ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) ()
#4	0x000000010a4460f0 in ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) ()
#5	0x000000010a444520 in ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) ()
#6	0x000000010a4445e8 in ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) ()
#7	0x000000010a436658 in dyld::initializeMainExecutable() ()
#8	0x000000010a43aeb0 in dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) ()
#9	0x000000010a435208 in dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) ()
#10	0x000000010a435038 in _dyld_start ()
Thread 2Thread 3com.apple.CoreMotion.MotionThread (4)

Accepted Reply

Xcode 15 RC Release Notes

Linking

New Features

A new linker has been written to significantly speed up static linking. It’s the default for all macOS, iOS, tvOS and visionOS binaries and anyone using the “Mergeable Libraries” feature. The classic linker can still be explicitly requested using -ld64, and will be removed in a future release.
 (108915312)

Known Issues

Binaries using symbols with a weak definition crash at runtime on iOS 14/macOS 12 or older. This impacts primarily C++ projects due to their extensive use of weak symbols. (114813650) (FB13097713)

Workaround: Bump the minimum deployment target to iOS 15, macOS 12, watchOS 8 or tvOS 15, or add -Wl,-ld_classic to the OTHER_LDFLAGS build setting.

Replies

    0x1051d0f7c <+0>:   stp    x24, x23, [sp, #-0x40]!
    0x1051d0f80 <+4>:   stp    x22, x21, [sp, #0x10]
    0x1051d0f84 <+8>:   stp    x20, x19, [sp, #0x20]
    0x1051d0f88 <+12>:  stp    x29, x30, [sp, #0x30]
    0x1051d0f8c <+16>:  add    x29, sp, #0x30
    0x1051d0f90 <+20>:  mov    w0, #0x18
    0x1051d0f94 <+24>:  bl     0x105526a18               ; symbol stub for: operator new(unsigned long)
->  0x1051d0f98 <+28>:  mov    x19, x0
    0x1051d0f9c <+32>:  adrp   x8, 4697
    0x1051d0fa0 <+36>:  ldr    x0, [x8, #0xe00]
    0x1051d0fa4 <+40>:  mov    x8, x19
    0x1051d0fa8 <+44>:  bl     0x105209c8c               ; WCDB::StringView::makeConstant at StringView.cpp:400
    0x1051d0fac <+48>:  adrp   x20, 4846
    0x1051d0fb0 <+52>:  str    x19, [x20, #0x658]
    0x1051d0fb4 <+56>:  mov    w0, #0x18
    0x1051d0fb8 <+60>:  bl     0x105526a18               ; symbol stub for: operator new(unsigned long)
    0x1051d0fbc <+64>:  mov    x19, x0
    0x1051d0fc0 <+68>:  adrp   x8, 4697
    0x1051d0fc4 <+72>:  ldr    x0, [x8, #0xe08]
    0x1051d0fc8 <+76>:  mov    x8, x19
    0x1051d0fcc <+80>:  bl     0x105209c8c               ; WCDB::StringView::makeConstant at StringView.cpp:400
    0x1051d0fd0 <+84>:  adrp   x21, 4846
    0x1051d0fd4 <+88>:  str    x19, [x21, #0x660]
    0x1051d0fd8 <+92>:  mov    w0, #0x18
    0x1051d0fdc <+96>:  bl     0x105526a18               ; symbol stub for: operator new(unsigned long)
    0x1051d0fe0 <+100>: mov    x19, x0
    0x1051d0fe4 <+104>: adrp   x8, 4697
    0x1051d0fe8 <+108>: ldr    x0, [x8, #0xe10]
    0x1051d0fec <+112>: mov    x8, x19
    0x1051d0ff0 <+116>: bl     0x105209c8c               ; WCDB::StringView::makeConstant at StringView.cpp:400
    0x1051d0ff4 <+120>: adrp   x22, 4846
    0x1051d0ff8 <+124>: str    x19, [x22, #0x668]
    0x1051d0ffc <+128>: mov    w0, #0x18
    0x1051d1000 <+132>: bl     0x105526a18               ; symbol stub for: operator new(unsigned long)
    0x1051d1004 <+136>: mov    x19, x0
    0x1051d1008 <+140>: adrp   x8, 4696
    0x1051d100c <+144>: ldr    x0, [x8, #0xe18]
    0x1051d1010 <+148>: mov    x8, x19
    0x1051d1014 <+152>: bl     0x105209c8c               ; WCDB::StringView::makeConstant at StringView.cpp:400
    0x1051d1018 <+156>: adrp   x23, 4845
    0x1051d101c <+160>: str    x19, [x23, #0x670]
    0x1051d1020 <+164>: mov    w0, #0x18
    0x1051d1024 <+168>: bl     0x105526a18               ; symbol stub for: operator new(unsigned long)
    0x1051d1028 <+172>: mov    x19, x0
    0x1051d102c <+176>: adrp   x8, 4696
    0x1051d1030 <+180>: ldr    x0, [x8, #0xe20]
    0x1051d1034 <+184>: mov    x8, x19
    0x1051d1038 <+188>: bl     0x105209c8c               ; WCDB::StringView::makeConstant at StringView.cpp:400
    0x1051d103c <+192>: adrp   x8, 4845
    0x1051d1040 <+196>: str    x19, [x8, #0x678]
    0x1051d1044 <+200>: ldr    x8, [x20, #0x658]
    0x1051d1048 <+204>: adrp   x9, 4845
    0x1051d104c <+208>: str    x8, [x9, #0x680]
    0x1051d1050 <+212>: ldr    x8, [x21, #0x660]
    0x1051d1054 <+216>: adrp   x9, 4845
    0x1051d1058 <+220>: str    x8, [x9, #0x688]
    0x1051d105c <+224>: ldr    x8, [x22, #0x668]
    0x1051d1060 <+228>: adrp   x9, 4845
    0x1051d1064 <+232>: str    x8, [x9, #0x690]
    0x1051d1068 <+236>: ldr    x8, [x23, #0x670]
    0x1051d106c <+240>: adrp   x9, 4845
    0x1051d1070 <+244>: str    x8, [x9, #0x698]
    0x1051d1074 <+248>: adrp   x8, 4845
    0x1051d1078 <+252>: str    x19, [x8, #0x6a0]
    0x1051d107c <+256>: ldp    x29, x30, [sp, #0x30]
    0x1051d1080 <+260>: ldp    x20, x19, [sp, #0x20]
    0x1051d1084 <+264>: ldp    x22, x21, [sp, #0x10]
    0x1051d1088 <+268>: ldp    x24, x23, [sp], #0x40
    0x1051d108c <+272>: ret    

Crash on new and reason is EXC_BAD_ACCESS (code=1, address=0x0)

Add a Comment

Xcode 15 RC Release Notes

Linking

New Features

A new linker has been written to significantly speed up static linking. It’s the default for all macOS, iOS, tvOS and visionOS binaries and anyone using the “Mergeable Libraries” feature. The classic linker can still be explicitly requested using -ld64, and will be removed in a future release.
 (108915312)

Known Issues

Binaries using symbols with a weak definition crash at runtime on iOS 14/macOS 12 or older. This impacts primarily C++ projects due to their extensive use of weak symbols. (114813650) (FB13097713)

Workaround: Bump the minimum deployment target to iOS 15, macOS 12, watchOS 8 or tvOS 15, or add -Wl,-ld_classic to the OTHER_LDFLAGS build setting.

Mentioned as fixed in Xcode 15.1 https://developer.apple.com/documentation/xcode-release-notes/xcode-15_1-release-notes

Fixed: Binaries using symbols with a weak definition crash at runtime on iOS 14/macOS 12 or older. This impacts primarily C++ projects due to their extensive use of weak symbols. (114813650)