-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: Fix CLI_MAX_ARG_SIZE issues #33243
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
base: master
Are you sure you want to change the base?
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33243. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
@@ -30,6 +30,11 @@ def run_test(self): | |||
lambda: node.echo(arg9='trigger_internal_bug'), | |||
) | |||
|
|||
self.log.info("test max arg size") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test also passes on master (MacOS environment with ARG_MAX = 1048576). It does not fail with the test_framework changes reverted.
However, the following test only passes on this PR, not on my master:
self.log.info("test many small args (sum-size trigger)")
tiny = "a" * 120000
args = [tiny] * 10
assert_equal(args, node.echo(*args))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test also passes on master (MacOS environment with ARG_MAX = 1048576).
Thanks for adding a macos data point for reference. This further supports that the hard-coded value may be different on different platforms.
However, the following test only passes on this PR, not on my master:
Nice, thanks for adapting the test and checking the bugfix on macos.
ACK fabe214 This PR fixes how the functional test framework estimates command-line argument size. Previously it checked only the longest argument, but the OS limit is on the total argv/env size, so it now sums all args. It also adds a functional test using very large echo args, which exercises the I appreciate lowering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK fa18c82 — The fix is a welcome improvement: summing arg sizes better reflects kernel ARG_MAX behavior. Good use of >= to match inclusive boundary semantics. Left a few non-blocking clarifier nits inline.
fa25f97
to
fac47f6
Compare
fac47f6
to
fa96a4a
Compare
ACK fa96a4a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fa96a4a — thanks for addressing the nits and clarifying the test; LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- It claims to be a "limit per arg", but it is a "The maximum length of the arguments": See https://www.man7.org/linux/man-pages/man3/sysconf.3.html, section
ARG_MAX - _SC_ARG_MAX
.
the relevant bottleneck for me (tested on Ubuntu and Debian) was not ARG_MAX
, but MAX_ARG_STRLEN
, which accounts for the maximum per arg, not the sum.
e.g. the folllowing passes
arg1=$(printf "%0*d" $((131072 - 1)) 0)
arg2=$(printf "%0*d" $((131072 - 1)) 0)
$(which printf) "%s %s" "$arg1" "$arg2" >/dev/null
whereas
arg3=$(printf "%0*d" $((131072)) 0)
$(which printf) "%s" "$arg3" >/dev/null
fails with bash: /usr/bin/printf: Argument list too long
But seeing how much this apparently differs between systems, Concept ACK to using a smaller limit.
Thanks for clarifying that this was intentionally picked and that |
(+GHA ci) |
CLI_MAX_ARG_SIZE
has many edge case issues: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
.bitcoin
command later on:bitcoin/src/bitcoin.cpp
Lines 85 to 92 in 73220fc
The issues are mostly harmless edge cases, but it would be good to fix them. So do that here, by:
max()
bysum()
, to correctly take into account all args, not just the largest one.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:On top of this pull it should pass, ...
... and with the test_framework changes reverted, it should fail:
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.