Skip to content

Crash of programs linked with libcurl on macOS Sonoma 14: unrecognized selector sent to instance #11893

@ryandesign

Description

@ryandesign

I did this

On macOS Sonoma 14 beta, cargo and other programs that link with libcurl may crash with an NSInvalidArgumentException because of an unrecognized selector sent to instance.

Crash log
% cargo
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString stringByStandardizingPath]: unrecognized selector sent to instance 0x6000039280c0'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000018ac78960 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x000000018a771eb4 objc_exception_throw + 60
	2   CoreFoundation                      0x000000018ad2a46c -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x000000018abe2b24 ___forwarding___ + 1572
	4   CoreFoundation                      0x000000018abe2440 _CF_forwarding_prep_0 + 96
	5   Foundation                          0x000000018bcb3d80 -[NSProcessInfo arguments] + 188
	6   CoreFoundation                      0x000000018acf4094 __getDefaultArguments_block_invoke + 96
	7   libdispatch.dylib                   0x000000018a979910 _dispatch_client_callout + 20
	8   libdispatch.dylib                   0x000000018a97b14c _dispatch_once_callout + 32
	9   CoreFoundation                      0x000000018acf3a30 _addBackstopValuesForIdentifierAndSource + 640
	10  CoreFoundation                      0x000000018abae3b4 __81-[_CFXPreferences(SourceAdditions) withNamedVolatileSourceForIdentifier:perform:]_block_invoke + 144
	11  CoreFoundation                      0x000000018acf36d8 -[_CFXPreferences withNamedVolatileSourceForIdentifier:perform:] + 272
	12  CoreFoundation                      0x000000018abb4724 -[CFPrefsSearchListSource addNamedVolatileSourceForIdentifier:] + 136
	13  CoreFoundation                      0x000000018ad3294c __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke.155 + 296
	14  CoreFoundation                      0x000000018ad325f4 -[_CFXPreferences withSearchLists:] + 84
	15  CoreFoundation                      0x000000018abafc78 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 300
	16  CoreFoundation                      0x000000018ad327a0 -[_CFXPreferences withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 384
	17  CoreFoundation                      0x000000018abaf5a0 -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] + 156
	18  CoreFoundation                      0x000000018abaf4c8 _CFPreferencesCopyAppValueWithContainerAndConfiguration + 112
	19  SystemConfiguration                 0x000000018b93c488 SCDynamicStoreCopyProxiesWithOptions + 180
	20  libcurl.4.dylib                     0x0000000105a05208 Curl_macos_init + 16
	21  libcurl.4.dylib                     0x00000001059ec140 global_init + 172
	22  libcurl.4.dylib                     0x00000001059ec084 curl_global_init + 68
	23  cargo                               0x000000010494b258 _ZN3std4sync4once4Once9call_once28_$u7b$$u7b$closure$u7d$$u7d$17h570c2b55831af76eE + 36
	24  cargo                               0x0000000104a57f90 _ZN3std10sys_common4once5queue4Once4call17h1bdcfaca3dc29e5fE + 724
	25  cargo                               0x000000010494b438 _ZN4curl9INIT_CTOR9init_ctor17hc2079233d77e33e8E + 96
	26  dyld                                0x000000018a7c95c8 ___ZZNK5dyld46Loader25findAndRunAllInitializersERNS_12RuntimeStateEENK3$_0clEv_block_invoke + 168
	27  dyld                                0x000000018a80e920 ___ZNK5dyld313MachOAnalyzer18forEachInitializerER11DiagnosticsRKNS0_15VMAddrConverterEU13block_pointerFvjEPKv_block_invoke.209 + 340
	28  dyld                                0x000000018a801c60 ___ZNK5dyld39MachOFile14forEachSectionEU13block_pointerFvRKNS0_11SectionInfoEbRbE_block_invoke + 496
	29  dyld                                0x000000018a7a92fc _ZNK5dyld39MachOFile18forEachLoadCommandER11DiagnosticsU13block_pointerFvPK12load_commandRbE + 300
	30  dyld                                0x000000018a800c98 _ZNK5dyld39MachOFile14forEachSectionEU13block_pointerFvRKNS0_11SectionInfoEbRbE + 192
	31  dyld                                0x000000018a80e434 _ZNK5dyld313MachOAnalyzer18forEachInitializerER11DiagnosticsRKNS0_15VMAddrConverterEU13block_pointerFvjEPKv + 516
	32  dyld                                0x000000018a7c5798 _ZNK5dyld46Loader25findAndRunAllInitializersERNS_12RuntimeStateE + 448
	33  dyld                                0x000000018a7cbb14 _ZNK5dyld416JustInTimeLoader15runInitializersERNS_12RuntimeStateE + 36
	34  dyld                                0x000000018a7c5b4c _ZNK5dyld46Loader23runInitializersBottomUpERNS_12RuntimeStateERN5dyld35ArrayIPKS0_EE + 220
	35  dyld                                0x000000018a7c9654 _ZZNK5dyld46Loader38runInitializersBottomUpPlusUpwardLinksERNS_12RuntimeStateEENK3$_1clEv + 112
	36  dyld                                0x000000018a7c5ccc _ZNK5dyld46Loader38runInitializersBottomUpPlusUpwardLinksERNS_12RuntimeStateE + 304
	37  dyld                                0x000000018a7eaad4 _ZN5dyld44APIs25runAllInitializersForMainEv + 464
	38  dyld                                0x000000018a7adf34 _ZN5dyld4L7prepareERNS_4APIsEPKN5dyld313MachOAnalyzerE + 3192
	39  dyld                                0x000000018a7acf44 start + 1948
)
libc++abi: terminating due to uncaught exception of type NSException
Abort trap: 6

This has been reported here:

macOS Sonoma will be publicly released September 26, 2023, so it seems that this problem will likely make it into the public release so curl should work around it.

@Ryu-ga commented in some of these issues that in macOS Sonoma, CoreFoundation requires CoreServices, and that linking libcurl with CoreServices fixes the problem.

This relates to curl's recent use of SCDynamicStoreCopyProxies at startup on macOS so it should only affect builds on macOS that enable IPv6 support and that do not use c-ares.

I'll submit a PR to update curl's autotools and cmake build systems to do that and @Schamschula has already prepared a patch to curl in MacPorts to use in the mean time (macports/macports-ports#20502).

I expected the following

No crash

curl/libcurl version

curl 8.3.0

operating system

macOS 14 beta

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions