To get a trial key
fill out the form below
Team License (standard version)
Enterprise License (extended version)
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
GBP
RUB
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
A Scoop from PVS-Studio: "An Ideal…

A Scoop from PVS-Studio: "An Ideal Project with Zero Bugs Found!"

Apr 30 2014

We were recently contacted by a user who was claiming that our tool had detected zero bugs in his pretty heavy project (2000 files)! Nor general errors, nor 64-bit issues, nor any other defects. Since things are never like this in our world, we sent him just a few e-mails to find out some details and very soon were working on his computer remotely trying to figure the whole thing out ourselves. All the settings were right; no silly evident faults of the analyzer's operation – all was fine. After a few test launches, we grew totally convinced that our analyzer wasn't actually generating a single warning for the project! Want to know why?

0254_An_Ideal_Project/image1.png

You see, the PVS-Studio analyzer provides the user with a number of ways to hide irrelevant diagnostic messages. You can turn them off inside the code; you can hide all messages relating to certain files by message name or text; you can hide messages for files in a certain folder. The very first idea to occur to anyone is that the guy added the entire project folder into the exceptions list. Doing so is possible, but we checked this version first of all, and it proved false.

However, the analyzer was behaving just as if the whole project had been excluded from analysis. We went on to examine intermediate configuration files (file.PVS-Studio.cfg) which are created before launching the analyzer for each file. Among other data, they include information about the folders excluded from analysis. This part of an intermediate file usually looks like this:

exclude-path = *\boost\*
exclude-path = *\zlib\*
...
exclude-path = c:\program files (x86)\microsoft visual studio 11.0
exclude-path = c:\program files (x86)\microsoft sdks
...

Some of the folders are system folders, others are standard libraries, and sometimes there may also be user folders.

But this time it was the entire project folder among other exceptions, although no one seemed to have added it there. Because of that the analyzer didn't show a single warning for the code.

So, what happened?

In our analyzer, in order to exclude system libraries from analysis, we have the paths from Additional Includes automatically added into the exceptions list, these paths starting with "C:\Program Files" and "C:\Program Files (x86)".

Additional Includes may include paths defined in relation to the folder the compiler is launched from (which is usually the folder of the project file). For example, you can legally add a path like "../Common" into the Additional Includes list.

Before checking the paths for being nested into "Program Files", we used to normalize them with the help of the DirectoryInfo class:

String NormIncludePath = 
  new DirectoryInfo(list[i].Trim('"')).FullName.ToLower();

However, the DirectoryInfo class would at the same time restore relative paths in relation to the current process folder, which is obviously incorrect. Now imagine the following situation. The IDE's devenv.exe process is launched from its standard folder – say, we simply open the IDE through a desktop shortcut. If the project contains relative paths in Additional Includes, these paths are filtered off as if they were system folders, for the standard folder of devenv.exe is c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\. Therefore these paths get into exceptions.

The bug was easy to fix, we just needed to expand the relative paths correctly:

String NormIncludePath = list[i].Trim('"');
ExpandRelativePath(
  ref NormIncludePath, CompilerWorkingDirectory);
NormIncludePath = NormIncludePath.ToLower();

To sum it all up, what impact could that bug in our analyzers have on your code? If you use relative paths in Additional Includes in your project and launch the IDE in a certain way (through the desktop Visual Studio shortcut), you might have missed some of the messages from the analyzer. This bug was both in PVS-Studio. The fresh versions of this product don't have it anymore.

P.S. Unfortunately, there hardly exists an absolutely perfect project our analyzer cannot find bugs in. Yet we keep seeking.

Popular related articles
Technologies used in the PVS-Studio code analyzer for finding bugs and potential vulnerabilities

Date: Nov 21 2018

Author: Andrey Karpov

A brief description of technologies used in the PVS-Studio tool, which let us effectively detect a large number of error patterns and potential vulnerabilities. The article describes the implementati…
PVS-Studio for Java

Date: Jan 17 2019

Author: Andrey Karpov

In the seventh version of the PVS-Studio static analyzer, we added support of the Java language. It's time for a brief story of how we've started making support of the Java language, how far we've co…
PVS-Studio ROI

Date: Jan 30 2019

Author: Andrey Karpov

Occasionally, we're asked a question, what monetary value the company will receive from using PVS-Studio. We decided to draw up a response in the form of an article and provide tables, which will sho…
Appreciate Static Code Analysis!

Date: Oct 16 2017

Author: Andrey Karpov

I am really astonished by the capabilities of static code analysis even though I am one of the developers of PVS-Studio analyzer myself. The tool surprised me the other day as it turned out to be sma…
How PVS-Studio Proved to Be More Attentive Than Three and a Half Programmers

Date: Oct 22 2018

Author: Andrey Karpov

Just like other static analyzers, PVS-Studio often produces false positives. What you are about to read is a short story where I'll tell you how PVS-Studio proved, just one more time, to be more atte…
Characteristics of PVS-Studio Analyzer by the Example of EFL Core Libraries, 10-15% of False Positives

Date: Jul 31 2017

Author: Andrey Karpov

After I wrote quite a big article about the analysis of the Tizen OS code, I received a large number of questions concerning the percentage of false positives and the density of errors (how many erro…
The Evil within the Comparison Functions

Date: May 19 2017

Author: Andrey Karpov

Perhaps, readers remember my article titled "Last line effect". It describes a pattern I've once noticed: in most cases programmers make an error in the last line of similar text blocks. Now I want t…
The Ultimate Question of Programming, Refactoring, and Everything

Date: Apr 14 2016

Author: Andrey Karpov

Yes, you've guessed correctly - the answer is "42". In this article you will find 42 recommendations about coding in C++ that can help a programmer avoid a lot of errors, save time and effort. The au…
Free PVS-Studio for those who develops open source projects

Date: Dec 22 2018

Author: Andrey Karpov

On the New 2019 year's eve, a PVS-Studio team decided to make a nice gift for all contributors of open-source projects hosted on GitHub, GitLab or Bitbucket. They are given free usage of PVS-Studio s…
The way static analyzers fight against false positives, and why they do it

Date: Mar 20 2017

Author: Andrey Karpov

In my previous article I wrote that I don't like the approach of evaluating the efficiency of static analyzers with the help of synthetic tests. In that article, I give the example of a code fragment…

Comments (0)

Next comments

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →
Accept