Tuesday, July 29, 2008

Application Crashing Problem in Release version in VC++ with Map File

Application Crashing Problem in Release version in VC++:
-------------------------------------------------------------------------


Crash is as follows:

Data Abort: Thread=8dac8ba4 Proc=8037c870 'TestApp.exe'
AKY=ffffffff PC=78a3e118(image_proc.dll+0x0001e118) RA=00013178(StreamingPlayer.exe+0x00003178) BVA=241dc35e FSR=00000807

Data Abort: Thread=8d89dc34 Proc=8037c870 'TestApp.exe'

AKY=ffffffff PC=78a3e118(image_proc.dll+0x0001e118) RA=00013178(StreamingPlayer.exe+0x00003178) BVA=241dc35e FSR=00000807

Unhandled exception at 0x78a3e118 in TestApp.exe: 0xC0000005: Access violation writing location 0x001dc35e.

Data Abort: Thread=8d739000 Proc=8037c960 'wmplayer.exe'

AKY=ffffffff PC=7894e118(imageLib.dll+0x0001e118) RA=00013178(wmplayer.exe+0x00003178) BVA=260ec35e FSR=00000807








if we are building our application in release version, at client side it crashed with some address;
How can we trace which function is failed and locate where the error is ?


1.Solution for the above thing is to make use of .map file


.map file content sample:
---------------------------
imageLib
Timestamp is 488496e7 (Mon Jul 21 19:32:15 2008)
Preferred load address is 10000000


Start Length Name Class
0001:00000000 000004bcH gTest CODE
0002:00000000 00000e30H Addition CODE

Address Publics by Value Rva+Base Lib:Object

0000:00000000 ___safe_se_handler_table 00000000
0000:00000000 ___safe_se_handler_count 00000000
0001:00000000 RGB565toYUV420 10001000 ColorConversion.obj
0002:00000000 UYVYtoRGB565 10002000 ColorConversion.obj
0002:000003d4 Rotate 100023d4 ImageOps.obj
0002:00000660 Blur 10002660 ImageOps.obj


Static symbols

0010:0000417c Init 1001517c f InitOps.obj






Crash will throw some address which caused the problem;




There are two types of crash;Crash may be in executables or may be in DLLs;



Solution for Crash in Executable Application:
------------------------------------------

Example:
---------
AKY=ffffffff PC=7894e118(TestApp.exe 0x1001e118) Data abort

if it is executables, the Solution is as follows:


0x1001e118 - is a Crash Address;


Function Address = Crash Address - Preferred Load Address in Map file - 0x1000 ( For Portable Executable File Format Infos) ;


Solution for Crash in DLL:
-----------------------------


AKY=ffffffff PC=7894e118(imageLib.dll+0x0002478) RA=00013178(wmplayer.exe+0x00003178)


ImageLib.dll + 0x0001e118 means

Crash Address = Preferred Load address in Map File + Crash Address;
= 10000000 + 2478
= 10002478 This Crash Address is in between Rotate and Blur Function;
So the crash is in Rotate function;





Preferred load address is 10000000
0002:000003d4 Rotate 100023d4 ImageOps.obj
0002:00000660 Blur 10002660 ImageOps.obj


Note:
--------
100023d4 - Starting Address of the Rotate() fn
( Rotate fn code occupies memory range from 100023d4 to 1000265F )
10002660 - Starting Address of the Blur() fn



Creation of a Map File in Vs2005:
--------------------------------------------------

At the time of building the project, if we specified this macro

/MAP[:file name] will leads to create the map file ;




/MAP (Generate Mapfile)


/MAP[:filename]
Remarks
where:

filename
A user-specified name for the mapfile. It replaces the default name.

Remarks
The /MAP option tells the linker to create a mapfile.

By default, the linker names the mapfile with the base name of the program and the extension .map. The optional filename allows you to override the default name for a mapfile.

A mapfile is a text file that contains the following information about the program being linked:

The module name, which is the base name of the file

The timestamp from the program file header (not from the file system)

A list of groups in the program, with each group's start address (as section:offset), length, group name, and class

A list of public symbols, with each address (as section:offset), symbol name, flat address, and .obj file where the symbol is defined

The entry point (as section:offset)

The /MAPINFO option specifies additional information to be included in the mapfile.

To set this linker option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.

Click the Linker folder.

Click the Debug property page.

Modify the Generate Map File property

No comments: