troubleshooting Question

The value of ESP was not properly saved across a function call

Avatar of mmingfeilam
mmingfeilam asked on
CC++
9 Comments1 Solution5586 ViewsLast Modified:
Hi,

i am keeping getting this error:

Debug Error !
Program : myfile.EXE
Module :
File : i386\chkesp.c
Line : 42
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."

this is the call stack:

TNSERVER! _chkesp + 46 bytes
ACE_Task<ACE_Thread_Mutex,ACE_Condition_Thread_Mutex>::putq(ACE_Message_Block * 0x009f2828, ACE_Time_Value * 0x00000000) line 40
CLogFile::log(e_log_level e_debug, const char * 0x0048dbb8 `string') line 142
CRequestMgr::svc() line 74 + 28 bytes
ACE_Task_Base::svc_run(void * 0x004a4018) line 254 + 11 bytes
ACE_Thread_Adapter::invoke_i() line 151 + 7 bytes
ACE_Thread_Adapter::invoke() line 95 + 11 bytes
ace_thread_adapter(void * 0x009e99c0) line 137 + 11 bytes
_threadstartex(void * 0x009e9a38) line 212 + 13 bytes
KERNEL32! 77e6608b()

this is the function:

int CLogFile::log(e_log_level level,const char *format, ...)
{
      char message[1024] = "";
      int ret = 0;
      va_list args;
      char serverName[256]="";
      ACE_TCHAR tmpValue[256];

      T_LOG_DATA log;

      /*ML-10/22/07*/
      try
      {
            ACE_OS::memset(&log, 0, sizeof(log));
            ACE_OS::memset(tmpValue,0,sizeof(tmpValue));

            /* check log level, only send configured type of log to logger */
            if ( m_glogLevel >= level )
            {
                  ret = CConfiguration::get_section_string((ACE_TCHAR*)GENERAL_SECTION,TNSERVER_NAME,tmpValue,256);
                  if ( ret < 0 ) //not found, just assign default name
                        ACE_OS::sprintf(serverName,"%s", APPLICATION_NAME);
                  else ACE_OS::sprintf(serverName,"%s",ACE_TEXT_ALWAYS_CHAR(tmpValue));

                  va_start( args, format );
                  _vsnprintf( message, sizeof(message), format,args );
                  va_end( args );

                  _snprintf( log.message, sizeof(log.message), "%s | %d.%d | %s\n",
                  serverName,TN_SERVER_MAJOR_VERSION,TN_SERVER_MINOR_VERSION,message );
                  log.logLevel = map_to_ace_error_type(level);
                  ACE_Message_Block *mb;

                  ACE_NEW_RETURN
                        (mb, ACE_Message_Block(sizeof(log)), -1);

                  ACE_OS::memcpy ( mb->wr_ptr (), &log, sizeof(log) );

                  m_plogMgr->putq( mb );
            
            }
      }
      catch(std::exception& e)
      {
            char exceptionbuff[150];
            strcpy(exceptionbuff, "EXCEPTION in CLogFile::log(): ");
            strcat(exceptionbuff, e.what());
            fprintf(stderr,"%s\n", exceptionbuff);
      }
      catch(...)
      {
            fprintf(stderr,"EXCEPTION in CLogFile::log()\n");
      }
      return 0;
}

and it's being called this way:

      try{

            CLogFile::log(e_debug, "Line:(%d),File:(%s), request_receiver():Entering",
                  __LINE__,__FILE__);

...

anyway, according to some online forums, it's due to:

Most probably its the different calling conventions you are using for the function exported from DLL and how you declare the function pointer to it.
but i don't see any different calling conventions, and i am not exporting the function from a dll.  can someone help me?
thanks.

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros