CLI_MAX_ARG_SIZE
has many edge case issues:
- It seems to be lower on some systems, but it is unknown how to reproduce locally: #33079 (comment)
MAX_ARG_STRLEN
is a limit per arg, but we probably want “The maximum length of [all of] the arguments”: See https://www.man7.org/linux/man-pages/man3/sysconf.3.html, sectionARG_MAX - _SC_ARG_MAX
.- It doesn’t account for the additional args added by the
bitcoin
command later on: https://github.com/bitcoin/bitcoin/blob/73220fc0f958f9b65f66cf0cf042af220b312fc6/src/bitcoin.cpp#L85-L92 - It doesn’t account for unicode encoding a string to bytes before taking its length.
The issues are mostly harmless edge cases, but it would be good to fix them. So do that here, by:
- Replacing
max()
bysum()
, to correctly take into account all args, not just the largest one. - Reduce
CLI_MAX_ARG_SIZE
, to account for thebitcoin
command additional args.
Also, there is a test. The test can be called with ulimit
to hopefully limit the max args size to the hard-coded value in the test framework. For reference:
0$ ( ulimit -s 512 && python3 -c 'import os; print(os.sysconf("SC_ARG_MAX") )' )
1131072
On top of this pull it should pass, …
0bash -c 'ulimit -s 512 && BITCOIN_CMD="bitcoin -M" ./bld-cmake/test/functional/rpc_misc.py --usecli -l DEBUG'
… and with the test_framework changes reverted, it should fail:
0OSError: [Errno 7] Argument list too long: 'bitcoin'
Also, there is a commit to enable CI_LIMIT_STACK_SIZE=1
in the i686 task, because it should now be possible and no longer hit the hard-to-reproduce issue mentioned above.