SlideShare ist ein Scribd-Unternehmen logo
1 von 6
Downloaden Sie, um offline zu lesen
Viva64: working up of 64-bit
applications
Author: Evgeniy Ryzhkov

Date: 14.12.2006

At present, Viva64 and VivaMP software products are included in PVS-Studio as parts of it and are no
longer distributed as separate applications. Please use PVS-Studio program to obtain the necessary
possibilities of code verification.


Abstract
Viva64 - is a tool for searching of errors and possible problems at C/C ++ code at the applications port on
the 64-bit platform. Nowadays when the necessity of the 64-bit versions software output is realized by
the most of the developers, it is too important to be sure of the working up product quality. Even if the
traditional 32-bit version of your product has been tested carefully, its portability on the 64-bit platform
may reveal some unexpected problems. Some separate items are devoted to the applications portability
problems, and this one tells how to provide the necessary level of the code quality with the help the
static analyzer Viva64.


The main resources
Came to the necessity of the existing applications port on the new 64-bit system, the software
developers meet with unusual problems. The programs that have been functioning like clock-watch for
years begin to behave themselves indefinitely. Certainly a program has more main memory. Although
during processing more data then earlier ones, the application may hang up, crash, or, what's worse to
give out files with stuff instead of ones with the results of its work. The reason of it is in the change of
some data types dimensions (primarily pointers). However to find out areas in the programs code,
where of the code fulfillment sequence has changed because of it, with the help of the compiler
standard expressions is impossible. The compiler can't give out warning messages at all potentially
incorrect constructions, although a programmer has to find them out.

The code static analyzer Viva64 comes to the aid, integrating into Visual Studio 2005, it allows:

    •   to detect incorrect construction at the code (from the 64-bit support's point of view);
    •   to give an exact and complete diagnostics up to the line number;
    •   to make navigation over the code incorrect areas;
    •   to analyze the after-effects, to which may lead the error, with the help of the full reference
        system, integrating into MSDN;
    •   to point out how to correct the errors with the help of the examples from the documentation;
    •   to carry out code analysis of the whole project or solution (in the Microsoft Visual Studio
        terminology) , but not only separate files.

Viva64 - is the first in world code analyzer on the compatibility with the 64-bit systems in the world.
Despite there existed early and exist now some other code analyzers (as a rule link-like ones), Viva64 is
distinguished on principle by:
•   orientation exceptionally towards the search of problems in the 64 bit code during the 32
                                                                            64-bit                 32-bit
        programs port as well as during the new applications working up.
    •   total integration with Microsoft Visual Studio - files analysis, navigation over the code, help
        system.
    •   minimum setup - one needn't study settings documentation, choose check levels, or set the
        numbers of the analyzing rules to work with the analyzer.
    •   the analyzer is ready for work just after its installation.

Let's know how it works.


Installation and setup
One can download the analyzer from the site www.Viva64.com. The evaluation version allows
appreciating completely its power. The installation is not difficult, that's why a user could start
installation at ones, if it were an ordinary code analyzer. However there is the only most important
adjustment for a user in Viva64 - is an input dialogue of the authorized information. But this adjustment
                               a64
will be necessary only after you can estimate all the possibilities of the tool.

As we have already said Viva64 integrates in Microsoft Visual Studio 2005 (picture 1) and allows at once
starting to work.

What we'll do.




                      Picture 1: Viva64 Integration in Microsoft Visual Studio 2005.

Attention! If it is necessary, a user may consult with the embedded help system about some other
settings.
The distributive Viva64 includes a test example PortSample - a project for Visual Studio 2005, which
contains a simple program, demonstrating some classical errors. This example is installed separately
from the Viva64 folder Windows program menu.

Adjust this example.


Functioning principle of Viv
                         Viva64
Open, compile and start PortSample 32 bit version. In Visual Studio you should choose the type of the
                                     32-bit
platform Win32 and menu command "Build". After the example start switch on all the checkboxes
(picture 2) and click the button "Run". The program will function correctly and send the message
"Done". At the same time all chosen functions VXXX() with demonstrating code will be called.




                                      Picture 2: Test example window.

And now let's compile and start 64 bit version of the same example, so choose the plat
                                64-bit                                              platform x64 in the
project Visual Studio adjustments. After clicking the button "Run" the program will behave
unpredictably and probably will crash (it depends of the computer). Its time for Viva64 to demonstrate
itself.

Open the file V1XX.cpp and choose the command in Viva64 menu

"Check current file". Firstly, it'll carry out the preprocessing for macro determination opening, switching
on the header files and etc. As a preprocessing result we'll get file with the expanding ".i", which is in the
project folder. For the created file the analyzer will be started that will carry out the code check. After
               .
which the results of the analyzer work will be set in the window of the ambience output Visual Studio
2005. Pay attention that you may carry out file analysis just for the platform x64. In case of file check for
                                                           just
another platform (for example, Win32) it will be sent a message about error. It means that for different
platforms it is possible to use different ways of carrying out the program, which are set with the he of
                                                                                                      help
the #ifdef/#endif constructions.

As far as for Viva64 analyzer work is necessary to carry out preprocessing, so one should make sure that
the file is compiled for the platform x64 correctly, without messages about errors.


The usage of Viva64: detect, analysis and errors correction in the code
To proceed directly with the errors detect at the open example PostSample one should choose "Check
Current Project". Firstly, it will be started the preprocessor, and then the analyzer. The results of its
work are shown in the output window (picture 3).
       e




                                        Picture 3: Output Window.

And this is the first:

error V101: Implicit assignment type conversion to memsize type.

Let's look at the code in this place.

   unsigned imageWidth = 1000;

   unsigned imageHeght = 1000
                         1000;

   unsigned bytePerPixel = 3;

   unsigned maxFrameCountInBuffer;
if (IsX64Platform()) {

       maxFrameCountInBuffer = 2000;

   } else {

       maxFrameCountInBuffer = 100;

   }

   size_t bufferSize = imageWidth * imageHeght *                                           // 34

                                  bytePerPixel * maxFrameCountInBuffer;

The error is given on the line with the declaration of the variable bufferSize. We see that the variable
maxFrameCountInBuffer for 64-bit platform has a value 2000.

This is admissible, because after the multiplying of all the variables we expect to get 64-bit figure (buffer
size), but ... we'll get only 32-bit one. As a result the variable bufferSize will never expend 4 Gb. Although
it itself is a 64-bit type. Pay attention that the compiler gives nothing on this line even at the highest
diagnostics level. And Viva64 says about the error here. If you are not sure that you absolutely realize
the types digit capacity problem, push F4, and the embedded help system will be opened Viva64, where
is given the detailed error description with the recommendations of its correction.

Let's continue studying the example, so push F4 once more. Move to the message:

error V102: Usage non memsize type for pointer arithmetic.

Let's check the code which is at the line 71:

   int domainWidth;

   int domainHeght;

   int domainDepth;

   ...

   char *buffer;

   ...

   char *current = buffer;

   char *end = buffer;

   end += domainWidth * domainHeght * domainDepth; // 71

Here is another problem. From the error description we see that for the pointer arithmetic is used the
type not intended for it. In this case the pointer arithmetic is carried out with 32-bit type int, but it
should be used 64-bit one. Data types, using for the work with the pointers, and also for the keeping of
the object sizes (for examples, arrays) in Viva64 are called memsize-types. At the reference system the
memsize-types usage is examined carefully.

Let's look in the help system how to correct the present error. Here are given advices how to change the
types, which take part in such arithmetic. The example correction is in the change of the variable type
domainWidth, domainHeigh, domainDepth for the type ptrdiff_t or in the usage of the explicit type
conversation. In all the analyzer will give out more than dozens error messages at the PostSample
project.

And what is the compiler? The compiler Microsoft Visual C++ 2005 with the switched on diagnostics of
the port problems (the key /Wp64) and the maximum level of the diagnostics messages (the key /W4)
gives out for the entire project... only three diagnostics messages, that are also caught by the analyzer
Viva64. This leads that the most errors stay undetected during the applications port on the 64-bit
platform without using Viva64.


Viva64's position in the process of the software working up
There are two ways of Viva64 usage at the working up process: in the case of the prepared 32-bit
application on the 64-bit platform and in the case of the working up new 64-bit application.

The 32-bit application port should be carried out in such a way:

    •   prepare the project in the Studio Visual 2005, which is build correctly for the platform Win32;
    •   add a new platform x64 to the project, build the project, fixing all compiler errors;
    •   switch on the maximum warning level (/Wp64, Detect 64-Bit Portability Issues), correct the
        errors;
    •   with the help of Viva64 carry out all possible errors detect, analyze them and correct;
    •   move to the application testing.

In the case of a new 64-bit application enduring it is reasonable not to wait for the end of the working
up, but to use Viva64 for the working up code control. Moreover one may check as well as the whole
project or decision, and the separate more important code parts.


Viva64 is not a silver bullet and what is next...
It is necessary to notice that Viva64 doesn't solve all the problems, appearing at the 64-bit software
enduring:

    •   Viva64 can't replace full testing;
    •   Viva64 knows about the most errors, but not about all;
    •   Viva64 should be used by the developer, understanding all work computer principles.

In other words, if you correct all the errors at the code with the help of Viva64, shouldn't consider that
the application has been already prepared and it doesn't need diagnostics.

Although Viva64 can really raise the quality of the working up software, enduce the error number and
hasten the time of the product output at the market.

Weitere ähnliche Inhalte

Was ist angesagt?

Difficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usabilityDifficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usabilityPVS-Studio
 
Regular use of static code analysis in team development
Regular use of static code analysis in team developmentRegular use of static code analysis in team development
Regular use of static code analysis in team developmentPVS-Studio
 
Regular use of static code analysis in team development
Regular use of static code analysis in team developmentRegular use of static code analysis in team development
Regular use of static code analysis in team developmentAndrey Karpov
 
20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platform20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platformAndrey Karpov
 
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...Andrey Karpov
 
PVS-Studio static analyzer: advanced features
PVS-Studio static analyzer: advanced featuresPVS-Studio static analyzer: advanced features
PVS-Studio static analyzer: advanced featuresAndrey Karpov
 
PVS-Studio for Visual C++
PVS-Studio for Visual C++PVS-Studio for Visual C++
PVS-Studio for Visual C++Andrey Karpov
 
PVS-Studio features overview (2020)
PVS-Studio features overview (2020)PVS-Studio features overview (2020)
PVS-Studio features overview (2020)Andrey Karpov
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codeAndrey Karpov
 
03 intro to vb programming
03 intro to vb programming03 intro to vb programming
03 intro to vb programmingJomel Penalba
 

Was ist angesagt? (12)

Difficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usabilityDifficulties of comparing code analyzers, or don't forget about usability
Difficulties of comparing code analyzers, or don't forget about usability
 
Regular use of static code analysis in team development
Regular use of static code analysis in team developmentRegular use of static code analysis in team development
Regular use of static code analysis in team development
 
Regular use of static code analysis in team development
Regular use of static code analysis in team developmentRegular use of static code analysis in team development
Regular use of static code analysis in team development
 
Parallel Lint
Parallel LintParallel Lint
Parallel Lint
 
20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platform20 issues of porting C++ code on the 64-bit platform
20 issues of porting C++ code on the 64-bit platform
 
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
Program errors occurring while porting C++ code from 32-bit platforms on 64-b...
 
PVS-Studio static analyzer: advanced features
PVS-Studio static analyzer: advanced featuresPVS-Studio static analyzer: advanced features
PVS-Studio static analyzer: advanced features
 
PVS-Studio for Visual C++
PVS-Studio for Visual C++PVS-Studio for Visual C++
PVS-Studio for Visual C++
 
PVS-Studio features overview (2020)
PVS-Studio features overview (2020)PVS-Studio features overview (2020)
PVS-Studio features overview (2020)
 
ID E's features
ID E's featuresID E's features
ID E's features
 
PVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio advertisement - static analysis of C/C++ code
PVS-Studio advertisement - static analysis of C/C++ code
 
03 intro to vb programming
03 intro to vb programming03 intro to vb programming
03 intro to vb programming
 

Ähnlich wie Viva64: working up of 64-bit applications

Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?PVS-Studio
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsPVS-Studio
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsAndrey Karpov
 
PVS-Studio, a solution for developers of modern resource-intensive applications
PVS-Studio, a solution for developers of modern resource-intensive applicationsPVS-Studio, a solution for developers of modern resource-intensive applications
PVS-Studio, a solution for developers of modern resource-intensive applicationsPVS-Studio
 
Lesson 6. Errors in 64-bit code
Lesson 6. Errors in 64-bit codeLesson 6. Errors in 64-bit code
Lesson 6. Errors in 64-bit codePVS-Studio
 
Driver Development for Windows 64-bit
Driver Development for Windows 64-bitDriver Development for Windows 64-bit
Driver Development for Windows 64-bitPVS-Studio
 
Diving into VS 2015 Day2
Diving into VS 2015 Day2Diving into VS 2015 Day2
Diving into VS 2015 Day2Akhil Mittal
 
Seven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemSeven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemAndrey Karpov
 
Seven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemSeven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemPVS-Studio
 
Lesson 27. Peculiarities of creating installers for a 64-bit environment
Lesson 27. Peculiarities of creating installers for a 64-bit environmentLesson 27. Peculiarities of creating installers for a 64-bit environment
Lesson 27. Peculiarities of creating installers for a 64-bit environmentPVS-Studio
 
The forgotten problems of 64-bit programs development
The forgotten problems of 64-bit programs developmentThe forgotten problems of 64-bit programs development
The forgotten problems of 64-bit programs developmentPVS-Studio
 
A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4Andrey Karpov
 
Comparison of analyzers' diagnostic possibilities at checking 64-bit code
Comparison of analyzers' diagnostic possibilities at checking 64-bit codeComparison of analyzers' diagnostic possibilities at checking 64-bit code
Comparison of analyzers' diagnostic possibilities at checking 64-bit codePVS-Studio
 
Monitoring a program that monitors computer networks
Monitoring a program that monitors computer networksMonitoring a program that monitors computer networks
Monitoring a program that monitors computer networksPVS-Studio
 
Comparing capabilities of PVS-Studio and Visual Studio 2010 in detecting defe...
Comparing capabilities of PVS-Studio and Visual Studio 2010 in detecting defe...Comparing capabilities of PVS-Studio and Visual Studio 2010 in detecting defe...
Comparing capabilities of PVS-Studio and Visual Studio 2010 in detecting defe...PVS-Studio
 
A collection of examples of 64 bit errors in real programs
A collection of examples of 64 bit errors in real programsA collection of examples of 64 bit errors in real programs
A collection of examples of 64 bit errors in real programsMichael Scovetta
 
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...Andrey Karpov
 
I just had to check ICQ project
I just had to check ICQ projectI just had to check ICQ project
I just had to check ICQ projectPVS-Studio
 
De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdf
De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdfDe05_panagenda_Prepare-Applications-for-64-bit-Clients.pdf
De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdfpanagenda
 

Ähnlich wie Viva64: working up of 64-bit applications (20)

Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real Programs
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real Programs
 
PVS-Studio, a solution for developers of modern resource-intensive applications
PVS-Studio, a solution for developers of modern resource-intensive applicationsPVS-Studio, a solution for developers of modern resource-intensive applications
PVS-Studio, a solution for developers of modern resource-intensive applications
 
Lesson 6. Errors in 64-bit code
Lesson 6. Errors in 64-bit codeLesson 6. Errors in 64-bit code
Lesson 6. Errors in 64-bit code
 
Driver Development for Windows 64-bit
Driver Development for Windows 64-bitDriver Development for Windows 64-bit
Driver Development for Windows 64-bit
 
Diving into VS 2015 Day2
Diving into VS 2015 Day2Diving into VS 2015 Day2
Diving into VS 2015 Day2
 
Seven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemSeven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit System
 
Seven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit SystemSeven Steps of Migrating a Program to a 64-bit System
Seven Steps of Migrating a Program to a 64-bit System
 
Lesson 27. Peculiarities of creating installers for a 64-bit environment
Lesson 27. Peculiarities of creating installers for a 64-bit environmentLesson 27. Peculiarities of creating installers for a 64-bit environment
Lesson 27. Peculiarities of creating installers for a 64-bit environment
 
The forgotten problems of 64-bit programs development
The forgotten problems of 64-bit programs developmentThe forgotten problems of 64-bit programs development
The forgotten problems of 64-bit programs development
 
A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4A Long-Awaited Check of Unreal Engine 4
A Long-Awaited Check of Unreal Engine 4
 
Comparison of analyzers' diagnostic possibilities at checking 64-bit code
Comparison of analyzers' diagnostic possibilities at checking 64-bit codeComparison of analyzers' diagnostic possibilities at checking 64-bit code
Comparison of analyzers' diagnostic possibilities at checking 64-bit code
 
Monitoring a program that monitors computer networks
Monitoring a program that monitors computer networksMonitoring a program that monitors computer networks
Monitoring a program that monitors computer networks
 
Comparing capabilities of PVS-Studio and Visual Studio 2010 in detecting defe...
Comparing capabilities of PVS-Studio and Visual Studio 2010 in detecting defe...Comparing capabilities of PVS-Studio and Visual Studio 2010 in detecting defe...
Comparing capabilities of PVS-Studio and Visual Studio 2010 in detecting defe...
 
A collection of examples of 64 bit errors in real programs
A collection of examples of 64 bit errors in real programsA collection of examples of 64 bit errors in real programs
A collection of examples of 64 bit errors in real programs
 
64-bit Loki
64-bit Loki64-bit Loki
64-bit Loki
 
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
 
I just had to check ICQ project
I just had to check ICQ projectI just had to check ICQ project
I just had to check ICQ project
 
De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdf
De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdfDe05_panagenda_Prepare-Applications-for-64-bit-Clients.pdf
De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdf
 

Kürzlich hochgeladen

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Kürzlich hochgeladen (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Viva64: working up of 64-bit applications

  • 1. Viva64: working up of 64-bit applications Author: Evgeniy Ryzhkov Date: 14.12.2006 At present, Viva64 and VivaMP software products are included in PVS-Studio as parts of it and are no longer distributed as separate applications. Please use PVS-Studio program to obtain the necessary possibilities of code verification. Abstract Viva64 - is a tool for searching of errors and possible problems at C/C ++ code at the applications port on the 64-bit platform. Nowadays when the necessity of the 64-bit versions software output is realized by the most of the developers, it is too important to be sure of the working up product quality. Even if the traditional 32-bit version of your product has been tested carefully, its portability on the 64-bit platform may reveal some unexpected problems. Some separate items are devoted to the applications portability problems, and this one tells how to provide the necessary level of the code quality with the help the static analyzer Viva64. The main resources Came to the necessity of the existing applications port on the new 64-bit system, the software developers meet with unusual problems. The programs that have been functioning like clock-watch for years begin to behave themselves indefinitely. Certainly a program has more main memory. Although during processing more data then earlier ones, the application may hang up, crash, or, what's worse to give out files with stuff instead of ones with the results of its work. The reason of it is in the change of some data types dimensions (primarily pointers). However to find out areas in the programs code, where of the code fulfillment sequence has changed because of it, with the help of the compiler standard expressions is impossible. The compiler can't give out warning messages at all potentially incorrect constructions, although a programmer has to find them out. The code static analyzer Viva64 comes to the aid, integrating into Visual Studio 2005, it allows: • to detect incorrect construction at the code (from the 64-bit support's point of view); • to give an exact and complete diagnostics up to the line number; • to make navigation over the code incorrect areas; • to analyze the after-effects, to which may lead the error, with the help of the full reference system, integrating into MSDN; • to point out how to correct the errors with the help of the examples from the documentation; • to carry out code analysis of the whole project or solution (in the Microsoft Visual Studio terminology) , but not only separate files. Viva64 - is the first in world code analyzer on the compatibility with the 64-bit systems in the world. Despite there existed early and exist now some other code analyzers (as a rule link-like ones), Viva64 is distinguished on principle by:
  • 2. orientation exceptionally towards the search of problems in the 64 bit code during the 32 64-bit 32-bit programs port as well as during the new applications working up. • total integration with Microsoft Visual Studio - files analysis, navigation over the code, help system. • minimum setup - one needn't study settings documentation, choose check levels, or set the numbers of the analyzing rules to work with the analyzer. • the analyzer is ready for work just after its installation. Let's know how it works. Installation and setup One can download the analyzer from the site www.Viva64.com. The evaluation version allows appreciating completely its power. The installation is not difficult, that's why a user could start installation at ones, if it were an ordinary code analyzer. However there is the only most important adjustment for a user in Viva64 - is an input dialogue of the authorized information. But this adjustment a64 will be necessary only after you can estimate all the possibilities of the tool. As we have already said Viva64 integrates in Microsoft Visual Studio 2005 (picture 1) and allows at once starting to work. What we'll do. Picture 1: Viva64 Integration in Microsoft Visual Studio 2005. Attention! If it is necessary, a user may consult with the embedded help system about some other settings.
  • 3. The distributive Viva64 includes a test example PortSample - a project for Visual Studio 2005, which contains a simple program, demonstrating some classical errors. This example is installed separately from the Viva64 folder Windows program menu. Adjust this example. Functioning principle of Viv Viva64 Open, compile and start PortSample 32 bit version. In Visual Studio you should choose the type of the 32-bit platform Win32 and menu command "Build". After the example start switch on all the checkboxes (picture 2) and click the button "Run". The program will function correctly and send the message "Done". At the same time all chosen functions VXXX() with demonstrating code will be called. Picture 2: Test example window. And now let's compile and start 64 bit version of the same example, so choose the plat 64-bit platform x64 in the project Visual Studio adjustments. After clicking the button "Run" the program will behave unpredictably and probably will crash (it depends of the computer). Its time for Viva64 to demonstrate itself. Open the file V1XX.cpp and choose the command in Viva64 menu "Check current file". Firstly, it'll carry out the preprocessing for macro determination opening, switching on the header files and etc. As a preprocessing result we'll get file with the expanding ".i", which is in the
  • 4. project folder. For the created file the analyzer will be started that will carry out the code check. After . which the results of the analyzer work will be set in the window of the ambience output Visual Studio 2005. Pay attention that you may carry out file analysis just for the platform x64. In case of file check for just another platform (for example, Win32) it will be sent a message about error. It means that for different platforms it is possible to use different ways of carrying out the program, which are set with the he of help the #ifdef/#endif constructions. As far as for Viva64 analyzer work is necessary to carry out preprocessing, so one should make sure that the file is compiled for the platform x64 correctly, without messages about errors. The usage of Viva64: detect, analysis and errors correction in the code To proceed directly with the errors detect at the open example PostSample one should choose "Check Current Project". Firstly, it will be started the preprocessor, and then the analyzer. The results of its work are shown in the output window (picture 3). e Picture 3: Output Window. And this is the first: error V101: Implicit assignment type conversion to memsize type. Let's look at the code in this place. unsigned imageWidth = 1000; unsigned imageHeght = 1000 1000; unsigned bytePerPixel = 3; unsigned maxFrameCountInBuffer;
  • 5. if (IsX64Platform()) { maxFrameCountInBuffer = 2000; } else { maxFrameCountInBuffer = 100; } size_t bufferSize = imageWidth * imageHeght * // 34 bytePerPixel * maxFrameCountInBuffer; The error is given on the line with the declaration of the variable bufferSize. We see that the variable maxFrameCountInBuffer for 64-bit platform has a value 2000. This is admissible, because after the multiplying of all the variables we expect to get 64-bit figure (buffer size), but ... we'll get only 32-bit one. As a result the variable bufferSize will never expend 4 Gb. Although it itself is a 64-bit type. Pay attention that the compiler gives nothing on this line even at the highest diagnostics level. And Viva64 says about the error here. If you are not sure that you absolutely realize the types digit capacity problem, push F4, and the embedded help system will be opened Viva64, where is given the detailed error description with the recommendations of its correction. Let's continue studying the example, so push F4 once more. Move to the message: error V102: Usage non memsize type for pointer arithmetic. Let's check the code which is at the line 71: int domainWidth; int domainHeght; int domainDepth; ... char *buffer; ... char *current = buffer; char *end = buffer; end += domainWidth * domainHeght * domainDepth; // 71 Here is another problem. From the error description we see that for the pointer arithmetic is used the type not intended for it. In this case the pointer arithmetic is carried out with 32-bit type int, but it should be used 64-bit one. Data types, using for the work with the pointers, and also for the keeping of the object sizes (for examples, arrays) in Viva64 are called memsize-types. At the reference system the memsize-types usage is examined carefully. Let's look in the help system how to correct the present error. Here are given advices how to change the types, which take part in such arithmetic. The example correction is in the change of the variable type
  • 6. domainWidth, domainHeigh, domainDepth for the type ptrdiff_t or in the usage of the explicit type conversation. In all the analyzer will give out more than dozens error messages at the PostSample project. And what is the compiler? The compiler Microsoft Visual C++ 2005 with the switched on diagnostics of the port problems (the key /Wp64) and the maximum level of the diagnostics messages (the key /W4) gives out for the entire project... only three diagnostics messages, that are also caught by the analyzer Viva64. This leads that the most errors stay undetected during the applications port on the 64-bit platform without using Viva64. Viva64's position in the process of the software working up There are two ways of Viva64 usage at the working up process: in the case of the prepared 32-bit application on the 64-bit platform and in the case of the working up new 64-bit application. The 32-bit application port should be carried out in such a way: • prepare the project in the Studio Visual 2005, which is build correctly for the platform Win32; • add a new platform x64 to the project, build the project, fixing all compiler errors; • switch on the maximum warning level (/Wp64, Detect 64-Bit Portability Issues), correct the errors; • with the help of Viva64 carry out all possible errors detect, analyze them and correct; • move to the application testing. In the case of a new 64-bit application enduring it is reasonable not to wait for the end of the working up, but to use Viva64 for the working up code control. Moreover one may check as well as the whole project or decision, and the separate more important code parts. Viva64 is not a silver bullet and what is next... It is necessary to notice that Viva64 doesn't solve all the problems, appearing at the 64-bit software enduring: • Viva64 can't replace full testing; • Viva64 knows about the most errors, but not about all; • Viva64 should be used by the developer, understanding all work computer principles. In other words, if you correct all the errors at the code with the help of Viva64, shouldn't consider that the application has been already prepared and it doesn't need diagnostics. Although Viva64 can really raise the quality of the working up software, enduce the error number and hasten the time of the product output at the market.