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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Forwarding of Empty Arguments to Profiled Application #354

Closed
chriswasser opened this issue Dec 18, 2020 · 4 comments 路 Fixed by #355
Closed

[BUG] Forwarding of Empty Arguments to Profiled Application #354

chriswasser opened this issue Dec 18, 2020 · 4 comments 路 Fixed by #355
Labels

Comments

@chriswasser
Copy link
Contributor

chriswasser commented Dec 18, 2020

Hi Thomas,

Sorry to open a bug report this close to the weekend and especially around Christmas 馃巹 There might be a minor bug which has floated around for quite some time.

Describe the bug
LIKWID's CLI parsing does not correctly forward all empty arguments to the profiled application. An empty argument is only passed on correctly if it is the very last argument in the argument list. I only tested this behaviour for likwid-perfctr although this bug might be present in other LIKWID tools as well due to the shared code base.

To Reproduce
The following shell commands act as a reproducer and use taskset's argument forwarding as a reference:

: > test.sh
chmod +x test.sh
cat >> test.sh <<EOF
echo "Number of Arguments: \${#}"
for argument in "\${@}"; do
    echo "--> '\${argument}'"
done
EOF

echo 'Running taskset...'
taskset -c 0 test.sh -a '' -b '' -c ''
taskset -c 0 test.sh -a '' -b '' -c 'argument'

echo 'Running likwid-perfctr...'
likwid-perfctr -C 0 -g MEM -o output.txt -- test.sh -a '' -b '' -c ''
likwid-perfctr -C 0 -g MEM -o output.txt -- test.sh -a '' -b '' -c 'argument'

rm -f test.sh output.txt

We can see that LIKWID deviates from taskset's behaviour in the resulting output:

Running taskset...
Number of Arguments: 6
--> '-a'
--> ''
--> '-b'
--> ''
--> '-c'
--> ''
Number of Arguments: 6
--> '-a'
--> ''
--> '-b'
--> ''
--> '-c'
--> 'argument'
Running likwid-perfctr...
Number of Arguments: 4
--> '-a'
--> '-b'
--> '-c'
--> ''
Number of Arguments: 4
--> '-a'
--> '-b'
--> '-c'
--> 'argument'

This was tested with the following LIKWID version:

$ likwid-perfctr -v
likwid-perfctr -- Version 5.0.2 (commit: 233ab943543480cd46058b34616c174198ba0459)

OS version (probably not relevant):

$ lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.8.2003 (Core)
Release:        7.8.2003
Codename:       Core

The bug is not specific to an application.
The bug is not specific to a hardware architecture.
The bug is not associated with GPUs
The bug is not associated with the MarkerAPI.

To Reproduce with a LIKWID command
If you need the complete output of likwid-perfctr with -V 3, I can supply the full output. But since the bug is not associated to the perfmon infrastructure, I have only pasted the relevant parts below:

Running taskset...
Number of Arguments: 6
--> '-a'
--> ''
--> '-b'
--> ''
--> '-c'
--> ''
Number of Arguments: 6
--> '-a'
--> ''
--> '-b'
--> ''
--> '-c'
--> 'argument'
# start LIKWID debug output
Running likwid-perfctr...
# more LIKWID debug output
Executing: test.sh -a  -b  -c 
# more LIKWID debug output
Number of Arguments: 4
--> '-a'
--> '-b'
--> '-c'
--> ''
# more LIKWID debug output
# start LIKWID debug output
Executing: test.sh -a  -b  -c argument
# more LIKWID debug output
Number of Arguments: 4
--> '-a'
--> '-b'
--> '-c'
--> 'argument'
# more LIKWID debug output

Additional context
I suspect that the bug occurs due to the interaction of these three parts of the code:

However, you probably know best where to look 馃憤 Hope the descriptions helps in bug hunting nevertheless 馃悰

Greetings,

Christian

Edit: Also verified that the same bug occurs for the latest 5.1.0 LIKWID release

@TomTheBear
Copy link
Member

Hi Christian,

Thanks for finding this and supplying detailed information. I'll look into it.

Best,
Thomas

@TomTheBear
Copy link
Member

I looked into it and you were on the right track. It's a combination of joining the string and parsing of the argument list.

@chriswasser
Copy link
Contributor Author

Can confirm that the fix pushed to the empty_cli_args branch fixes this issue 馃憣
Other tests with nested quotes as arguments ("''" or '""') also work fine 馃憤
Thanks Thomas 馃帀

@TomTheBear
Copy link
Member

Thanks for testing and confirming the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants