Re: Thread exiting with code 1282 (0x502)
- From: "Patricio" <Patricio@xxxxxxxxxxxxxxxxx>
- Date: Wed, 7 Feb 2007 17:39:40 -0500
Hello Charles,
I found the problem and it seems a very basic error (see reply to Joe). Anyway, suggestions about improving my OnToolTipNotify are welcome.
Thank you,
Patricio.
"Patricio" <Patricio@xxxxxxxxxxxxxxxxx> wrote in message news:EF411E2B-D19C-49BB-B821-F8389FE9F4A6@xxxxxxxxxxxxxxxx
Hello Charles,.
Thank you for your answer.
As I mentioned to Joe, the application exits when I display a dialog that contains text boxes (actually they are CComboBox)with some large strings. I am using Visual Studio 2005 and I have the trapping of all the exceptions enabled. I start debugging with VS2005, interact with the application so that it displays a properties dialog for one of the graphics objects we have, then I click on a button (of the properties dialog) that displays another dialog with four Combo Boxes.
The sequence of crashing was:
1.- Combo Box had short text and then I entered the new string that is a lot longer than before.
2.- Application stays open for about 2 seconds and then exits. I restart debugging again...
3.- I get to the Combo Box again and I enter the new long string and this time I quickly press "OK" and save the object. No problems here. Application continues to run.
4.- I start debugging the application again and now when the dialog with the Combo Box is displayed for anywhere from 2 to 30 seconds then the application freezes for about 3 seconds and then exits to VS with only the exit error messages I copied in the first e-mail.
At the beginning I thought that some of the application code that uses the string was being executed but none of the breakpoints in the code were hit (this is what I expected because the dialog is modal and I assume only MFC/Windows is running when the dialog is waiting for input).
...
Ok. I found the offending method: BOOL CSimpleLineDlg::OnToolTipNotify(UINT, NMHDR* pNMHDR, LRESULT*). Now it makes sense, only when I put the cursor for a couple of seconds over the Combo Box this method is called.
Now I have to figure out why this method crashes:
BOOL CSimpleLineDlg::OnToolTipNotify(UINT, NMHDR* pNMHDR, LRESULT*)
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
UINT nID = pNMHDR->idFrom;
if (pTTT->uFlags & TTF_IDISHWND)
{
// idFrom is actually the HWND of the tool
nID = ::GetDlgCtrlID((HWND)nID);
if(nID)
{
CWnd * pWnd = (CWnd *)GetDlgItem(nID);
pWnd->GetWindowText(pTTT->szText, sizeof(pTTT->szText));
pTTT->hinst = AfxGetResourceHandle();
return(TRUE);
}
}
return(FALSE);
}
Is this the appropriate implementation of this method?
I see that the size of pTTT->szText is 80 so that could be the issue?!? but the GetWindowText() method should handle that.
If I just return(FALSE) when I enter the method then everything works ok (no tooltip of course).
Please let me know if the implementation of OnToolTipNotify() should be different.
Thank you,
Patricio.
"Charles Wang[MSFT]" <changliw@xxxxxxxxxxxxxxxxxxxx> wrote in message news:my8GFuoSHHA.3872@xxxxxxxxxxxxxxxxxxxxxxxxxHi Patricio,
From your description, I understand that:
Your application exited with the code 1282 when it was starting. You found
that this issue started to happen when some strings started to become very
large.
You would like to know how to debug your MFC application now.
If I have misunderstood, please let me know.
If you had Visual Studio IDE, you can use breakpoint debugging as mentioned
in Joe's reply;
Also, you can use Windbg.exe to debug your application.
I would like to provide the following links for your reference:
How to debug application crash/hang in production environment?
http://blogs.msdn.com/msdnts/archive/2006/11/24/how-to-debug-application-cra
sh-hang-in-production-environment.aspx
Windows Debuggers: Part 1: A WinDbg Tutorial
http://www.codeproject.com/debug/windbg_part1.asp
Also, from the error code 1282, it means that the system detected an
overrun of a stack-based buffer in this application. This overrun could
potentially allow a malicious user to gain control of this application.
(Ref: http://msdn2.microsoft.com/en-us/library/ms681383.aspx )
I would like to know:
Were there many large objects allocated on stack rather than heap in your
application?
I recommend that you check your application and ensure that large objects
are allocated on heap.
Hope this helps. If you have any other questions or concerns, please feel
free to let me know.
Sincerely yours,
Charles Wang
Microsoft Online Community Support
======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
- Follow-Ups:
- Re: Thread exiting with code 1282 (0x502)
- From: Charles Wang[MSFT]
- Re: Thread exiting with code 1282 (0x502)
- References:
- Thread exiting with code 1282 (0x502)
- From: Patricio
- RE: Thread exiting with code 1282 (0x502)
- From: Charles Wang[MSFT]
- Re: Thread exiting with code 1282 (0x502)
- From: Patricio
- Thread exiting with code 1282 (0x502)
- Prev by Date: Re: How to export afunction in class?
- Next by Date: What is this window type ?
- Previous by thread: Re: Thread exiting with code 1282 (0x502)
- Next by thread: Re: Thread exiting with code 1282 (0x502)
- Index(es):
Loading