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

aria2 doesn't work in Sonoma #2083

Closed
alphavector opened this issue Aug 20, 2023 · 23 comments
Closed

aria2 doesn't work in Sonoma #2083

alphavector opened this issue Aug 20, 2023 · 23 comments

Comments

@alphavector
Copy link

The simplest call results in an error

~ > aria2c
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString stringByStandardizingPath]: unrecognized selector sent to instance 0x600002c28450'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000189e34960 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x000000018992deb4 objc_exception_throw + 60
	2   CoreFoundation                      0x0000000189ee646c -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x0000000189d9eb24 ___forwarding___ + 1572
	4   CoreFoundation                      0x0000000189d9e440 _CF_forwarding_prep_0 + 96
	5   Foundation                          0x000000018ae6fd80 -[NSProcessInfo arguments] + 188
	6   CoreFoundation                      0x0000000189eb0094 __getDefaultArguments_block_invoke + 96
	7   libdispatch.dylib                   0x0000000189b35910 _dispatch_client_callout + 20
	8   libdispatch.dylib                   0x0000000189b3714c _dispatch_once_callout + 32
	9   CoreFoundation                      0x0000000189eafa30 _addBackstopValuesForIdentifierAndSource + 640
	10  CoreFoundation                      0x0000000189d6a3b4 __81-[_CFXPreferences(SourceAdditions) withNamedVolatileSourceForIdentifier:perform:]_block_invoke + 144
	11  CoreFoundation                      0x0000000189eaf6d8 -[_CFXPreferences withNamedVolatileSourceForIdentifier:perform:] + 272
	12  CoreFoundation                      0x0000000189d70724 -[CFPrefsSearchListSource addNamedVolatileSourceForIdentifier:] + 136
	13  CoreFoundation                      0x0000000189eee94c __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke.155 + 296
	14  CoreFoundation                      0x0000000189eee5f4 -[_CFXPreferences withSearchLists:] + 84
	15  CoreFoundation                      0x0000000189d6bc78 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 300
	16  CoreFoundation                      0x0000000189eee7a0 -[_CFXPreferences withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 384
	17  CoreFoundation                      0x0000000189d6b5a0 -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] + 156
	18  CoreFoundation                      0x0000000189d6b4c8 _CFPreferencesCopyAppValueWithContainerAndConfiguration + 112
	19  libintl.8.dylib                     0x00000001016f0ca4 _nl_locale_name_default + 72
	20  libintl.8.dylib                     0x00000001016eef54 libintl_dcigettext + 1852
	21  aria2c                              0x0000000100fa48cc _GLOBAL__sub_I_OptionHandlerException.cc + 20
	22  dyld                                0x00000001899855c8 ___ZZNK5dyld46Loader25findAndRunAllInitializersERNS_12RuntimeStateEENK3$_0clEv_block_invoke + 168
	23  dyld                                0x00000001899ca920 ___ZNK5dyld313MachOAnalyzer18forEachInitializerER11DiagnosticsRKNS0_15VMAddrConverterEU13block_pointerFvjEPKv_block_invoke.209 + 340
	24  dyld                                0x00000001899bdc60 ___ZNK5dyld39MachOFile14forEachSectionEU13block_pointerFvRKNS0_11SectionInfoEbRbE_block_invoke + 496
	25  dyld                                0x00000001899652fc _ZNK5dyld39MachOFile18forEachLoadCommandER11DiagnosticsU13block_pointerFvPK12load_commandRbE + 300
	26  dyld                                0x00000001899bcc98 _ZNK5dyld39MachOFile14forEachSectionEU13block_pointerFvRKNS0_11SectionInfoEbRbE + 192
	27  dyld                                0x00000001899ca434 _ZNK5dyld313MachOAnalyzer18forEachInitializerER11DiagnosticsRKNS0_15VMAddrConverterEU13block_pointerFvjEPKv + 516
	28  dyld                                0x0000000189981798 _ZNK5dyld46Loader25findAndRunAllInitializersERNS_12RuntimeStateE + 448
	29  dyld                                0x0000000189987b14 _ZNK5dyld416JustInTimeLoader15runInitializersERNS_12RuntimeStateE + 36
	30  dyld                                0x0000000189981b4c _ZNK5dyld46Loader23runInitializersBottomUpERNS_12RuntimeStateERN5dyld35ArrayIPKS0_EE + 220
	31  dyld                                0x0000000189985654 _ZZNK5dyld46Loader38runInitializersBottomUpPlusUpwardLinksERNS_12RuntimeStateEENK3$_1clEv + 112
	32  dyld                                0x0000000189981ccc _ZNK5dyld46Loader38runInitializersBottomUpPlusUpwardLinksERNS_12RuntimeStateE + 304
	33  dyld                                0x00000001899a6ad4 _ZN5dyld44APIs25runAllInitializersForMainEv + 464
	34  dyld                                0x0000000189969f34 _ZN5dyld4L7prepareERNS_4APIsEPKN5dyld313MachOAnalyzerE + 3192
	35  dyld                                0x0000000189968f44 start + 1948
)
libc++abi: terminating due to uncaught exception of type NSException
[1]    96653 abort      aria2c

What I tried:

  • brew reinstall aria2c
  • install the previous version 1.35.0
  • source installation from the master branch

Installing like this:

autoreconf --force --verbose --install
./configure --disable-dependency-tracking --prefix=<my_prefix> --with-libssh2 --without-gnutls --without-libgmp --without-libnettle --without-libgcrypt --with-appletls --without-openssl
make install
~ > sw_vers
ProductName:		macOS
ProductVersion:		14.0
BuildVersion:		23A5312d
@Ryu-ga
Copy link

Ryu-ga commented Aug 22, 2023

LC_MESSAGES="C" ./aria2c or add export LC_MESSAGES="C" in your shell init script.
it works.

@alphavector
Copy link
Author

Setting any LC_MESSAGES value works

@alphavector
Copy link
Author

@Ryu-ga, and how did you know that was the problem? :D

@Ryu-ga
Copy link

Ryu-ga commented Aug 23, 2023

_nl_locale_name_default + 72
libintl_dcigettext + 1852

The error was occurred in here. So I just added LC_ALL or LC_MESSAGES to env to bypass default locale name function.
After I found it, I saw this issue, fish-shell/fish-shell#277

@Ryu-ga
Copy link

Ryu-ga commented Aug 23, 2023

And yesterday I found more interesting one.
aria2c -> crash
DYLD_INSERT_LIBRARIES=/opt/local/lib/libintl.8.dylib aria2c -> works well
LC_ALL or LC_MESSAGES=[something] aria2c -> works well
I can't understand what fish-shell does in env settings.

@alphavector
Copy link
Author

And what does fish-shell do in the env settings?
I just installed fish and without explicitly setting set -x LC_ALL en_US.UTF-8 the problem is reproduced
Exactly the same as in zsh

@Ryu-ga
Copy link

Ryu-ga commented Aug 23, 2023

Actually aria2c works well without such settings if I build it from build-system files built with more recent gettext.

  1. Download sources from master branch. (* files from brew or macports are built with old gettext files.)
  2. autoreconf -i, (* I need to do it twice because aria2's build files are weird)
  3. mkdir build && cd build && ../configure
    Then the binary works well without env settings.
    I guess the error is related to old gettext files.

@alphavector
Copy link
Author

alphavector commented Aug 23, 2023

Probably a silly question, but how did you build the gettext from master? I tried to install version 0.22, but it didn't install

ld: Undefined symbols:
  _iconv_ostream_create, referenced from:
      <initial-undefines>
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Trying to create .configure from master branch

> autoreconf -ivf
autoreconf: export WARNINGS=
autoreconf: Entering directory '.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
sh: build-aux/git-version-gen: No such file or directory
configure.ac:25: error: AC_INIT should be called with package and version arguments
/opt/homebrew/Cellar/automake/1.16.5/share/aclocal-1.16/init.m4:29: AM_INIT_AUTOMAKE is expanded from...
configure.ac:25: the top level
autom4te: error: /opt/homebrew/opt/m4/bin/m4 failed with exit status: 1
aclocal: error: /opt/homebrew/Cellar/autoconf/2.71/bin/autom4te failed with exit status: 1
autoreconf: error: aclocal failed with exit status: 1

@alphavector
Copy link
Author

Seems to be a related problem
Homebrew/homebrew-core#134039

@Ryu-ga
Copy link

Ryu-ga commented Aug 23, 2023

git clone https://github.com/aria2/aria2
cd aria2
autoreconf -i
autoreconf -i
mkdir build && cd build
../configure && make -j8

I'm using gettext-runtime v0.20.

@alphavector
Copy link
Author

I understand how to build aria2c, I don't understand how to build gettext 0.22

I already have gettext 0.21.1.
Apparently there is an even older version of gettext that is part of macos and that is what is used when building aria2c, not my gettext 0.21.1

@alphavector
Copy link
Author

files from brew or macports are built with old gettext files.

I thought my version of gettext 0.21.1 was old
But judging by your posts everything works on 0.20 as well

@Ryu-ga
Copy link

Ryu-ga commented Aug 23, 2023

I made misleading words "if I build it from build-system files built with more recent gettext.".
I meant it as 'use more recent files under aria2/m4 and aria2/po using autoreconf, not in master branch'.
On my opinion, the version of gettext does not matter.

@Ryu-ga
Copy link

Ryu-ga commented Aug 23, 2023

I test it with custom gettext-runtime v0.21.1.
CoreFoundation 0x000000018ae4fe64 CFLocaleCopyPreferredLanguages + 28
libintl.8.dylib 0x0000000101727250 _nl_language_preferences_default + 60
libintl.8.dylib 0x00000001017247dc guess_category_value + 260
libintl.8.dylib 0x0000000101723bb4 libintl_dcigettext + 1356
libintl.8.dylib 0x000000010171e72c libintl_dcgettext + 52
libintl.8.dylib 0x000000010171e788 libintl_gettext + 32
gettext-runtime with aria2c crash always CoreFoundation functions.
CFPreferencesCopyAppValue was behaving strangely and its behavior was difficult to understand.

@Ryu-ga
Copy link

Ryu-ga commented Aug 23, 2023

diff --git a/src/OptionHandlerException.cc b/src/OptionHandlerException.cc
index 738181fe..646ee635 100644
--- a/src/OptionHandlerException.cc
+++ b/src/OptionHandlerException.cc
@@ -38,8 +38,8 @@
 namespace aria2 {
 
 namespace {
-const char* MESSAGE =
-    _("We encountered a problem while processing the option '--%s'.");
+const char* _message = "We encountered a problem while processing the option '--%s'.";
+const char* MESSAGE = NULL;
 } // namespace
 
 OptionHandlerException::OptionHandlerException(const char* file, int line,
@@ -48,6 +48,7 @@ OptionHandlerException::OptionHandlerException(const char* file, int line,
                            error_code::OPTION_ERROR),
       pref_(pref)
 {
+  MESSAGE = _(_message);
 }
 
 OptionHandlerException::OptionHandlerException(const char* file, int line,
@@ -57,6 +58,7 @@ OptionHandlerException::OptionHandlerException(const char* file, int line,
                            error_code::OPTION_ERROR, cause),
       pref_(pref)
 {
+  MESSAGE = _(_message);
 }
 
 OptionHandlerException::~OptionHandlerException() throw() = default;
diff --git a/src/UnknownOptionException.cc b/src/UnknownOptionException.cc
index 1cf4f208..1c0edeb4 100644
--- a/src/UnknownOptionException.cc
+++ b/src/UnknownOptionException.cc
@@ -38,7 +38,8 @@
 namespace aria2 {
 
 namespace {
-const char* MESSAGE = _("Unknown option '%s'");
+const char* _message = "Unknown option '%s'";
+const char* MESSAGE = NULL;
 } // namespace
 
 UnknownOptionException::UnknownOptionException(const char* file, int line,
@@ -47,6 +48,7 @@ UnknownOptionException::UnknownOptionException(const char* file, int line,
                            error_code::OPTION_ERROR),
       unknownOption_(unknownOption)
 {
+  MESSAGE = _(_message);
 }
 
 UnknownOptionException::UnknownOptionException(const char* file, int line,
@@ -56,6 +58,7 @@ UnknownOptionException::UnknownOptionException(const char* file, int line,
                            error_code::OPTION_ERROR, cause),
       unknownOption_(unknownOption)
 {
+  MESSAGE = _(_message);
 }
 
 UnknownOptionException::~UnknownOptionException() throw() = default;

This patch let aria2 work well.
In Sonoma, many CF Functions in cxx_global_init phase crash with some unset env variables.
I guess it is bug of CF in Sonoma.

@alphavector
Copy link
Author

alphavector commented Aug 23, 2023

Adding the --disable-nls flag also solves the problem 😂

@412999826
Copy link

LC_MESSAGES="C" ./aria2c or add export LC_MESSAGES="C" in your shell init script. it works.

Great, it works, thank you.

And I update the plist file so it can run at boot. 😄

homebrew.mxcl.aria2.plist

@Ryu-ga
Copy link

Ryu-ga commented Aug 27, 2023

TL;DR. add Link libraries CoreServices

I figure out what is problem.
In Sonoma, some CoreFoundation functions require CoreServices, but dyld of Sonoma cannot load CoreServices when it should do, like cxx_global_init in gettext, MacOS_init in libcurl.
So, some programs like aria2(gettext), cargo(libcurl) didn't work.
This error can be solved by simply linking CoreServices to binaries

@crazyi
Copy link

crazyi commented Sep 27, 2023

TL;DR. add Link libraries CoreServices

I figure out what is problem. In Sonoma, some CoreFoundation functions require CoreServices, but dyld of Sonoma cannot load CoreServices when it should do, like cxx_global_init in gettext, MacOS_init in libcurl. So, some programs like aria2(gettext), cargo(libcurl) didn't work. This error can be solved by simply linking CoreServices to binaries

Hi, can you tell me how to link CoreServices to binaries??

@Ryu-ga
Copy link

Ryu-ga commented Sep 27, 2023

@crazyi To solve these issues globally, add -framework CoreServices to LDFLAGS when building gettext.
Alternatively, you can do the same thing while building aria2, which will only resolve the issue with aria2.

Xerxes-2 added a commit to Xerxes-2/homebrew-core that referenced this issue Oct 1, 2023
Fix for aria2/aria2#2083 (comment)
and for Homebrew#142161 (comment)
CoreServices is not linked to gettext on Sonoma, causing aria2c to fail.
So we have to explicitly link CoreServices to gettext.
Seems to be a bug of Sonoma, maybe fixed in the future by Apple.
github-actions bot pushed a commit to smalltalkman/gnulib that referenced this issue Oct 2, 2023
Reported by Shupeng Xue <dspxue@gmail.com> at
<https://lists.gnu.org/archive/html/bug-gettext/2023-10/msg00001.html>.

Cf <aria2/aria2#2083 (comment)>.

* m4/intlmacosx.m4 (gt_INTL_MACOSX): Link with the CoreServices
framework in addition to the CoreFoundation framework.
jollaitbot pushed a commit to sailfishos-mirror/gnulib that referenced this issue Oct 3, 2023
Reported by Shupeng Xue <dspxue@gmail.com> at
<https://lists.gnu.org/archive/html/bug-gettext/2023-10/msg00001.html>.

Cf <aria2/aria2#2083 (comment)>.

* m4/intlmacosx.m4 (gt_INTL_MACOSX): Link with the CoreServices
framework in addition to the CoreFoundation framework.
jollaitbot pushed a commit to sailfishos-mirror/gnulib that referenced this issue Oct 3, 2023
Reported by Shupeng Xue <dspxue@gmail.com> at
<https://lists.gnu.org/archive/html/bug-gettext/2023-10/msg00001.html>.

Cf <aria2/aria2#2083 (comment)>.

* m4/intlmacosx.m4 (gt_INTL_MACOSX): Link with the CoreServices
framework in addition to the CoreFoundation framework.
TimothyGu pushed a commit to autotools-mirror/gettext that referenced this issue Oct 4, 2023
Reported by Shupeng Xue <dspxue@gmail.com> at
<https://lists.gnu.org/archive/html/bug-gettext/2023-10/msg00001.html>.
Cf <aria2/aria2#2083 (comment)>.

* gettext-runtime/m4/intlmacosx.m4 (gt_INTL_MACOSX): Link with the CoreServices
framework in addition to the CoreFoundation framework.
@bhaible
Copy link

bhaible commented Oct 5, 2023

A new release, gettext 0.22.3, is out, that should fix this problem.

@muuvmuuv
Copy link

muuvmuuv commented Oct 5, 2023

If one needs that gettext immediately just fetch in homebrew-core (/opt/homebrew/Library/Taps/homebrew/homebrew-core) and do an brew upgrade. Had to do that in order to install ruby through rbenv.

@alphavector
Copy link
Author

~ > gettext --version              
gettext (GNU gettext-runtime) 0.22.3
Copyright (C) 1995-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Ulrich Drepper.
~ > aria2c
Specify at least one URL.
Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE | METALINK_FILE]...
See 'aria2c -h'.

problem solved, I think we can close the thread

mitchcapper pushed a commit to mitchcapper/_git_merge_issue that referenced this issue Mar 17, 2024
Reported by Shupeng Xue <dspxue@gmail.com> at
<https://lists.gnu.org/archive/html/bug-gettext/2023-10/msg00001.html>.

Cf <aria2/aria2#2083 (comment)>.

* m4/intlmacosx.m4 (gt_INTL_MACOSX): Link with the CoreServices
framework in addition to the CoreFoundation framework.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants