Bug 381641 - Valgrind produces corrupted XML output when program uses popen
Summary: Valgrind produces corrupted XML output when program uses popen
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR major
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-25 11:51 UTC by ebeschastnov
Modified: 2017-07-02 21:05 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
XML output (1.61 KB, application/xml)
2017-06-25 11:51 UTC, ebeschastnov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ebeschastnov 2017-06-25 11:51:31 UTC
Created attachment 106289 [details]
XML output

Dear Developers,

I've come across a bug with XML output when a program under analysis uses popen. The same happens when I try running valgrind as follows: valgrind ... /bin/bash some_command_file. I've done a quick search on the bug reports with similar problem and found one but it was said there that this bug is already fixed. I've checked with the latest trunk version and it seems that this problem still exists. Attached is the output XML I obtained.

Best Regards,
Evgeniy Beschastnov
Comment 1 Philippe Waroquiers 2017-07-01 14:07:12 UTC
When trying with a small script, it works:
valgrind --xml=yes --xml-file=x.xml /bin/bash ./truc
where truc contains:
echo coucou

the resulting x.xml file seems properly formatted.

Please give the exact/precise way to reproduce your problem.
Preferably a small compilable reproducer and the exact
valgrind options are you using.

If your program uses popen, it might be that it is forking/execing
another program, and that you are using --trace-children=yes
In such a case, be sure to use an --xml-file argument so that unique
file names are generated for each process e.g. using %p

In the attached xml file, I see you are using --trace-children=yes
but no %p if the xml file argument.

So, very probably, this is the cause of your problem.
Comment 2 ebeschastnov 2017-07-02 21:05:12 UTC
Dear Philippe,

Thank you. Indeed, I was not using %p, completely overlooked that in the documentation. I'll give it a try (however, I'm pretty sure that the issue will go away).

Best Regards,
Evgeniy Beschastnov