debug assertion error in threads of c++ under windows

Discussion in 'C++' started by Pushpa, Mar 9, 2007.

  1. Pushpa

    Pushpa Guest

    Hi All,

    This my part of the c++ program using threads in windows :

    //modified by pushpa
    struct structExrdDoc
    {
    CExrdDoc* spDoc;
    LPCTSTR sstrFileName;

    structExrdDoc():spDoc(NULL),sstrFileName(""){}
    };
    structExrdDoc sp;

    volatile bool running;

    UINT CExcelExport::run(LPVOID p)
    {
    CExrdDoc* me = sp.spDoc;
    me->OnSaveDocument ((LPCTSTR)sp.sstrFileName);
    running = FALSE;
    return 0;
    }
    //modified by pushpa

    void CExcelExport::SaveExcelFile (CExrdDoc* pDoc, const string&
    strFileName)
    {
    sp.spDoc = pDoc; //modified by pushpa
    sp.sstrFileName = strFileName.c_str(); //modified by pushpa
    running = TRUE; //modified by pushpa
    AfxBeginThread(run,NULL); //modified by pushpa
    //pDoc->OnSaveDocument (strFileName.c_str()); //modified by pushpa
    }


    Here the line of code I have commented was taking lot of time, so I hv
    tried to use
    threads and I am new to this.

    This is the declaration in the .h file

    static UINT CExcelExport::run(LPVOID p);

    After some struggle I could compile the application, but when it is
    run I am getting a
    Debug assertion error.

    debug assertion failed!
    program:d:\amsa\amsa\bin\gageanalysisdlld.exe
    file:wincore.cpp
    line:888
    for information on how your program can cause an assertion failure,
    see the visual c++

    documentation on asserts.

    Could you please help me with this.

    Thanking you in advance,
    Pushpa.
     
    Pushpa, Mar 9, 2007
    #1
    1. Advertising

  2. Pushpa

    Sarath Guest

    On Mar 9, 6:13 pm, "Pushpa" <> wrote:
    > Hi All,
    >
    > This my part of the c++ program using threads in windows :
    >
    > //modified by pushpa
    > struct structExrdDoc
    > {
    > CExrdDoc* spDoc;
    > LPCTSTR sstrFileName;
    >
    > structExrdDoc():spDoc(NULL),sstrFileName(""){}};
    >
    > structExrdDoc sp;
    >
    > volatile bool running;
    >
    > UINT CExcelExport::run(LPVOID p)
    > {
    > CExrdDoc* me = sp.spDoc;
    > me->OnSaveDocument ((LPCTSTR)sp.sstrFileName);
    > running = FALSE;
    > return 0;}
    >
    > //modified by pushpa
    >
    > void CExcelExport::SaveExcelFile (CExrdDoc* pDoc, const string&
    > strFileName)
    > {
    > sp.spDoc = pDoc; //modified by pushpa
    > sp.sstrFileName = strFileName.c_str(); //modified by pushpa
    > running = TRUE; //modified by pushpa
    > AfxBeginThread(run,NULL); //modified by pushpa
    > //pDoc->OnSaveDocument (strFileName.c_str()); //modified by pushpa
    >
    > }
    >
    > Here the line of code I have commented was taking lot of time, so I hv
    > tried to use
    > threads and I am new to this.
    >
    > This is the declaration in the .h file
    >
    > static UINT CExcelExport::run(LPVOID p);
    >
    > After some struggle I could compile the application, but when it is
    > run I am getting a
    > Debug assertion error.
    >
    > debug assertion failed!
    > program:d:\amsa\amsa\bin\gageanalysisdlld.exe
    > file:wincore.cpp
    > line:888
    > for information on how your program can cause an assertion failure,
    > see the visual c++
    >
    > documentation on asserts.
    >
    > Could you please help me with this.
    >
    > Thanking you in advance,
    > Pushpa.


    First of all if, possible remove the duplicate posts.

    CExrdDoc* me = sp.spDoc;
    me->OnSaveDocument ((LPCTSTR)sp.sstrFileName);

    I really dint get how you assigned sp

    Your code is not complete and run it in the debug mode. when the
    program crashes, just break there and check the call stack. From there
    you can identify which part of your code caused the problem.
     
    Sarath, Mar 9, 2007
    #2
    1. Advertising

  3. Pushpa

    Sarath Guest

    On Mar 9, 6:13 pm, "Pushpa" <> wrote:
    > Hi All,
    >
    > This my part of the c++ program using threads in windows :
    >
    > //modified by pushpa
    > struct structExrdDoc
    > {
    > CExrdDoc* spDoc;
    > LPCTSTR sstrFileName;
    >
    > structExrdDoc():spDoc(NULL),sstrFileName(""){}};
    >
    > structExrdDoc sp;
    >
    > volatile bool running;
    >
    > UINT CExcelExport::run(LPVOID p)
    > {
    > CExrdDoc* me = sp.spDoc;
    > me->OnSaveDocument ((LPCTSTR)sp.sstrFileName);
    > running = FALSE;
    > return 0;}
    >
    > //modified by pushpa
    >
    > void CExcelExport::SaveExcelFile (CExrdDoc* pDoc, const string&
    > strFileName)
    > {
    > sp.spDoc = pDoc; //modified by pushpa
    > sp.sstrFileName = strFileName.c_str(); //modified by pushpa
    > running = TRUE; //modified by pushpa
    > AfxBeginThread(run,NULL); //modified by pushpa
    > //pDoc->OnSaveDocument (strFileName.c_str()); //modified by pushpa
    >
    > }
    >
    > Here the line of code I have commented was taking lot of time, so I hv
    > tried to use
    > threads and I am new to this.
    >
    > This is the declaration in the .h file
    >
    > static UINT CExcelExport::run(LPVOID p);
    >
    > After some struggle I could compile the application, but when it is
    > run I am getting a
    > Debug assertion error.
    >
    > debug assertion failed!
    > program:d:\amsa\amsa\bin\gageanalysisdlld.exe
    > file:wincore.cpp
    > line:888
    > for information on how your program can cause an assertion failure,
    > see the visual c++
    >
    > documentation on asserts.
    >
    > Could you please help me with this.
    >
    > Thanking you in advance,
    > Pushpa.


    Your code is not complete and run it in the debug mode. when the
    program crashes, just break there and check the call stack. From there
    you can identify which part of your code caused the problem.
     
    Sarath, Mar 9, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cormac
    Replies:
    3
    Views:
    2,592
    Kevin Goodsell
    Apr 6, 2004
  2. Kapt. Boogschutter

    Debug Assertion Failed! and no obvious Error

    Kapt. Boogschutter, Jun 23, 2004, in forum: C++
    Replies:
    1
    Views:
    601
    red floyd
    Jun 23, 2004
  3. Pushpa
    Replies:
    0
    Views:
    331
    Pushpa
    Mar 9, 2007
  4. Pushpa
    Replies:
    1
    Views:
    435
    Scott McPhillips [MVP]
    Mar 9, 2007
  5. Joe Ardent
    Replies:
    1
    Views:
    351
Loading...

Share This Page