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

>
>
Program Errors That Do Not Exist

Program Errors That Do Not Exist

Dec 24 2009
Author:

Not long ago, one user of our code analyzer PVS-Studio addressed us; he was complaining about the work of the tool during the verification of one of his projects.

Our tool gave out such a message:

Error 155 Cannot open configuration file c:\foo\testfile.c.PVS
  Studio.cfg

We should explain hereby that for each file being verified, PVS-Studio creates, among others, a special configuration file PVS-Studio.cfg, in which the selected settings are given for the analysis module (which is a separate exe-file).

In the process of correspondence, it turned out that the file which the tool cannot check, is called not testfile.c, as it should be by the logic of the message, but test^file.c. Such behavior looks as if the analyzer lost the symbol "^". Trying to find the error, we have detected that the plug-in PVS-Studio transfers the file name correctly, while the problem occurs in fact in the analyzer core (the separate exe-file itself).

First, we seemed to find that the problem with this symbol is "nearby" the parsing library of configuration files. However, strange things turned out during the debugging. If one sets command line parameters in Visual Studio environment (in which we develop the tool) for the analyzer as "-cfg=c:\foo\test^file.c.PVS-Studio.cfg" and presses Ctrl-F5 (program start), one will get a message:

Cannot open configuration file c:\foo\testfile.c.PVS-Studio.cfg

That means that the error repeats.

And if one presses F5 only (debugger start), then the program will work correctly! The reader will say at once: "So why do you develop a tool for a developer and do not know yourself that the Debug-version of the program can work, while the Release version cannot?" Please pay attention that both in the first and second cases Debug-version was started, but in different modes.

After the experiments it became obvious that nothing was obvious.

We put the code of our project aside and carried out a simple experiment that can be repeated by anyone.

  • 1. Open Visual Studio 2005 or 2008 (there is no difference), create Visual C++ Win32 Console Application.
  • 2. Insert only one line with fprintf the way the following code is obtained as a result:
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
  fprintf(stdout, "%s\n", argv[1]);
  return 0;
}
  • 3. In the debug settings (Debugging->Command Arguments) indicate "test^file.c" without quotation marks.
  • 4. Start the program (Debug mode) by Ctrl-F5. We get:
testfile.c

i.e., symbol "^" has disappeared

  • 5. Put a breakpoint in the line "return 0;", press F5. We get:
test^file.c

i.e., symbol "^" exists.

Strange as it may seem, the program behaves differently depending on the start mode. Probably, symbol "^" is processed as an Escape-sequence. But why start by F5 and Ctrl-F5 gives different results?

In PVS-Studio, we selected an alternate way. In case in the configuration file name there appears symbol "^", we replace it by another symbol.

Popular related articles


Comments (0)

Next comments next comments
close comment form