Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

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

close form
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

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

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam

Webinar: Evaluation - 05.12

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


Comments (0)

Next comments next comments
close comment form