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

Request our prices
New License
License Renewal
--Select currency--
USD
EUR
GBP
RUB
* By clicking this button you agree to our Privacy Policy statement

Free PVS-Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

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

I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

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.

>
>
PVS-Studio 7.09

PVS-Studio 7.09

Aug 28 2020
Author:

The development of the PVS-Studio analyzer is speeding up. Therefore, most likely, now each release will be followed by a special note so that users don't miss changes that may be useful to them. What's interesting is that from now on we won't just list everything that was added or improved. Rather, now on the contrary, the purpose is to highlight the most important features in the news to avoid having just a boring list of changes. So, we offer you a press release for PVS-Studio 7.09.

0757_Release_709/image1.png

Forrester Research

This section is not related to the new version of PVS-Studio, but we would like to note a pleasant event that just took place shortly before the release.

On August 6, 2020, Forrester Research released a study called Now Tech: Static Application Security Testing, Q3 2020, which included the PVS-Studio analyzer as a SAST-specialized solution. Forrester is one of the leading researchers of the impact of new and innovative technologies on business processes and the market, so the inclusion of PVS-Studio in this study is a decent confirmation (both for our users and for us) of the relevance of this direction in which our product is developing. The research report is available for purchase to subscribers and customers of Forrester Research.

C++

Regular readers of our blog are likely to remember that we use our own engine for parsing C and C++ code. This has both advantages and disadvantages. The C++ language is now rapidly developing and it has become clear that a serious reworking of the analyzer core is required. Otherwise, the analyzer will gradually get worse at parsing complex templates and get confused when inferring types of certain objects. This got our team a bit distracted from developing new diagnostics. However, after completing the planned work, we will be able to reduce the amount of memory consumed, improve support of C++20, and make many other improvements. In turn, these changes in the future will make the data flow analysis mechanism multipass. This will significantly improve the accuracy of many existing diagnostics.

New general analysis diagnostics:

  • V1059. Macro name overrides a keyword/reserved name. This may lead to undefined behavior.
  • V1060. Passing 'BSTR ' to the 'SysAllocString' function may lead to incorrect object creation.
  • V1061. Extending 'std' or 'posix' namespace may result in undefined behavior.
  • V1062. Class defines a custom new or delete operator. The opposite operator must also be defined.
  • V1063. The modulo by 1 operation is meaningless. The result will always be zero.

Micro optimizations:

  • V826. Consider replacing standard container with a different one.
  • V827. Maximum size of a vector is known at compile time. Consider pre-allocating it by calling reserve(N).
  • V828. Decreased performance. Moving an object in a return statement prevents copy elision.
  • V829. Lifetime of the heap-allocated variable is limited to the current function's scope. Consider allocating it on the stack instead.

Let's have a closer look at the new V012 diagnostic: Some warnings could have been disabled.

Some methods of suppressing false positives allow you to completely disable the analyzer diagnostics. As a result, not only will some warnings be marked as false positives, but it also will become possible to remove them from further reports.

To find out which mechanisms are involved in disabling diagnostics, you can enable adding special warnings to the analyzer report.

  • When using the analyzer with Visual Studio, go to the plugin settings and activate the ReportDisabledRules option in the 'Specific Analyzer Settings' section.
  • When using the analyzer on Linux and MacOS, add the 'report-disabled-rules=yes' option to the .cfg file.
pvs-studio-analyzer analyze ... --cfg source.cpp.PVS-Studio.cfg

As a result, the analyzer report will display messages with the V012 code and information about the sources of disabling diagnostics. PVS-Studio IDE plugins support navigation to the reason of disabling diagnostics in source code files and configuration files with rules (.pvsconfig). The paths to the configuration files containing the analyzer exception rules will also be added to the analyzer report as V012 messages.

C#

In the PVS-Studio C# analyzer, there are now extended abilities of navigation through source files for Visual Studio and Rider plugins. Now it is possible to follow potentially dangerous fragments of code inside methods when the analyzer complains about calling such a method.

Also, the PVS-Studio C# analyzer supports redefining the certainty levels of warnings in the diagnostics configuration files (. pvsconfig). This feature has been available for a long time in the C++ analyzer.

The analyzer's warnings have three certainty levels: High, Medium, and Low. Depending on the used constructs in code, the analyzer estimates the reliability of warnings and assigns them an appropriate level in a report.

In some projects, searching for specific types of errors can be very important, regardless of the level of a warning's certainty. Sometimes there can be a reverse situation, when the error messages are of little use, but a developer doesn't want to disable them at all. In such cases, you can manually set the diagnostics' level of High/Medium/Low. To do this, you should use special comments that can be added in code or the diagnostics configuration file.

In the configuration file (.pvsconfig), you can write:

//V_LEVEL_1::3001
//V_LEVEL_2::3010,3020,3030
//V_LEVEL_3::3002

New diagnostics:

  • V3154. The 'a % b' expression always evaluates to 0.
  • V3155. The expression is incorrect or it can be simplified.

Java

Most of the new diagnostics in this release are added for the Java language. By the way, speaking of creating Java diagnostics, we wrote a small note: Under the hood of PVS-Studio for Java: how we develop diagnostics.

New diagnostics:

  • V6082. Unsafe double-checked locking.
  • V6083. Serialization order of fields should be preserved during deserialization.
  • V6084. Suspicious return of an always empty collection.
  • V6085. An abnormality within similar comparisons. It is possible that a typo is present inside the expression.
  • V6086. Suspicious code formatting. 'else' keyword is probably missing.
  • V6087. InvalidClassException may occur during deserialization.
  • V6088. Result of this expression will be implicitly cast to 'Type'. Check if program logic handles it correctly.
  • V6089. It's possible that the line was commented out improperly, thus altering the program's operation logics.
  • V6090. Field 'A' is being used before it was initialized.
  • V6091. Suspicious getter/setter implementation. The 'A' field should probably be returned/assigned instead.
  • V6092. A resource is returned from try-with-resources statement. It will be closed before the method exits.

Additional links

Since the previous release, in our blog we have posted several notes on integrating PVS-Studio into the development process. We think that they can be useful for DevOps specialists and developers who implement static code analysis methodology in their companies.

Popular related articles
The Last Line Effect

Date: May 31 2014

Author: Andrey Karpov

I have studied many errors caused by the use of the Copy-Paste method, and can assure you that programmers most often tend to make mistakes in the last fragment of a homogeneous code block. I have ne…
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…
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…
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…
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…
Static analysis as part of the development process in Unreal Engine

Date: Jun 27 2017

Author: Andrey Karpov

Unreal Engine continues to develop as new code is added and previously written code is changed. What is the inevitable consequence of ongoing development in a project? The emergence of new bugs in th…
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…
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…

Comments (0)

Next comments
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