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.
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
fprintf(stdout, "%s\n", argv[1]);
return 0;
}
testfile.c
i.e., symbol "^" has disappeared
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.
0