Click here to Skip to main content
15,895,084 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: SandCastle Help Builder with C++ Dynamic DLL (MFC) Pin
Member 437978321-Aug-09 0:50
Member 437978321-Aug-09 0:50 
QuestionDefault type Pin
thelonesquirrely20-Aug-09 7:59
thelonesquirrely20-Aug-09 7:59 
AnswerRe: Default type Pin
Graham Shanks20-Aug-09 8:11
Graham Shanks20-Aug-09 8:11 
AnswerRe: Default type Pin
Maximilien20-Aug-09 8:19
Maximilien20-Aug-09 8:19 
GeneralRe: Default type Pin
thelonesquirrely20-Aug-09 8:22
thelonesquirrely20-Aug-09 8:22 
GeneralRe: Default type Pin
Maximilien20-Aug-09 9:08
Maximilien20-Aug-09 9:08 
QuestionDoxygen help Pin
Pabolo20-Aug-09 7:35
Pabolo20-Aug-09 7:35 
QuestionDebugging Multiple Threaded App - Throwing Unhandled Exeception Pin
CodeMacDaddy20-Aug-09 4:44
CodeMacDaddy20-Aug-09 4:44 
I'm debugging a Microsoft Visual C++ 2003 SDI/MFC windows app I have created. My app is using a 3rd party C++ library(DLL) for CAN msg communication. When my app starts it calls a 3rd party lib API which creats a new thread for handling CAN comm msg handling. The problem right now is that after many hours of running the app crashes with unhandled exception 0x7c90120e : user breakpoint. In the debugger output window it shows:
HEAP: Free Heap block 0x3f4e60 modified at 0x3f4e88 after it was freed.

I believe the 3rd party thread is attempting to access memory that was previously deallocated. The call stack looks like this:

ntdll.dll!7c90120e()
ntdll.dll!7c96e139()
.
.
kernel32.dll!7c80b7d0()

The threads window shows:
2024 WinMain guGetRxDataFrame <- my app function
=>2140 Win32 Thread 7c90120e <- this thread my by lib code

1) I believe the app is crashing because of the 3rd party lib
thread based on the debug info I provided above. Is my
understanding correct ? Also my code is not doing new/delete
operations but the lib code is.

2) I have access to the 3rd party lib code and have been
reviewing this "steaming pile" of poorly written code.
In it they are doing set_new_handler to install a user
function that is called when new operation fails. In the user
function they are doing throw std::bad_alloc(). I have added
try/catch(... ) in my code. In a multiple thread application
if the child thread crashes or throws an exceptoin how can my
parent thread "trap" the exception ? Is this possible ? I would like to do this so I can execute one of my user function to do some cleanup before exiting the app by installing a handler with set_terminate. I know this won't fix the root cause but I need to handle these kind of errors in my app anyways.

3) Is is possible to add a user function like set_new_handler() for the delete [] operation ? The 3rd party lib code is doing a new operation when executing a class constructor. They don't even check if the new operation was successful. Then in the class destructor they are doing a delete [] operation without even checking of the memory pointer in not NULL !!! crazy code, extremely bad. For example

4) If the child thread is leaking memory is there a way I can call function periodically to dump info to the debug window to see if memory is being chewed up over time such as CrtDumpMemoryLeaks() ?
Will setting up a time to execute CrtDumpMemoryLeaks() provide any useful info ?

Baga::Baga()
{
m_buffer = new dgUint8[MAXGFRAME];
m_framelen = sizeof( struct gframehdr );
m_gframehdr = (struct gframehdr *) m_buffer;
}

Baga::~Baga()
{
delete[] m_buffer; <- shouldn't they be check that
m_buffer is not NULL before attempting
this operation ????
}

I wish I could compile/link in the 3rd party lib code but I cannot.
This is my first debug of a multi-thread app. Need help in trying to figure out the root cause of this issue. Any other things I can try to help diagnose this problem ? Sorry, complex problem, so long email Frown | :(

These problems suck but I have already learned so much from this forum and the web in trying to attack this problem.

Suspicious | :suss:
AnswerRe: Debugging Multiple Threaded App - Throwing Unhandled Exeception Pin
Roger Stoltz20-Aug-09 6:01
Roger Stoltz20-Aug-09 6:01 
GeneralRe: Debugging Multiple Threaded App - Throwing Unhandled Exeception Pin
CodeMacDaddy20-Aug-09 8:14
CodeMacDaddy20-Aug-09 8:14 
AnswerRe: Debugging Multiple Threaded App - Throwing Unhandled Exeception Pin
Roger Stoltz20-Aug-09 22:19
Roger Stoltz20-Aug-09 22:19 
GeneralRe: Debugging Multiple Threaded App - Throwing Unhandled Exeception Pin
CodeMacDaddy21-Aug-09 8:30
CodeMacDaddy21-Aug-09 8:30 
AnswerRe: Debugging Multiple Threaded App - Throwing Unhandled Exeception Pin
KarstenK20-Aug-09 21:38
mveKarstenK20-Aug-09 21:38 
GeneralRe: Debugging Multiple Threaded App - Throwing Unhandled Exeception Pin
CodeMacDaddy21-Aug-09 8:31
CodeMacDaddy21-Aug-09 8:31 
QuestionOpening new document type in existing frame window Pin
Member 268155320-Aug-09 3:46
Member 268155320-Aug-09 3:46 
Questioncommunicate between 2 different applications using CORBA Pin
sola7720-Aug-09 1:44
sola7720-Aug-09 1:44 
AnswerRe: communicate between 2 different applications using CORBA Pin
Adam Roderick J20-Aug-09 1:48
Adam Roderick J20-Aug-09 1:48 
GeneralRe: communicate between 2 different applications using CORBA Pin
sola7720-Aug-09 1:54
sola7720-Aug-09 1:54 
GeneralRe: communicate between 2 different applications using CORBA [modified] Pin
Adam Roderick J20-Aug-09 2:39
Adam Roderick J20-Aug-09 2:39 
AnswerRe: communicate between 2 different applications using CORBA Pin
Cedric Moonen20-Aug-09 2:00
Cedric Moonen20-Aug-09 2:00 
GeneralRe: communicate between 2 different applications using CORBA Pin
sola7720-Aug-09 2:10
sola7720-Aug-09 2:10 
GeneralRe: communicate between 2 different applications using CORBA Pin
Cedric Moonen20-Aug-09 2:15
Cedric Moonen20-Aug-09 2:15 
GeneralRe: communicate between 2 different applications using CORBA Pin
sola7720-Aug-09 2:21
sola7720-Aug-09 2:21 
GeneralRe: communicate between 2 different applications using CORBA Pin
Cedric Moonen20-Aug-09 2:26
Cedric Moonen20-Aug-09 2:26 
GeneralRe: communicate between 2 different applications using CORBA Pin
sola7720-Aug-09 2:33
sola7720-Aug-09 2:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.