Click here to Skip to main content
Sign Up to vote bad
good
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 - 18:48
Edited 24 Apr '12 - 18:52

Comments
SAKryukov - 25 Apr '12 - 0:49
What is "debug error"? --SA

2 solutions

can you identify the line where the error occurs?
  Permalink  
Comments
Tony Joy - 26 Apr '12 - 0:29
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 - 26 Apr '12 - 0:30
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.
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 - 26 Apr '12 - 9:11
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 - 26 Apr '12 - 9:29
how are you #including the zLib header?
Tony Joy - 26 Apr '12 - 9:38
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 - 26 Apr '12 - 9:40
when you #include "zlib.h", are you doing this: #ifdef __cplusplus extern "C" { #endif #include "zlib.h" #ifdef __cplusplus } #endif ?
Tony Joy - 26 Apr '12 - 9:49
i added include 'zlib.h' in header file. also #ifdef __cplusplus extern "C" { #endif .still error occurs .
Chris Losinger - 26 Apr '12 - 10:02
are you using any other (non-MS) external libraries ? (statically linked)
Tony Joy - 26 Apr '12 - 10:03
using like basesd.h and zconf.h
Chris Losinger - 26 Apr '12 - 10:06
did you build the copy of zlib.dll that you are using?
Tony Joy - 26 Apr '12 - 10:10
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 - 26 Apr '12 - 10:26
can you try commenting-out just the calls to zlib ?
Tony Joy - 26 Apr '12 - 10:28
can u brief commenting calls to zlib means?
Chris Losinger - 26 Apr '12 - 10:47
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 - 26 Apr '12 - 10:38
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 - 26 Apr '12 - 10:50
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 - 26 Apr '12 - 11:05
can you show me the link that you downloaded?
Tony Joy - 27 Apr '12 - 7:26
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 - 27 Apr '12 - 7:28
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 - 27 Apr '12 - 9:02
still error exist even i build latest verison of zlib files/dll?
Chris Losinger - 27 Apr '12 - 9:08
what preprocessor symbols are you defining when you build zlib, and which are you defining when you build your project?
Tony Joy - 27 Apr '12 - 9:20
#include "zlib.h"
Chris Losinger - 27 Apr '12 - 9:30
go to Project / Settings / C|C++ . do you you have anything in the "Preprocessor definitions" field?
Tony Joy - 30 Apr '12 - 1:38
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 - 30 Apr '12 - 5:07
Chris,If i run the same project in Qt4.7 version ,it is running sucesfully with 0utany eroors.
Tony Joy - 3 May '12 - 8:14
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
Your Filters
Interested
Ignored
     
0 OriginalGriff 206
1 Richard MacCutchan 145
2 Tadit Dash 140
3 Sergey Alexandrovich Kryukov 135
4 Santhosh G_ 125
0 Sergey Alexandrovich Kryukov 10,294
1 OriginalGriff 7,955
2 CPallini 4,201
3 Rohan Leuva 3,522
4 Maciej Los 3,159


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 26 Apr 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid