Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC6
Program:my.exe
debug error File i386\chkesp.c
Line 42
The valueof ESP was not properly saved across fucntion call.This is usally a result of calling a fucntion declared with one calling convention with a function pointer
declared witha declared calling convention..
 
In C/C++ settings it is _cdecl convention.
 
the code is which i am coverting bmp to png format
 
char *inBuffer = new char[inStreamSize];
 
        uncompressedBufferSize = inStreamSize*40;
        unCompressedBuffer = new char[uncompressedBufferSize];
 
        inFile.read (inBuffer, inStreamSize);
        //inStreamSize = inFile.gcount();

        zs = new z_stream;
        zs->next_in   = (unsigned char *)inBuffer;  //point to beginning of compressed file
        zs->avail_in  = inFile.gcount();                   //specify the size of the compressed file
        zs->next_out  = (unsigned char *)unCompressedBuffer;  //point to where the uncompressed file will be
        zs->avail_out = uncompressedBufferSize;   //specify size of buffer to hold uncompressed file
        zs->zalloc    = (alloc_func)0;
        zs->zfree     = (free_func)0;
        zs->data_type = Z_BINARY;
 
        ret = inflateInit(zs);
 

 
        ret = inflate(zs, Z_FINISH);
        if(ret != Z_OK && ret != Z_STREAM_END)
        {
            AfxMessageBox("Failed to decompress file");
             inFile.close();
             outFile.close();
            return TRUE;
        }
 
        ret = inflateEnd (zs);
 

        if(ret == Z_OK)
        {
            outFile.write (unCompressedBuffer, zs->total_out);
            m_ctrlFileProgress.StepIt();
            CreateBMPFiles(unCompressedBuffer, zs->total_out);
            m_ctrlFileProgress.StepIt();
        //  m_ctrlFileProgress.StepIt();
            CreateLogFile(unCompressedBuffer);
            m_ctrlFileProgress.StepIt();
 
        }
//cleanup:
         inFile.close();
             outFile.close();
 
        delete [] zs;
        delete[] unCompressedBuffer;
        delete[] inBuffer;
 

    }
    m_ctrlFileProgress.SetPos(4);
    SetDlgItemText(IDC_PROGRESS_TEXT, "1 File Converted");
    AfxMessageBox("Decompression Complete");
 
    return TRUE;
}
after this the error occurs.
Posted 24-Apr-12 19:48pm
Roja_25290
Edited 24-Apr-12 19:52pm
v3
Comments
SAKryukov at 25-Apr-12 0:49am
   
What is "debug error"?
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

can you identify the line where the error occurs?
  Permalink  
Comments
Tony Joy at 26-Apr-12 0:29am
   
Message displays correct like "Decompression Complete",after that come out of this loop and error message displays
 
Program:my.exe
debug error File i386\chkesp.c
Line 42
The valueof ESP was not properly saved across fucntion call.This is usally a result of calling a fucntion declared with one calling convention with a function pointer
declared witha declared calling convention..
Tony Joy at 26-Apr-12 0:30am
   
this is what displays in call stack
 

1023325A push edx
1023325B push ebx
1023325C push esi
1023325D push edi
1023325E push offset string "The value of ESP was not properl"... (10258b28)
10233263 push offset string "" (10256788)
10233268 push 2Ah
1023326A push offset string "i386\\chkesp.c" (10258b18)
1023326F push 1
10233271 call _CrtDbgReport (10214eb0)
10233276 add esp,14h
10233279 cmp eax,1
1023327C jne __chkesp+2Fh (1023327f)
1023327E int 3
1023327F pop edi
10233280 pop esi
10233281 pop ebx
10233282 pop edx
10233283 pop eax
10233284 mov esp,ebp
10233286 pop ebp
10233287 ret
10233288 push esi
10233289 inc ebx
1023328A xor dword ptr [eax],esi
1023328C pop eax
1023328D inc ebx
1023328E xor byte ptr [eax],dh
__except_handler2:
10233290 push ebp
10233291 mov ebp,esp
10233293 sub esp,8
10233296 push ebx
10233297 push esi
10233298 push edi
10233299 push ebp.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

as the error message says, this usually happens when you call an external library using the wrong calling convention.
 
i don't see anything obviously wrong with the code you've shown here. double-check the function declarations for any DLLs you're using.
  Permalink  
Comments
Tony Joy at 26-Apr-12 9:11am
   
Will zlib.dll makes difference in this which iam using 1.4 version here and it should be compatible.is it true ?confirm. Other than zlib.dll i am not using any DLL.
Chris Losinger at 26-Apr-12 9:29am
   
how are you #including the zLib header?
Tony Joy at 26-Apr-12 9:38am
   
I am adding in external dependencies zlib files zlib.h file.
 
2) in vc6.0 settings->links>library/modules options ->i am adding zlib.lib
Chris Losinger at 26-Apr-12 9:40am
   
when you #include "zlib.h", are you doing this:
 

#ifdef __cplusplus
extern "C" {
#endif
#include "zlib.h"
#ifdef __cplusplus
}
#endif
 

?
Tony Joy at 26-Apr-12 9:49am
   
i added include 'zlib.h' in header file. also #ifdef __cplusplus
extern "C" {
#endif
.still error occurs .
Chris Losinger at 26-Apr-12 10:02am
   
are you using any other (non-MS) external libraries ? (statically linked)
Tony Joy at 26-Apr-12 10:03am
   
using like basesd.h and zconf.h
Chris Losinger at 26-Apr-12 10:06am
   
did you build the copy of zlib.dll that you are using?
Tony Joy at 26-Apr-12 10:10am
   
yes.
 
also i observed if comment following lines like
/* zs->next_in = (unsigned char *)inBuffer; //point to beginning of compressed file
zs->avail_in = inFile.gcount(); //specify the size of the compressed file
zs->next_out = (unsigned char *)unCompressedBuffer; //point to where the uncompressed file will be
zs->avail_out = uncompressedBufferSize; //specify size of buffer to hold uncompressed file
zs->zalloc = (alloc_func)0;
zs->zfree = (free_func)0;
zs->data_type = Z_BINARY;
 
ret = inflateInit(zs);

 

ret = inflate(zs, Z_FINISH);
if(ret != Z_OK && ret != Z_STREAM_END)
{
AfxMessageBox("Failed to decompress file");
inFile.close();
outFile.close();
return TRUE;
}
 
ret = inflateEnd (zs);


if(ret == Z_OK)
{
outFile.write (unCompressedBuffer, zs->total_out);
m_ctrlFileProgress.StepIt();
CreateBMPFiles(unCompressedBuffer, zs->total_out);
m_ctrlFileProgress.StepIt();
// m_ctrlFileProgress.StepIt();
CreateLogFile(unCompressedBuffer);
m_ctrlFileProgress.StepIt();

}
//cleanup:
inFile.close();
outFile.close();
*/
 
error do not occur.
Chris Losinger at 26-Apr-12 10:26am
   
can you try commenting-out just the calls to zlib ?
Tony Joy at 26-Apr-12 10:28am
   
can u brief commenting calls to zlib means?
Chris Losinger at 26-Apr-12 10:47am
   
the zlib calls are inflate, inflateInit, inflateEnd.
 
if commenting those out eliminates the crash, then the problem is probably that the zlib functions are not being exported from the DLL with the calling convention that your application expects.
 
what did you do to get zlib to compile as a DLL?
Tony Joy at 26-Apr-12 10:38am
   
i comented lines mentioned below here error not comming.
other than this lines if i comment error comes occurs and application crash.
/* ret = inflateInit(zs);
 
ret = inflate(zs, Z_FINISH);
if(ret != Z_OK && ret != Z_STREAM_END)
{
AfxMessageBox("Failed to decompress file");
inFile.close();
outFile.close();
return TRUE;
}
 

ret = inflateEnd (zs);
*/
Tony Joy at 26-Apr-12 10:50am
   
i had downloaded zlib sources frm zlib website with version required to get the zlib.dll.Also i builed and compiled andthere is no errors in zlib
Chris Losinger at 26-Apr-12 11:05am
   
can you show me the link that you downloaded?
Tony Joy at 27-Apr-12 7:26am
   
http://www.zlib.net/
 

surely error is within these functions inflate, inflateInit, inflateEnd.
here it is not considering.
can you tell me how to delete zlib.h in external dependcies folder and add new version to the dsw
Chris Losinger at 27-Apr-12 7:28am
   
you can't delete anything from the external dependencies folder. that folder is just to show you the files that have been included based on your #include statements and the include paths you've defined.
Tony Joy at 27-Apr-12 9:02am
   
still error exist even i build latest verison of zlib files/dll?
Chris Losinger at 27-Apr-12 9:08am
   
what preprocessor symbols are you defining when you build zlib, and which are you defining when you build your project?
Tony Joy at 27-Apr-12 9:20am
   
#include "zlib.h"
Chris Losinger at 27-Apr-12 9:30am
   
go to Project / Settings / C|C++ . do you you have anything in the "Preprocessor definitions" field?
Tony Joy at 30-Apr-12 1:38am
   
while compiling zlib files,preprocessor definationa field having below mentioned.DEBUG,DYNAMIC_CRC_TABLE,NO_GZIP,WIN32,_LIB
.
Where as in my project the preprocessor defination field having below mentioned
WIN32,_DEBUG,_WINDOWS,_AFXDLL,_MBCS,_LIB
Tony Joy at 30-Apr-12 5:07am
   
Chris,If i run the same project in Qt4.7 version ,it is running sucesfully with 0utany eroors.
Tony Joy at 3-May-12 8:14am
   
any updates on this error?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 428
1 Maciej Los 249
2 BillWoodruff 199
3 /\jmot 180
4 Suraj Sahoo | Coding Passion 150
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 26 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100