Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. crash on the end of release mode

crash on the end of release mode

Scheduled Pinned Locked Moved C / C++ / MFC
databasedebugginghelpannouncement
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    valerie99
    wrote on last edited by
    #1

    morning, this app runs fine on debug mode, but got access violation at the exiting dialog in release, I checked the thread, it was trying to close [CCallsmDbf::~CCallsmDbf]....here is part of the code that causing problem, but I am not sure what need to be fixed, thanks! CCallsmDbf::CCallsmDbf(char *dbfname, int exclusive) : CB_DBF_NTX(dbfname, exclusive) { if (validDBF()) { ptrIdxName = m_csIdxFile.GetBuffer( L_tmpnam + 1 ); GetTempFileName( ".", "callsm", 0, ptrIdxName ); index_on( ptrIdxName, "ANI" ); m_csIdxFile.ReleaseBuffer(); top(); BindFieldOrdinals(); } } CCallsmDbf::~CCallsmDbf() { } in header file, protected: CString m_csIdxFile; char* ptrIdxName;

    C 1 Reply Last reply
    0
    • V valerie99

      morning, this app runs fine on debug mode, but got access violation at the exiting dialog in release, I checked the thread, it was trying to close [CCallsmDbf::~CCallsmDbf]....here is part of the code that causing problem, but I am not sure what need to be fixed, thanks! CCallsmDbf::CCallsmDbf(char *dbfname, int exclusive) : CB_DBF_NTX(dbfname, exclusive) { if (validDBF()) { ptrIdxName = m_csIdxFile.GetBuffer( L_tmpnam + 1 ); GetTempFileName( ".", "callsm", 0, ptrIdxName ); index_on( ptrIdxName, "ANI" ); m_csIdxFile.ReleaseBuffer(); top(); BindFieldOrdinals(); } } CCallsmDbf::~CCallsmDbf() { } in header file, protected: CString m_csIdxFile; char* ptrIdxName;

      C Offline
      C Offline
      carks
      wrote on last edited by
      #2

      Hi, ptrIdxName = m_csIdxFile.GetBuffer( L_tmpnam + 1 ); This line looks dangerous! L_tmpnam may not be initialized. which would assign an unpredictable amount of mem. in release mode. The memory pointed to by ptrIdxName might easily be corrupted by the "GetTempFileName" call on the next line... the problem might only manifest itself when the class destructor deallocates the memory at object destruction time. Why not try a simpler way of doing this instead of GetBuffer/ReleaseBuffer like... TCHAR filename[MAX_PATH]; GetTempFileName( ,,, filename ); m_csIdxFile = filename; Cheers, Dave

      V 1 Reply Last reply
      0
      • C carks

        Hi, ptrIdxName = m_csIdxFile.GetBuffer( L_tmpnam + 1 ); This line looks dangerous! L_tmpnam may not be initialized. which would assign an unpredictable amount of mem. in release mode. The memory pointed to by ptrIdxName might easily be corrupted by the "GetTempFileName" call on the next line... the problem might only manifest itself when the class destructor deallocates the memory at object destruction time. Why not try a simpler way of doing this instead of GetBuffer/ReleaseBuffer like... TCHAR filename[MAX_PATH]; GetTempFileName( ,,, filename ); m_csIdxFile = filename; Cheers, Dave

        V Offline
        V Offline
        valerie99
        wrote on last edited by
        #3

        But it's still crashes at the same spot. when the access violation message show up, there were two threads [CCallsmDbf::~CCallsmDbf] and [CDialog::EndDialog], I gess the problem could be at the CDialog as well.... and it's not crash every single time of on release mode, every now and then it works...... thanks for your time!

        P 1 Reply Last reply
        0
        • V valerie99

          But it's still crashes at the same spot. when the access violation message show up, there were two threads [CCallsmDbf::~CCallsmDbf] and [CDialog::EndDialog], I gess the problem could be at the CDialog as well.... and it's not crash every single time of on release mode, every now and then it works...... thanks for your time!

          P Offline
          P Offline
          prasad_som
          wrote on last edited by
          #4

          Problem could be still suggested by Dave. I think one or more extra bits are accessed somewhere. Try to keep track of character pointer used. use strcpy() wherever needed, and with care

          V 1 Reply Last reply
          0
          • P prasad_som

            Problem could be still suggested by Dave. I think one or more extra bits are accessed somewhere. Try to keep track of character pointer used. use strcpy() wherever needed, and with care

            V Offline
            V Offline
            valerie99
            wrote on last edited by
            #5

            thanks for your info, here is another function that from same file, somehow, it's done deifferently..... CFavNatDbf::CFavNatDbf(int exclusive) : CB_DBF_NTX("DATA\\FAVNAT.DBF", exclusive) { if (validDBF()) { char* ptrIdxName = m_csIdxFile.GetBuffer( L_tmpnam + 1 ); GetTempFileName( ".", "favnat", 0, ptrIdxName ); _strupr( ptrIdxName ); memmove( ptrIdxName, ptrIdxName + 2, strlen( ptrIdxName ) - 2 ); *strstr( ptrIdxName, ".TMP" ) = '\0'; index_on( ptrIdxName, "CUST_NUM + LOCATION" ); m_csIdxFile.ReleaseBuffer(); top(); BindFieldOrdinals(); } } CFavNatDbf::~CFavNatDbf() { } void CFavNatDbf::BindFieldOrdinals() { }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups