-
March 5th, 2022, 03:47 AM
#1
App crash
VS2015 mfc app with a button click launches a thread. After thread exists and dialog's X on top right is clicked on, it closes and re-launches. The event viewer shows the event name APPCRASH. problem signature item 4 points to mfc140.dll.
-
March 5th, 2022, 09:13 AM
#2
Re: App crash
Originally Posted by @EE@
After thread exists ...
Did you mean "exists" or "exits"?
Victor Nijegorodov
-
March 5th, 2022, 11:46 AM
#3
Re: App crash
after thread exits. After all processing done. After X on the top right is clicked on to close the APP. After APP apparently closed, After a few seconds, it launches again on its own. checked the event viewer. Maybe a compatibility related between the DLL and APP?.
-
March 6th, 2022, 04:03 AM
#4
Re: App crash
How do you start your thread?
How does the thread exit?
What DLL do you mean? Are you using some external DLL? Which one?
PS. A peace of your actual code could be helpful to understand your problem.
Victor Nijegorodov
-
March 6th, 2022, 09:20 PM
#5
Re: App crash
this is the way I start my thread and get going to the end.
https://www.codeproject.com/Articles...d-to-terminate
-
March 6th, 2022, 10:19 PM
#6
Re: App crash
my application is multi tab application which uses tab tree control. The APPCRASH may not be related to start of the thread. I could not see any memory lean risk code. I use CREATE for each dialog in each tab.
-
March 7th, 2022, 02:05 AM
#7
Re: App crash
Originally Posted by @EE@
my application is multi tab application which uses tab tree control. The APPCRASH may not be related to start of the thread. I could not see any memory lean risk code. I use CREATE for each dialog in each tab.
How many threads are started in your application?
Does the every tab dialog start the thread?
How did you check whether all started threads successfully exit before closing your application?
Victor Nijegorodov
-
March 7th, 2022, 02:34 AM
#8
Re: App crash
only one thread get started in one of the tabs by clicking on a button. the rest are regular buttons.
-
March 7th, 2022, 03:23 AM
#9
Re: App crash
Originally Posted by @EE@
my application is multi tab application which uses tab tree control. The APPCRASH may not be related to start of the thread. I could not see any memory lean risk code. I use CREATE for each dialog in each tab.
And what about answering my other question?
Originally Posted by VictorN
How many threads are started in your application?
Does the every tab dialog start the thread?
How did you check whether all started threads successfully exit before closing your application?
Victor Nijegorodov
-
March 7th, 2022, 03:37 AM
#10
Re: App crash
How many threads are started in your application?
in one of the tabs only when a button is clicked on.
Does the every tab dialog start the thread?
click on a button
How did you check whether all started threads successfully exit before closing your application?
i follow something similar to this link:
https://www.codeproject.com/Articles...d-to-terminate
-
March 7th, 2022, 06:56 AM
#11
-
March 8th, 2022, 10:45 AM
#12
Re: App crash
this is the code i use to check for thread exit.
Code:
void CMyDlg::OnBnClickedButton()
{
m_pWinThread = AfxBeginThread(MyThreadFunc, (LPVOID)this);
DWORD ret;
do
{
ret = ::MsgWaitForMultipleObjects(1, &m_pWinThread->m_hThread, FALSE,
INFINITE, QS_ALLINPUT);
if (ret != WAIT_OBJECT_0)
{
if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
} while ((ret != WAIT_OBJECT_0) && (ret != WAIT_FAILED));
AfxMeesageBox("Done");
}
-
March 8th, 2022, 10:52 AM
#13
Re: App crash
Originally Posted by @EE@
this is the code i use to check for thread exit.
However, I asked you about the code showing how exactly you implemented the thread's exit.
And, BTW, do you create some handles within the thread that were not closed before exiting?
Victor Nijegorodov
-
March 9th, 2022, 05:07 AM
#14
Re: App crash
the thread includes a series of steps till it returns. The first step is to initialize the library. I moved it out of the thread and seems to resolve it. Not 100% sure yet. Need to do more testing. Not sure why this would help if moved out of the thread function. I am passing 0 or NULL instead of this object.
I do not create handles, no.
-
March 9th, 2022, 05:19 AM
#15
Re: App crash
1. How exactly does the thread exit? Note that the best way to exit for a worker thread is just to return from the thread procedure. If the thread has no idea about when it has to exit then the main thread has to notify it (usually by setting an Event) about it!
2. What type of the library do you initialize within the thread? Does the library need to be "uninitialized" (or to be closed / cleaned up / ...)?
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|