Ableton / LinkKit

iOS SDK for Ableton Link, a new technology that synchronizes musical beat, tempo, and phase across multiple applications running on one or more devices.
http://ableton.github.io/linkkit
Other
147 stars 10 forks source link

Build with Xcode 15 crashes on iOS 12 and macOS 10.15 #70

Closed arlomedia closed 10 months ago

arlomedia commented 10 months ago

I just released my first app versions built with Xcode 15 and started getting crash reports from users with iOS 12 and (for the Mac Catalyst version) macOS 10.15. It seems from the crash logs that this is caused by LinkKit:

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000000000da47000
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [586]

VM Regions Near 0xda47000:
--> 
__TEXT 000000010da47000-000000010e107000 [ 6912K] r-x/r-x SM=COW /Applications/Set List Maker.app/Contents/MacOS/Set List Maker

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.arlomedia.setlistmaker.macos 0x000000010dfe915e asio::detail::completion_handler, std::__1::function, std::__1::function, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context >::setClientState(ableton::link::IncomingClientState)::'lambda'(), asio::io_context::basic_executor_type, 0u> >::do_complete(void*, asio::detail::scheduler_operation*, std::__1::error_code const&, unsigned long) + 302
1 dyld 0x000000011bb02353 ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 535
2 dyld 0x000000011bb0275e ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 40
3 dyld 0x000000011bafd17b ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 493
4 dyld 0x000000011bafb234 ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 188
5 dyld 0x000000011bafb2d4 ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 82
6 dyld 0x000000011bae96a8 dyld::initializeMainExecutable() + 199
7 dyld 0x000000011baeebf7 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 6728
8 dyld 0x000000011bae8227 dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) + 453
9 dyld 0x000000011bae8025 _dyld_start + 37

That was from macOS. The iOS crash logs aren't symbolicating, but seem similar:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000254000
VM Region Info: 0x254000 is not in any region.  Bytes before following region: 4294967296
      REGION TYPE                      START - END             [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                 0000000100254000-0000000100258000 [   16K] r-x/r-x SM=COW  ...et List Maker

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [709]
Triggered by Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   Set List Maker                  0x000000010071ff80 __cxx_global_var_init.13 + 20
1   dyld                            0x0000000100b110e0 0x100af8000 + 102624
2   dyld                            0x0000000100b110e0 0x100af8000 + 102624
3   dyld                            0x0000000100b11314 0x100af8000 + 103188
4   dyld                            0x0000000100b0c398 0x100af8000 + 82840
5   dyld                            0x0000000100b0b3dc 0x100af8000 + 78812
6   dyld                            0x0000000100b0b498 0x100af8000 + 79000
7   dyld                            0x0000000100afa6d8 0x100af8000 + 9944
8   dyld                            0x0000000100aff2a0 0x100af8000 + 29344
9   dyld                            0x0000000100af9044 0x100af8000 + 4164

The crash happens on launch, before my app tries to use any LinkKit functions. Apparently just loading the ABLLink library triggers this.

I'm using LinkKit 3.1.5 currently. I see from the release notes that version 3.1.9 had a fix for compatibility with older iOS versions, but that was from a year and a half ago and didn't specify the problem or the versions affected. I don't have and older device to test with at this point so I'd like to know if this is fixed in a particular LinkKit version before releasing another app version with Xcode 15. I have reverted to building with Xcode 14 for now.

fgo-ableton commented 10 months ago

The Xcode 15 release notes mention a linker issue: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking 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) I guess this is what is causing the crash. They also mention a workaround.

arlomedia commented 10 months ago

Thanks for the info. Is it your understanding that -Wl and -ld_classic are two separate flags, or one flag -Wl,-ld_classic? Since I don't have an iOS 12 device to test this with, I want to be sure before releasing another update with Xcode 15. This is what I have now:

Screenshot 2023-09-25 at 5 25 18 PM

I also see that depending on the Xcode settings, OTHER_LDFLAGS will be displayed as Other Linker Flags.

cdi-ableton commented 10 months ago

I built the example app (from LinkKit 3.1.5) with Xcode 15 using the linker flags -Wl and -ld_classic and the macOS deployment target 10.15. It works without crashing on my Mac Mini running macOS Catalina 10.15.7. I added the two flags like it's shown in your screenshot. However, I recommend getting test coverage for all the platforms your application is supported on.

arlomedia commented 10 months ago

Confirmed -- I got an old iPad with iOS 12 and it crashes on launch without those two flags but runs fine with them. Thanks for your help!