-
Notifications
You must be signed in to change notification settings - Fork 186
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
CFE-4244: Fix RlistEqual comparison on lists of different lengths #5313
Conversation
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.
Very nice 🚀 I have only a few nitpicks.
Thank you for providing both an acceptance- and unit tests. I see that your acceptance test fails on Windows, and I'm not quite sure why. I will request a build from @cf-bottom in Jenkins, so that I can investigate this further. Feel free to address the suggested changes in the meanwhile.
01253fd
to
7f60706
Compare
I you think it would be acceptable I could skip this test on Windows and macOS. |
Hi @amousset, I just tested this manually on Windows, and you can fix it my using |
tests/acceptance/01_vars/04_containers/execresult_and_as_data.cf
Outdated
Show resolved
Hide resolved
Second part addressed in #5317 |
Could you please squash the commits as described in https://github.com/cfengine/core/blob/master/CONTRIBUTING.md#interactive-rebase? |
8471c90
to
25c6f40
Compare
tests/acceptance/01_vars/04_containers/execresult_and_as_data.cf
Outdated
Show resolved
Hide resolved
25c6f40
to
c1f76d9
Compare
tests/acceptance/01_vars/04_containers/execresult_and_as_data.cf
Outdated
Show resolved
Hide resolved
The original issue that leads to this is the fact that the cache for execresult and execresult_as_data were mixed. This is caused by two separate issues: * The function cache uses the args list as key and discards the function itself. This means different function with the same args are considered identical, and cache is reused. * The args are passed as an Rlist, and the used Rlist comparison ignores the additional items of the longest list when comparing two lists of different lengths, leading to treating execresult and execresult_as_data as identical when using the same command and shell args. This PR only fixes the specific case of execresult, but leaves other function cache issues (e.g. host2ip vs. ip2host could be confused).
c1f76d9
to
d5a7372
Compare
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.
Thanks for your contribution 🚀
Seems that the GitHub Action workflow for windows acceptance tests, tests with master nightly build, instead of testing it with the changes you did to core. Thus I merged this, and will see if it passes when we have a new master nightly build. |
The original issue that leads to this is the fact that the caches for execresult and execresult_as_data were mixed (CFE-4244). This is caused by two separate issues:
core/libpromises/eval_context.c
Line 2840 in 57745c7
This PR only fixes the specific case of execresult, but leaves other function cache issues. For example,
host2ip
vs.ip2host
could be confused:still returns:
I'll try to add the function name to the Rlist used as cache key in a subsequent PR.
Note: Even if the function name "Equal" suggests lists of different lengths should be different, it might break other stuff using Rlists, I haven't tried to investigate other use cases.