https://bugs.kde.org/show_bug.cgi?id=328563

Hideaki Kimura <hideaki.kim...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hideaki.kim...@gmail.com

--- Comment #1 from Hideaki Kimura <hideaki.kim...@gmail.com> ---
I'm also hitting this, but in a bit different form from the original comment
probably due to version difference (mine is 3.11.0).

When I enable track-fds and xml output, valgrind _does_ output open-at-exit
file descriptors information in XML. However, the output is far from ideal.

For example,

// test.c
#include <fcntl.h>
int main(void) {
  open("bluh", O_CREAT, 0);
  return 0;
}

Then
gcc test.c; rm -f bluh; valgrind --xml=yes --xml-file=out.xml --track-fds=yes
--leak-check=full --error-exitcode=1 ./a.out

a.out emits no error code:
> echo $?
0

The out.xml would look like:

<?xml version="1.0"?>
<valgrindoutput>
<protocolversion>4</protocolversion>
<protocoltool>memcheck</protocoltool>
<preamble>...snip...</preamble>
<pid>20082</pid>
<ppid>25595</ppid>
<tool>memcheck</tool>
<args>
  <vargv>
    <exe>/usr/bin/valgrind</exe>
    <arg>--xml=yes</arg>
    <arg>--xml-file=out.xml</arg>
    <arg>--track-fds=yes</arg>
    <arg>--leak-check=full</arg>
    <arg>--error-exitcode=1</arg>
  </vargv>
  <argv>
    <exe>./a.out</exe>
  </argv>
</args>
<status>
  <state>RUNNING</state>
  <time>00:00:00:00.056 </time>
</status>
<status>
  <state>FINISHED</state>
  <time>00:00:00:00.242 </time>
</status>
  <stack>
    <frame>
      <ip>0x4F27490</ip>
      <obj>/usr/lib64/libc-2.22.so</obj>
      <fn>__open_nocancel</fn>
    </frame>
    <frame>
      <ip>0x400552</ip>
      <obj>/home/kimurhid/a.out</obj>
      <fn>main</fn>
    </frame>
  </stack>
<errorcounts></errorcounts>
<suppcounts></suppcounts>
</valgrindoutput>


This is it. The <stack> element shows where the open-at-exit FD was made, which
is useful but the way the xml shows it is very user-unfriendly. It doesn't even
say what this <stack> element is about!

In my case, this is also causing an issue to integrate with other tools like
Continuous Integration (Jenkins) and CTest because the output/exit-code looks
normal even when there are leaked FDs. Jenkins/CTest just report that there
were no errors.. even when I have leaked FDs!

In sum, I suggest the following:

1. In XML, make the leaked-FD output as beefy as usual memory-leak errors,
ideally follow the same format.

2. Add an option to emit error exit-code on observing leaked-FDs, again just
like usual memory-leak errors.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to