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

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

Closed
ryandesign opened this issue Sep 20, 2023 · 0 comments

Comments

@ryandesign
Copy link
Contributor

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

ryandesign added a commit to ryandesign/curl that referenced this issue Sep 20, 2023
When linking with CoreFoundation, also link with CoreServices which is
apparently required to avoid an NSInvalidArgumentException in software
linking with libcurl on macOS Sonoma 14 and later.

Fixes curl#11893
@bagder bagder closed this as completed in 6ab7e19 Sep 20, 2023
ptitSeb pushed a commit to wasix-org/curl that referenced this issue Sep 25, 2023
When linking with CoreFoundation, also link with CoreServices which is
apparently required to avoid an NSInvalidArgumentException in software
linking with libcurl on macOS Sonoma 14 and later.

Fixes curl#11893
Closes curl#11894
SomeoneToIgnore added a commit to SomeoneToIgnore/curl-rust that referenced this issue Sep 28, 2023
This curl version fixes macOs Sonoma curl initialization crash:
curl/curl#11893
smoelius added a commit to trailofbits/dylint that referenced this issue Sep 29, 2023
github-merge-queue bot pushed a commit to trailofbits/dylint that referenced this issue Sep 29, 2023
BewareMyPower added a commit to BewareMyPower/vcpkg that referenced this issue Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant