bcoconni / ValgrindCI

A Python package that provides tools to integrate valgrind into your CI workflow
GNU General Public License v3.0
19 stars 8 forks source link

Fails if valgrind uses [xwhat] tag instead of [what] in xml file. #1

Closed iotanbo closed 3 years ago

iotanbo commented 4 years ago

Thanks for a useful tool, I've already put a star! But there is a problem:

When using valgrind-3.15.0 on Ubuntu 20.04, it looks like xwhat tag is used instead of (or in conjuncion with) what that makes ValgrindCI fail with exception.

Xml output excerpt:

<error>
  <unique>0x0</unique>
  <tid>1</tid>
  <kind>Leak_DefinitelyLost</kind>
  <xwhat>
    <text>248 bytes in 1 blocks are definitely lost in loss record 1 of 1</text>
    <leakedbytes>248</leakedbytes>
    <leakedblocks>1</leakedblocks>
  </xwhat>
  <stack>
    <frame>
      <ip>0x483BE63</ip>
      <obj>/usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so</obj>
      <fn>operator new(unsigned long)</fn>
    </frame>
    <frame>
      <ip>0x10E303</ip>
      <obj>/MyProject/build/p01</obj>
      <fn>main</fn>
      <dir>/MyProject</dir>
      <file>my_file.cpp</file>
      <line>436</line>
    </frame>
  </stack>
</error>

valgrind-ci message:

Traceback (most recent call last):
  File "/home/username/.local/bin/valgrind-ci", line 23, in <module>
    main()
  File "/home/username/.local/lib/python3.8/site-packages/ValgrindCI/__init__.py", line 54, in main
    data.parse(args.xml_file)
  File "/home/username/.local/lib/python3.8/site-packages/ValgrindCI/parse.py", line 94, in parse
    self.errors.append(Error(error_tag))
  File "/home/username/.local/lib/python3.8/site-packages/ValgrindCI/parse.py", line 26, in __init__
    self.what = tag.find("what").text
AttributeError: 'NoneType' object has no attribute 'text'
bcoconni commented 4 years ago

I just pushed the PR #2, thanks for the report and the bug fix.

iotanbo commented 4 years ago

OK, then the issue can be closed. It'd also be nice to update the PyPi repo. I don't know why valgrind developers changed this tag, maybe it's just a bug and they will revert it. Anyway, better to be prepared for any situation. Thanks.

bcoconni commented 4 years ago

After some further investigations, I've just realized that the <xwhat> tag is somewhat different than <what>: the new tag uses sub elements such as <text> and <leakedbytes> as your example shows:

<error>
  <unique>0x0</unique>
  <tid>1</tid>
  <kind>Leak_DefinitelyLost</kind>
  <xwhat>
    <text>248 bytes in 1 blocks are definitely lost in loss record 1 of 1</text>
    <leakedbytes>248</leakedbytes>
    <leakedblocks>1</leakedblocks>
  </xwhat>

As a consequence, your patch fixes the crash but the error message 248 bytes in 1 blocks are definitely lost in loss record 1 of 1 is not read by ValgrindCI.

bcoconni commented 3 years ago

So it appears the tag <xwhat> is used for leak errors while the tag <what> is used for other errors. The consequence is that the 2 tags can coexist and that we need to manage both of them.

bcoconni commented 3 years ago

As a consequence, your patch fixes the crash but the error message 248 bytes in 1 blocks are definitely lost in loss record 1 of 1 is not read by ValgrindCI.

This has been fixed by commit 6007b185c75.

bcoconni commented 3 years ago

It'd also be nice to update the PyPi repo.

This is now done :smile: