Open bartlibert opened 5 years ago
Hi @bartlibert,
I don't use the sensor so I can only guess:
own
code. Own means it must be a file which is below root and indexed.In your sample it seams that files are from a library or in test code?
Regards,
Hi @guwirth, I already had a look at the code and I assumed that the "getLastOwnFrame" call would try to find a file within the source folder(s), hence it should find test_pdfForm.cpp and try to assign to that. Am I interpreting this wrong and is "getLastOwnFrame" badly named?
Hi @bartlibert,
is test_pdfForm.cpp
in/below source
or test
?
test_pdfForm.cpp
is indexed.Regards,
It is inside the unit folder (so the tests), which is also in the "sonar.sources" config variable, so I don't know if it should be handled differently? The file is indexed, although it has some syntax errors, related to the catch2 testing framework.
tl;dr: Valgrind output MUST contain absolute paths for \<dir> entries and they MUST start with whatever you put as projectBaseDir.
@guwirth Been debugging this for a few days... had basically the same issue as @bartlibert and I think I finally found the issue.
Inside getLastOwnFrame we loop over every frame in the valgrind stack trying to find one that's "owned" by our project (Bart was right about that part):https://github.com/SonarOpenCommunity/sonar-cxx/blob/4f9280bd1d0a114606914733dd71e0c1b5a6d87d/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindStack.java#L91-L98
You might get this far and think the issue of "ownership" has to do with whether or not the file is indexed or being excluded for some reason but you'd be wrong in chasing that lead. Instead it's this nasty snippet:
path.startsWith(folder)
is checking against baseDir, which in my case was the source of the issue because the valgrind report that I generated was actually generated from a binary that was created in another directory and this sensor (woefully) has no support for relative paths in valgrind output.
Hi @shua27,
thanks for your feedback.
First of all I like to ask you to read:
Does this make sense for Valgrind?
path.startsWith(folder) is checking against baseDir, which in my case was the source of the issue because the valgrind report that I generated was actually generated from a binary that was created in another directory and this sensor (woefully) has no support for relative paths in valgrind output.
If you create the reports on another computer, you need to adjust the paths in the report files to match the paths on the computer running the scanner.
Or is the problem the “has no support for relative paths in valgrind output“?
Do you have a sample report file / snippet showing the issue? Or even better: a patch for the issue?
I’m not familiar with Valgrind and don’t have the possibility to make own tests… but we are for sure interested to improve the sensor.
Regards,
To be fixed: … sensor (woefully) has no support for relative paths in valgrind output.
I also have same issue and fixed by recompiling program with option -g. Here is example: gcc -g -o use_after_free use_after_free.c. Include the -g flag for debugging symbols, which helps tools like Valgrind provide more useful output.
Description
I have a moderately complex meson setup that is reused by several projects and I find the valgrind (memcheck) results are not fed into sonarqube, giving the error "Cannot find a project file to assign the valgrind error".
I cannot share everything because some proprietary code is involved, but I'll try to sketch the situation as well as possible.
Repository layout
Sonar properties file
Valgrind
Sample valgrind error frame output
Sonar log snippet