-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
kcov bash-4.3 generates PS4 output with script that calls a script #67
Comments
My guess is that this is a combination of the BASH_XTRACEFD fix and the --bash-parser= option: The test2.sh script gets executed with /bin/bash because it's called from the Python script (and I guess the same thing could happen from pure bash itself). In your case, this will be bash 4.1, so the PS4 stuff will end up on the console. Probably it's possible to workaround this problem by running with
i.e., falling back to PS4 on stderr, which should work in both bash 4.3 and bash 4.1. I thought of the force-stderr stuff as a pure debugging option (I use it in the automatic tests for kcov itself), but because of this issue, I guess it would be better to make it a proper option. I'll commit that later, but --bash-force-ps4-to-stderr could perhaps be a better name. I don't think there's any easy way around the problem you see, except perhaps selecting PS4-stderr automatically if --bash-parser= is selected. However, I think that would be confusing in other ways. |
Could it have something to do with PS4 being an environment variable
If I just run it PS4 is a shell variable, and BASH_XTRACEFD is not set:
If I run it with kcov it looks like both are environment variables:
(I'm not sure where my Hi went in the second case.) So, the PS4 and BASH_XTRACEFD are set in the sub-shell (test2.sh) but Interestingly, I get this when I pass --bash-parser
|
I didn't even know there was a difference :-) Anyway, if the --debug-bash-force-stderr workaround didn't work, I've implemented a fix for Issue #51, which might correct this problem as well (as it should always use the bash you supply with --bash-parser, even for scripts executed directly). If you have time, it would be nice if you could test the git head to see if it works. The Issue #51 fix is also a bit intrusive, so I'd be interested to know how it works out in larger environments. |
On 03/01/15 05:41, Simon Kagstrom wrote:
Something has caused kcov to run significantly more slowly. I have a Mark E. Hamilton |
OK, I didn't think about that myself (but I also run with very small bash scripts). Kcov collection has a cost, so the 3->9 second change is probably not abnormal. 80-140 sounds like it would be an issue though. Did you test with 8a97825 as well? I suspect there won't be any difference, but 5f56dc0 had some issues that have been resolved in the later commit. Anyway, the solution to Issue #51 works by replacing the execve libc call and for each executed file reads a bit at the start of the file to see if it's executed with a #!/bin/sh hash bang. If it is, it will replace the command line with "bash -x /path/to/script". If there are frequent program executions (as is often the case in bash scripts), I can imagine that this can give quite some overhead. I suppose that feature should be made optional. |
I saw the issue on 8a97825 first. I reset back to afe5793 to ensure it Mark E. Hamilton |
Thanks for testing this. I'll make this feature optional. The question is just if it should be default-on or default-off. How does your 80 second scripts look? I.e., are they thousands of lines long or short-but-with-loops? |
This feature is now optional (it also breaks in strange ways on some systems, so it's unsafe as well), and default's to off. Hopefully performance should be better again. |
On 03/03/15 01:17, Simon Kagstrom wrote:
Sorry, I've been off on other things for a few days, and will continue Mark E. Hamilton |
On 03/04/15 12:07, Simon Kagstrom wrote:
Yep, it is. Thanks. I've encountered and issue with FUNCNAME which is not a kcov issue, but Mark E. Hamilton |
No problem! Feel free to open issues as you please, it's easy to close them if it turns out to be an unrelated problem. |
Hi,
I've tracked down another oddness when using bash-4.3. I've got another set of test scripts:
When I run this with kcov and bash-4.1.2 I get only 'Hi' printed.
However, when I run it with bash-4.3 as the parser I get PS4 lines output.
If I add more statements to test2, I get more lines echoed. I also noticed that the output seems to be lost in the case where it goes through the python script. Although that might be an issue with the test, it seems to me they should both do the same thing.
The text was updated successfully, but these errors were encountered: