SlideShare a Scribd company logo
HPX and PVS-Studio
Author: Hartmut Kaiser
Date: 04.07.2015
This article was originally published at STE||AR Group Blog. Republished by the editors' permission.
We have used a trial version of PVS-Studio for HPX previously, but I vaguely remembered it as being very
verbose in its diagnostics. I have read a lot about the tool lately, and since it was a long time since we
used it, we contacted the developers at Viva64 asking whether they would be willing to support our
open source project. We were positively surprised that they agreed to provide us with a free license for
one year in exchange for a blog post about our experience with the tool.
General Impressions
So I downloaded PVS-Studio V5.26 and installed it (without any problems) as an extension for my
VS2013 Professional (update 4) setup. I would have preferred to test it with VS2015RC1, as this is
currently my main development environment. Unfortunately, VS2015 is not supported yet, I however
expect that it will be supported as soon as Microsoft releases the new version.
The integration of the PVS-Studio into the Visual Studio user interface made a very good impression on
me. One additional top level menu item provides access to all of the commands and options. All of the
generated diagnostics are placed into a special output window from where you can jump to the source
code that a message refers to. You can also open a web-based, context sensitive help explaining each of
the generated diagnostics in more detail. In short, all is as it should be.
The diagnostics generated have three severity levels (high, medium, and low) and are grouped into
three categories (general analysis, optimization analysis, and 64-bit compatibility analysis). The user
interface allows restriction of the shown diagnostics to only some (or one) of those and additionally
allows for filtering to reduce the amount of messages to work through. For the main HPX module the
tool generated about 70 diagnostics in about 1,000 C++ header and source files (~140,000 lines of code),
which was not too bad (high severity: 5, medium: 44, low: 21). The initial analysis on my laptop took
about 10 minutes.
Example Diagnostics
I was eager to see what mistakes or problems the tool might reveal. The HPX team is very conscious
about code quality and we have the policy that code has to be reviewed by at least one other developer
before it can go into the main branch. So I was quite confident the tool wouldn't find anything.
Let's look at the high severity diagnostics first. Four of the diagnostics were very similar, and the context
for one of them is shown below:
template <typename Archive>
void load(Archive& ar)
{
actions::manage_object_action_base* act = 0;
ar >> hpx::serialization::detail::raw_ptr(act);
// V522: Dereferencing of the null pointer 'act' might take place.
HPX_ASSERT(act->is_valid());
// ...
}
This code is de-serializing a polymorphic object through its base pointer and we know that raw_ptr(act)
is allocating a new object instance for the de-serialized object returning a pointer to it through its
argument. We also know thatraw_ptr(act) would throw in case of any error. All of this should have been
visible to PVS-Studio as all the related code is located in header files. The tool apparently was not able to
see that, which is why it generated the diagnostic. Luckily you can tell PVS-Studio to ignore this
particular error with a single mouse click, which adds a magic comment to the corresponding source
code: //-V522, thus suppressing this message in the future - nifty. PVS-Studio gives you many more
options for suppressing diagnostics - file or directory based, file name pattern based, or specific to a
particular diagnostic globally - all of those easily accessible and self-explanatory.
A second diagnostic was really alarming to me. Here is the corresponding code:
#define HPX_VERSION_MAJOR 0
#define HPX_VERSION_MINOR 9
#define HPX_VERSION_SUBMINOR 11
std::string full_version_as_string()
{
// V609 Mod by zero. Denominator '0' == 0.
return boost::str(
boost::format("%d.%d.%d") %
HPX_VERSION_MAJOR % HPX_VERSION_MINOR %
HPX_VERSION_SUBMINOR);
}
It took me a moment to understand what PVS-Studio was trying to convey, since for me the overloaded
operator%()implemented by the Boost.Format library was totally inconspicuous. However, even after
realizing that the code would have been problematic if the operator was not actually overloaded, the
generated diagnostic itself still did not make too much sense to me. In the end, I 'resolved' this message
by suppressing it as well.
The last 'high severity' diagnostic was an optimization analysis result:
// V808 'hostname' object of 'basic_string' type was created
// but was not utilized.
std::string hostname = boost::asio::ip::host_name();
Sure enough, the tool was right, the variable 'hostname' was completely unused in this context. None of
the compilers we use for our regular testing on more than 20 different platforms had reported this
before - nice catch!
The generated diagnostics from lesser severity levels were mostly things worth looking at once, but
almost all of those flagged benign issues related to 32bit/64bit compatibility, like implicit conversions of
signed integers to larger unsigned representation widths (e.g. int32_t --> uint64_t).
Two diagnostics helped finding actual bugs, though. In one place we had this code:
int runtime_support::load_components(util::section& ini)
{
// load all components as described in the configuration information
if (!ini.has_section("hpx.components")) {
// V601 The 'true' value is implicitly cast to the integer type.
return true; // no components to load
}
// ...
}
The generated diagnostic pointed us to a problem: a while back we had changed the return type of the
function frombool to int (including a change to the semantics of the returned value), but we forgot to
adapt one of the return statements. This could have created problems which are difficult to reproduce.
Another of the useful diagnostics actually revealed a possibly more serious problem:
struct when_each_frame
{
// ...
private:
// V690 Copy constructor is declared as private in the
// 'when_each_frame' class, but the default '=' operator
// will still be generated by compiler. It is dangerous
// to use such a class.
when_each_frame();
when_each_frame(when_each_frame const&);
public:
// ...
};
This was a very nice catch indeed! Especially as we added the constructor declarations as a workaround
for older versions of gcc which were incorrectly instantiating default implementations for those
constructors.
In the end, I was happy to have invested my time into doing the work of running PVS-Studio on all of our
files. I was also happy to see that no absolutely serious issues were diagnosed, another confirmation of
the validity of our code review policy we put in place a while ago. As an action item, I noted to integrate
running PVS-Studio as part of our contiguous integration system, which triggers builds on every commit
to our development branch.
Conclusions
Static analysis definitely has its place. Running tools like PVS-Studio costs additional time and effort
which in my book is absolutely well invested. Compilers can not always afford to perform such deep
analysis that PVS-Studio attempts to do, as this would increase compile times even further.
Especially useful for us will be the ability to seamlessly integrate the tool into our contiguous integration
build system. This will also have another nice side effect: since we run our daily tests on many platforms
(including Windows), it will make the results of the static analysis produced by a Windows-only tool
available to our developers who mainly work on other platforms (like Linux or Mac/OS).
Another nice option of the IDE integration of PVS-Studio is the ability to automatically run the analysis
after each successful build. Surprisingly, this does not impose too much overhead onto the normal build
process. This is a very useful feature which gives feedback for subtle problems very early on during
development of new code. I will try to leave that option enabled for a while to see how effective that is.
When looking through all of the generated diagnostics, I was surprised to realize that - even while the
tool has all the time it needs to do an analysis as deeply as possible - PVS-Studio seems not to be able to
look through certain operator overloads to figure out that those actually implement semantics different
from the default. The example I showed above demonstrates this: the operator%() overload in
Boost.Format does everything but an integral modulo operation (it performs string formatting instead),
but PVS-Studio still warns about a possible division by zero. Sure, this is a real corner case and I'm not
sure if it is always possible to provide the right level of diagnostics. On the other hand, this is where the
real value of static analysis could be: deep semantic checking of our codes.
In any case, if you are interested in trying out HPX, please fork it from our github site.

More Related Content

What's hot

New Year PVS-Studio 6.00 Release: Scanning Roslyn
New Year PVS-Studio 6.00 Release: Scanning RoslynNew Year PVS-Studio 6.00 Release: Scanning Roslyn
New Year PVS-Studio 6.00 Release: Scanning Roslyn
PVS-Studio
 
PVS-Studio for Visual C++
PVS-Studio for Visual C++PVS-Studio for Visual C++
PVS-Studio for Visual C++
Andrey Karpov
 
PVS-Studio features overview (2020)
PVS-Studio features overview (2020)PVS-Studio features overview (2020)
PVS-Studio features overview (2020)
Andrey Karpov
 
Difficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usabilityDifficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usability
Andrey Karpov
 
Difficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usabilityDifficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usability
PVS-Studio
 
Difficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usabilityDifficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usability
PVS-Studio
 
Static analysis is most efficient when being used regularly. We'll tell you w...
Static analysis is most efficient when being used regularly. We'll tell you w...Static analysis is most efficient when being used regularly. We'll tell you w...
Static analysis is most efficient when being used regularly. We'll tell you w...
Andrey Karpov
 
Why Windows 8 drivers are buggy
Why Windows 8 drivers are buggyWhy Windows 8 drivers are buggy
Why Windows 8 drivers are buggy
PVS-Studio
 
War of the Machines: PVS-Studio vs. TensorFlow
War of the Machines: PVS-Studio vs. TensorFlowWar of the Machines: PVS-Studio vs. TensorFlow
War of the Machines: PVS-Studio vs. TensorFlow
PVS-Studio
 
Containerize your Blackbox tests
Containerize your Blackbox testsContainerize your Blackbox tests
Containerize your Blackbox tests
Kevin Beeman
 
How the PVS-Studio analyzer began to find even more errors in Unity projects
How the PVS-Studio analyzer began to find even more errors in Unity projectsHow the PVS-Studio analyzer began to find even more errors in Unity projects
How the PVS-Studio analyzer began to find even more errors in Unity projects
Andrey Karpov
 
Documenting Bugs in Doxygen
Documenting Bugs in DoxygenDocumenting Bugs in Doxygen
Documenting Bugs in Doxygen
PVS-Studio
 
Pragmatic Code Coverage
Pragmatic Code CoveragePragmatic Code Coverage
Pragmatic Code Coverage
Alexandre (Shura) Iline
 
Checking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-StudioChecking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-Studio
Andrey Karpov
 
Looking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelopLooking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelop
PVS-Studio
 
Checking the Qt 5 Framework
Checking the Qt 5 FrameworkChecking the Qt 5 Framework
Checking the Qt 5 Framework
Andrey Karpov
 
PVS-Studio static analyzer: advanced features
PVS-Studio static analyzer: advanced featuresPVS-Studio static analyzer: advanced features
PVS-Studio static analyzer: advanced features
Andrey Karpov
 
Bugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-StudioBugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-Studio
PVS-Studio
 
Espressif IoT Development Framework: 71 Shots in the Foot
Espressif IoT Development Framework: 71 Shots in the FootEspressif IoT Development Framework: 71 Shots in the Foot
Espressif IoT Development Framework: 71 Shots in the Foot
Andrey Karpov
 
Date Processing Attracts Bugs or 77 Defects in Qt 6
Date Processing Attracts Bugs or 77 Defects in Qt 6Date Processing Attracts Bugs or 77 Defects in Qt 6
Date Processing Attracts Bugs or 77 Defects in Qt 6
Andrey Karpov
 

What's hot (20)

New Year PVS-Studio 6.00 Release: Scanning Roslyn
New Year PVS-Studio 6.00 Release: Scanning RoslynNew Year PVS-Studio 6.00 Release: Scanning Roslyn
New Year PVS-Studio 6.00 Release: Scanning Roslyn
 
PVS-Studio for Visual C++
PVS-Studio for Visual C++PVS-Studio for Visual C++
PVS-Studio for Visual C++
 
PVS-Studio features overview (2020)
PVS-Studio features overview (2020)PVS-Studio features overview (2020)
PVS-Studio features overview (2020)
 
Difficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usabilityDifficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usability
 
Difficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usabilityDifficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usability
 
Difficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usabilityDifficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usability
 
Static analysis is most efficient when being used regularly. We'll tell you w...
Static analysis is most efficient when being used regularly. We'll tell you w...Static analysis is most efficient when being used regularly. We'll tell you w...
Static analysis is most efficient when being used regularly. We'll tell you w...
 
Why Windows 8 drivers are buggy
Why Windows 8 drivers are buggyWhy Windows 8 drivers are buggy
Why Windows 8 drivers are buggy
 
War of the Machines: PVS-Studio vs. TensorFlow
War of the Machines: PVS-Studio vs. TensorFlowWar of the Machines: PVS-Studio vs. TensorFlow
War of the Machines: PVS-Studio vs. TensorFlow
 
Containerize your Blackbox tests
Containerize your Blackbox testsContainerize your Blackbox tests
Containerize your Blackbox tests
 
How the PVS-Studio analyzer began to find even more errors in Unity projects
How the PVS-Studio analyzer began to find even more errors in Unity projectsHow the PVS-Studio analyzer began to find even more errors in Unity projects
How the PVS-Studio analyzer began to find even more errors in Unity projects
 
Documenting Bugs in Doxygen
Documenting Bugs in DoxygenDocumenting Bugs in Doxygen
Documenting Bugs in Doxygen
 
Pragmatic Code Coverage
Pragmatic Code CoveragePragmatic Code Coverage
Pragmatic Code Coverage
 
Checking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-StudioChecking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-Studio
 
Looking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelopLooking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelop
 
Checking the Qt 5 Framework
Checking the Qt 5 FrameworkChecking the Qt 5 Framework
Checking the Qt 5 Framework
 
PVS-Studio static analyzer: advanced features
PVS-Studio static analyzer: advanced featuresPVS-Studio static analyzer: advanced features
PVS-Studio static analyzer: advanced features
 
Bugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-StudioBugs found in GCC with the help of PVS-Studio
Bugs found in GCC with the help of PVS-Studio
 
Espressif IoT Development Framework: 71 Shots in the Foot
Espressif IoT Development Framework: 71 Shots in the FootEspressif IoT Development Framework: 71 Shots in the Foot
Espressif IoT Development Framework: 71 Shots in the Foot
 
Date Processing Attracts Bugs or 77 Defects in Qt 6
Date Processing Attracts Bugs or 77 Defects in Qt 6Date Processing Attracts Bugs or 77 Defects in Qt 6
Date Processing Attracts Bugs or 77 Defects in Qt 6
 

Similar to HPX and PVS-Studio

Static Analysis: From Getting Started to Integration
Static Analysis: From Getting Started to IntegrationStatic Analysis: From Getting Started to Integration
Static Analysis: From Getting Started to Integration
Andrey Karpov
 
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
Andrey Karpov
 
A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4
Andrey Karpov
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio
 
Comparing Functionalities of PVS-Studio and CppCat Static Code Analyzers
Comparing Functionalities of PVS-Studio and CppCat Static Code AnalyzersComparing Functionalities of PVS-Studio and CppCat Static Code Analyzers
Comparing Functionalities of PVS-Studio and CppCat Static Code Analyzers
Andrey Karpov
 
Static analysis is most efficient when being used regularly. We'll tell you w...
Static analysis is most efficient when being used regularly. We'll tell you w...Static analysis is most efficient when being used regularly. We'll tell you w...
Static analysis is most efficient when being used regularly. We'll tell you w...
PVS-Studio
 
Using PVS-Studio analyzer together with Microsoft Visual Studio 2010 incremen...
Using PVS-Studio analyzer together with Microsoft Visual Studio 2010 incremen...Using PVS-Studio analyzer together with Microsoft Visual Studio 2010 incremen...
Using PVS-Studio analyzer together with Microsoft Visual Studio 2010 incremen...
PVS-Studio
 
The Development History of PVS-Studio for Linux
The Development History of PVS-Studio for LinuxThe Development History of PVS-Studio for Linux
The Development History of PVS-Studio for Linux
PVS-Studio
 
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
Andrey Karpov
 
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
Andrey Karpov
 
Exploit Frameworks
Exploit FrameworksExploit Frameworks
Exploit Frameworks
phanleson
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#
Andrey Karpov
 
Linux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-StudioLinux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-Studio
PVS-Studio
 
Information sheet PVS-Studio
Information sheet PVS-StudioInformation sheet PVS-Studio
Information sheet PVS-Studio
PVS-Studio
 
How we test the code analyzer
How we test the code analyzerHow we test the code analyzer
How we test the code analyzer
PVS-Studio
 
How we test the code analyzer
How we test the code analyzerHow we test the code analyzer
How we test the code analyzer
PVS-Studio
 
Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notes
Perrin Harkins
 
PVS-Studio for Visual C++
PVS-Studio for Visual C++PVS-Studio for Visual C++
PVS-Studio for Visual C++
PVS-Studio
 
Regular use of static code analysis in team development
Regular use of static code analysis in team developmentRegular use of static code analysis in team development
Regular use of static code analysis in team development
PVS-Studio
 
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsPVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
Andrey Karpov
 

Similar to HPX and PVS-Studio (20)

Static Analysis: From Getting Started to Integration
Static Analysis: From Getting Started to IntegrationStatic Analysis: From Getting Started to Integration
Static Analysis: From Getting Started to Integration
 
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
 
A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ code
 
Comparing Functionalities of PVS-Studio and CppCat Static Code Analyzers
Comparing Functionalities of PVS-Studio and CppCat Static Code AnalyzersComparing Functionalities of PVS-Studio and CppCat Static Code Analyzers
Comparing Functionalities of PVS-Studio and CppCat Static Code Analyzers
 
Static analysis is most efficient when being used regularly. We'll tell you w...
Static analysis is most efficient when being used regularly. We'll tell you w...Static analysis is most efficient when being used regularly. We'll tell you w...
Static analysis is most efficient when being used regularly. We'll tell you w...
 
Using PVS-Studio analyzer together with Microsoft Visual Studio 2010 incremen...
Using PVS-Studio analyzer together with Microsoft Visual Studio 2010 incremen...Using PVS-Studio analyzer together with Microsoft Visual Studio 2010 incremen...
Using PVS-Studio analyzer together with Microsoft Visual Studio 2010 incremen...
 
The Development History of PVS-Studio for Linux
The Development History of PVS-Studio for LinuxThe Development History of PVS-Studio for Linux
The Development History of PVS-Studio for Linux
 
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
 
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
PVS-Studio Static Analyzer as a Tool for Protection against Zero-Day Vulnerab...
 
Exploit Frameworks
Exploit FrameworksExploit Frameworks
Exploit Frameworks
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#
 
Linux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-StudioLinux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-Studio
 
Information sheet PVS-Studio
Information sheet PVS-StudioInformation sheet PVS-Studio
Information sheet PVS-Studio
 
How we test the code analyzer
How we test the code analyzerHow we test the code analyzer
How we test the code analyzer
 
How we test the code analyzer
How we test the code analyzerHow we test the code analyzer
How we test the code analyzer
 
Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notes
 
PVS-Studio for Visual C++
PVS-Studio for Visual C++PVS-Studio for Visual C++
PVS-Studio for Visual C++
 
Regular use of static code analysis in team development
Regular use of static code analysis in team developmentRegular use of static code analysis in team development
Regular use of static code analysis in team development
 
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsPVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
 

Recently uploaded

UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
devvsandy
 
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
ssuserad3af4
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Envertis Software Solutions
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 

Recently uploaded (20)

UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
 
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 

HPX and PVS-Studio

  • 1. HPX and PVS-Studio Author: Hartmut Kaiser Date: 04.07.2015 This article was originally published at STE||AR Group Blog. Republished by the editors' permission. We have used a trial version of PVS-Studio for HPX previously, but I vaguely remembered it as being very verbose in its diagnostics. I have read a lot about the tool lately, and since it was a long time since we used it, we contacted the developers at Viva64 asking whether they would be willing to support our open source project. We were positively surprised that they agreed to provide us with a free license for one year in exchange for a blog post about our experience with the tool. General Impressions So I downloaded PVS-Studio V5.26 and installed it (without any problems) as an extension for my VS2013 Professional (update 4) setup. I would have preferred to test it with VS2015RC1, as this is currently my main development environment. Unfortunately, VS2015 is not supported yet, I however expect that it will be supported as soon as Microsoft releases the new version. The integration of the PVS-Studio into the Visual Studio user interface made a very good impression on me. One additional top level menu item provides access to all of the commands and options. All of the generated diagnostics are placed into a special output window from where you can jump to the source code that a message refers to. You can also open a web-based, context sensitive help explaining each of the generated diagnostics in more detail. In short, all is as it should be. The diagnostics generated have three severity levels (high, medium, and low) and are grouped into three categories (general analysis, optimization analysis, and 64-bit compatibility analysis). The user
  • 2. interface allows restriction of the shown diagnostics to only some (or one) of those and additionally allows for filtering to reduce the amount of messages to work through. For the main HPX module the tool generated about 70 diagnostics in about 1,000 C++ header and source files (~140,000 lines of code), which was not too bad (high severity: 5, medium: 44, low: 21). The initial analysis on my laptop took about 10 minutes. Example Diagnostics I was eager to see what mistakes or problems the tool might reveal. The HPX team is very conscious about code quality and we have the policy that code has to be reviewed by at least one other developer before it can go into the main branch. So I was quite confident the tool wouldn't find anything. Let's look at the high severity diagnostics first. Four of the diagnostics were very similar, and the context for one of them is shown below: template <typename Archive> void load(Archive& ar) { actions::manage_object_action_base* act = 0; ar >> hpx::serialization::detail::raw_ptr(act); // V522: Dereferencing of the null pointer 'act' might take place. HPX_ASSERT(act->is_valid()); // ... } This code is de-serializing a polymorphic object through its base pointer and we know that raw_ptr(act) is allocating a new object instance for the de-serialized object returning a pointer to it through its argument. We also know thatraw_ptr(act) would throw in case of any error. All of this should have been visible to PVS-Studio as all the related code is located in header files. The tool apparently was not able to see that, which is why it generated the diagnostic. Luckily you can tell PVS-Studio to ignore this particular error with a single mouse click, which adds a magic comment to the corresponding source code: //-V522, thus suppressing this message in the future - nifty. PVS-Studio gives you many more options for suppressing diagnostics - file or directory based, file name pattern based, or specific to a particular diagnostic globally - all of those easily accessible and self-explanatory. A second diagnostic was really alarming to me. Here is the corresponding code: #define HPX_VERSION_MAJOR 0 #define HPX_VERSION_MINOR 9 #define HPX_VERSION_SUBMINOR 11 std::string full_version_as_string() { // V609 Mod by zero. Denominator '0' == 0.
  • 3. return boost::str( boost::format("%d.%d.%d") % HPX_VERSION_MAJOR % HPX_VERSION_MINOR % HPX_VERSION_SUBMINOR); } It took me a moment to understand what PVS-Studio was trying to convey, since for me the overloaded operator%()implemented by the Boost.Format library was totally inconspicuous. However, even after realizing that the code would have been problematic if the operator was not actually overloaded, the generated diagnostic itself still did not make too much sense to me. In the end, I 'resolved' this message by suppressing it as well. The last 'high severity' diagnostic was an optimization analysis result: // V808 'hostname' object of 'basic_string' type was created // but was not utilized. std::string hostname = boost::asio::ip::host_name(); Sure enough, the tool was right, the variable 'hostname' was completely unused in this context. None of the compilers we use for our regular testing on more than 20 different platforms had reported this before - nice catch! The generated diagnostics from lesser severity levels were mostly things worth looking at once, but almost all of those flagged benign issues related to 32bit/64bit compatibility, like implicit conversions of signed integers to larger unsigned representation widths (e.g. int32_t --> uint64_t). Two diagnostics helped finding actual bugs, though. In one place we had this code: int runtime_support::load_components(util::section& ini) { // load all components as described in the configuration information if (!ini.has_section("hpx.components")) { // V601 The 'true' value is implicitly cast to the integer type. return true; // no components to load } // ... } The generated diagnostic pointed us to a problem: a while back we had changed the return type of the function frombool to int (including a change to the semantics of the returned value), but we forgot to adapt one of the return statements. This could have created problems which are difficult to reproduce. Another of the useful diagnostics actually revealed a possibly more serious problem: struct when_each_frame { // ...
  • 4. private: // V690 Copy constructor is declared as private in the // 'when_each_frame' class, but the default '=' operator // will still be generated by compiler. It is dangerous // to use such a class. when_each_frame(); when_each_frame(when_each_frame const&); public: // ... }; This was a very nice catch indeed! Especially as we added the constructor declarations as a workaround for older versions of gcc which were incorrectly instantiating default implementations for those constructors. In the end, I was happy to have invested my time into doing the work of running PVS-Studio on all of our files. I was also happy to see that no absolutely serious issues were diagnosed, another confirmation of the validity of our code review policy we put in place a while ago. As an action item, I noted to integrate running PVS-Studio as part of our contiguous integration system, which triggers builds on every commit to our development branch. Conclusions Static analysis definitely has its place. Running tools like PVS-Studio costs additional time and effort which in my book is absolutely well invested. Compilers can not always afford to perform such deep analysis that PVS-Studio attempts to do, as this would increase compile times even further. Especially useful for us will be the ability to seamlessly integrate the tool into our contiguous integration build system. This will also have another nice side effect: since we run our daily tests on many platforms (including Windows), it will make the results of the static analysis produced by a Windows-only tool available to our developers who mainly work on other platforms (like Linux or Mac/OS). Another nice option of the IDE integration of PVS-Studio is the ability to automatically run the analysis after each successful build. Surprisingly, this does not impose too much overhead onto the normal build process. This is a very useful feature which gives feedback for subtle problems very early on during development of new code. I will try to leave that option enabled for a while to see how effective that is. When looking through all of the generated diagnostics, I was surprised to realize that - even while the tool has all the time it needs to do an analysis as deeply as possible - PVS-Studio seems not to be able to look through certain operator overloads to figure out that those actually implement semantics different from the default. The example I showed above demonstrates this: the operator%() overload in Boost.Format does everything but an integral modulo operation (it performs string formatting instead), but PVS-Studio still warns about a possible division by zero. Sure, this is a real corner case and I'm not sure if it is always possible to provide the right level of diagnostics. On the other hand, this is where the real value of static analysis could be: deep semantic checking of our codes. In any case, if you are interested in trying out HPX, please fork it from our github site.