locked
app crashes when run in debugger RRS feed

  • Question

  • if my app is running without the debugger (not to be confused with debug and release mode) it works as expected.  if app is run in the debugger it will crash at the commented line. 

    void ChildDisplay::ReadNext(int iLength, String* sKey)

    {

    String* recbuff = S"";

    String* temp = S"";

    m_pMMDM->SetLL(NULL, sKey);

    m_pMMDM->ReadNext(NULL);

    for(int i=0; i < iLength; ++i)

    {

    m_pMMDM->ReadNext(NULL);

    recbuff = m_pMMDM->FormatBufferDisplayLine();

    //check for and skip duplicate entry

    temp = recbuff->Remove(recbuff->IndexOf('|'), (recbuff->Length)-(recbuff->IndexOf('|')));

    if(String::Equals(temp, sKey) == true)

    {

    m_pMMDM->ReadNext(NULL);

    recbuff = m_pMMDM->FormatBufferDisplayLine();

    }

    if(listBox1->Items->get_Count() > 0)

    {

    listBox1->Items->RemoveAt(0); //<--- crashes here when run by debugger

    listBox1->Items->Insert(listBox1->Items->get_Count(), recbuff);

    }

    }

    }

    Friday, December 9, 2005 10:33 PM

Answers

  • the problem was that i wasnt closing the database when i exited the app correctly. thanks for the help but i got this one on my own!
    Tuesday, December 13, 2005 6:49 PM

All replies

  • Is it a valid crash though? Should it crash? Are the values shown in the debugger explain any of the crash?

    Please include more info so that folks can help you!

    Thanks,
      Ayman Shoukry
      VC++ Team
    Friday, December 9, 2005 10:53 PM
  • the listbox has values in it. 

    listBox1->Items->RemoveAt(0)

    there is a valid value at index 0 in the listbox.  the crash doesnt occur right away either its after i have run used the app for a bit but it does crash at the same place or when i do the same thing while the program runs.  the app loads a database,  when i press the scrollbar down this function is called with an iLength value of 1 or 3.  after i have pressed the down a couple of times the app will crash at the same spot every time.  here are the changes that i have made since then to the same function

    void ChildDisplay::ReadNext(int iLength, String* sKey)

    {

    m_pMMDM->SetLL(NULL, sKey);

    m_pMMDM->ReadNext(NULL);

    for(int i=0; i < iLength; ++i)

    {

    String* recbuff = __gc new String(S"");

    String* temp = __gc new String(S"");

    m_pMMDM->ReadNext(NULL);

    recbuff = m_pMMDM->FormatBufferDisplayLine();

    //check for and skip duplicate entry

    temp = recbuff->Remove(recbuff->IndexOf('|'), (recbuff->Length)-(recbuff->IndexOf('|')));

    if(String::Equals(temp, sKey) == true)

    {

    m_pMMDM->ReadNext(NULL);

    recbuff = m_pMMDM->FormatBufferDisplayLine();

    }

    listBox1->Items->RemoveAt(0); //<--- crashes here when run by debugger

    listBox1->Items->Insert(listBox1->Items->get_Count(), recbuff);

    }

    }

     

    I thought that there might be a memory allocation problem so as you can see i have tried to fix that potential problem using new, but that didnt help at all.  what other additional info would you need to help me diagnose this problem?

    Monday, December 12, 2005 4:00 PM
  • this is the error that i am recieving

    An unhandled exception of type 'System.ExecutionEngineException' occurred in system.windows.forms.dll

    int APIENTRY _tWinMain(HINSTANCE hInstance,

    HINSTANCE hPrevInstance,

    LPTSTR lpCmdLine,

    int nCmdShow)

    {

    System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;

    Application::Run(new MDIContainer());

    return 0; <--debugger break

    }

    when i break into the app this is where it starts.  IF i put a break point in and step through it then the app crashes at the commented code that i have listed above at this line of code

    listBox1->Items->RemoveAt(0); //<--- crashes here when run by debugger

    Monday, December 12, 2005 4:09 PM
  • i am not sure if this could be the cause of my problems.

    String* aManagedMixDM::FormatBufferDisplayLine()

    {

    return FormatBufferDisplayLine(m_pDtf->m_no_fields,m_pDtf->m_buffer);

    }

    String* aManagedMixDM::FormatBufferDisplayLine(int nFields, IntPtr pBuffer)

    {

    IntPtr pIn = pBuffer;

    StringBuilder* sbline = new StringBuilder("");

    for( int i = 0 ; i < nFields ; i++ )

    {

    if(i != 0)

    sbline->Append("|");

    for(;;)

    {

    Byte by = Marshal::ReadByte(pIn);

    pIn = (IntPtr)((int)pIn + 1);

    if(by == 0)

    break;

    if(isprint(by)!= 0 )

    {

    Char c = (char) by;

    sbline->Append(c);

    }

    else

    sbline->Append(".");

    }

    }

    String* line = sbline->ToString();

    return line;

    }

    Monday, December 12, 2005 4:26 PM
  • new symptoms!  like i said earlier it runs the way its supposed to when not run by the debugger.  when i change the compile location to a different dir and then run with the debugger it runs fine the first time.  i think the database that i am opening is not being closed when the app is closed.
    Monday, December 12, 2005 7:18 PM
  • the problem was that i wasnt closing the database when i exited the app correctly. thanks for the help but i got this one on my own!
    Tuesday, December 13, 2005 6:49 PM