I have created a MFC exe using VC++ .NET 2003 on Windows XP Prof
service pack 2 and it works properly on my machine, but when I run the
same exe on a different machine (Windows XP Prof SP-2), The application
is bought up and after some time its throwing a windows xp error dialog
box saying,
I am also running the same application on 2 more machines there
everything works fine.
Here is thr Windows XP error dialog box that appreas when its crashed
TODO: <File descriptionhas encountered a problem and needs to close.
We are sorry for any inconenience.
If you are in the middle of something, the information you were working
on might be lost.
Please tell Microsoft about this problem.
blab blah....
I have function called OnNotifyNewData (WPARAM wParam, LPARAM lParam)
which appreas to be cauing the problem. When I run the application
commenting this function its didnt crashed.
LRESULT CUserViewFrame: :OnNotifyNewDat a (WPARAM wParam, LPARAM lParam)
{
const char* strVariable("CU serViewFrame::O nNotifyNewData START");
const char* strValue("6");
CUtility::LogDe bugInfo( strVariable, strValue);
WRITE_LOG_FUNCT ION_ENTRY("LRES ULT CUserViewFrame: :OnNotifyNewDat a
(WPARAM wParam, LPARAM lParam)")
PInstData pInstData = (PInstData)wPar am;
if (!pInstData) return 0;
CString csText;
char buffer[255];
LVFINDINFO info;
int iIndex = 0;
PSystemSetting pSystemSetting = CSystemSetting: :GetObject();
info.flags = LVFI_WRAP|LVFI_ STRING;
std::vector<CMa rketData>::cons t_iterator iter;
std::vector<CPa rticipant>::con st_iterator iterpart;
const std::vector<CMa rketData& userListBid =
pInstData->GetMarketDataB id();
for (iter = userListBid.beg in(); iter != userListBid.end (); iter++)
{
const std::vector<CPa rticipant& participants =
iter->GetParticipant s();
for (iterpart = participants.be gin(); iterpart !=
participants.en d();
iterpart++)
{
if (iterpart->GetSize() 0.0 && iter->GetPrice()
0.0){
memset(&buffer, 0, sizeof(buffer)) ;
if (sizeof(iterpar t->GetUserName( )/*.c_str()*/) 255
continue;
//sprintf(buffer, "%s",
iterpart->GetUserName( )/*.c_str()*/);
info.psz = iterpart->GetUserName( );
iIndex = m_ctrlUserListC trl.FindItem(&i nfo);
if (iIndex == -1)
{ // insert the item
iIndex = m_ctrlUserListC trl.GetItemCoun t();
if (sizeof(iterpar t->GetUserName( )/*.c_str()*/)
255continue;
//csText.Format(T EXT("%s"),
iterpart->GetUserName( )/*.c_str()
csText = iterpart->GetUserName( ); //Sanjeev
012407
int size = iterpart->GetUserName(). GetLength();
char bufsize[20];
memset(&bufsize , 0, sizeof(bufsize) );
_itoa(size,bufs ize,10);
CUtility::LogDe bugInfo( "OnNotifyNewDat a - BID
UserName", bufsize);
m_ctrlUserListC trl.InsertItem( LVIF_TEXT|LVIF_ STATE, iIndex, csText,
0,
LVIS_SELECTED, 0, 0);
char * pchText = new char [csText.GetLengt h() +
1];
strcpy(pchText, (LPCTSTR)csText );
m_ctrlUserListC trl.SetItemData (iIndex,
(DWORD)pchText) ;
}
if
(sizeof(pInstDa ta->GetInstName( )/*.c_str()*/) 255)
continue;
//csText.Format(T EXT("%s"),
pInstData->GetInstName( )/*.c_str()*/);
csText =
pInstData->GetInstName( );
m_ctrlUserListC trl.SetItemText (iIndex,
eUserViewListCo lumn::BID_INST, csText);
memset(&buffer, 0, sizeof(buffer)) ;
sprintf(buffer, "%%.%df",
pSystemSetting->GetDecimalSize ());
csText.Format(b uffer, iterpart->GetSize());
m_ctrlUserListC trl.SetItemText (iIndex,
eUserViewListCo lumn::BID_SIZE, csText);
memset(&buffer, 0, sizeof(buffer)) ;
sprintf(buffer, "%%.%df",
pSystemSetting->GetDecimalPric e());
csText.Format(b uffer, iter->GetPrice());
m_ctrlUserListC trl.SetItemText (iIndex,
eUserViewListCo lumn::BID_PRICE , csText);
if (sizeof(iterpar t->GetTimestamp() .c_str()) >
255)
continue;
csText.Format(" %s",
iterpart->GetTimestamp() .c_str());
m_ctrlUserListC trl.SetItemText (iIndex,
eUserViewListCo lumn::BID_TIME, csText);
}
}
}
const std::vector<CMa rketData& userListAsk =
pInstData->GetMarketDataA sk();
for (iter = userListAsk.beg in(); iter != userListAsk.end ();
iter++)
{
const std::vector<CPa rticipant& participants =
iter->GetParticipant s();
for (iterpart = participants.be gin(); iterpart !=
participants.en d();
iterpart++)
{
if (iterpart->GetSize() 0.0 &&
iter->GetPrice() 0.0)
{
memset(&buffer, 0, sizeof(buffer)) ;
if (sizeof(iterpar t->GetUserName( )/*.c_str()*/)
255)continue;
//sprintf(buffer, "%s",
iterpart->GetUserName( )/*.c_str()*/);
int size = iterpart->GetUserName(). GetLength();
char bufsize[20];
memset(&bufsize , 0, sizeof(bufsize) );
_itoa(size,bufs ize,10);
CUtility::LogDe bugInfo( "OnNotifyNewDat a - ASK
UserName", bufsize);
info.psz = iterpart->GetUserName( );
iIndex = m_ctrlUserListC trl.FindItem(&i nfo);
if (iIndex == -1)
{ // insert the item
iIndex = m_ctrlUserListC trl.GetItemCoun t();
if (sizeof(iterpar t->GetUserName( )/*.c_str()*/)
255)continue;
//csText.Format(T EXT("%s"),
iterpart->GetUserName( )/*.c_str()*/);
csText = iterpart->GetUserName( );
m_ctrlUserListC trl.InsertItem( LVIF_TEXT|LVIF_ STATE, iIndex, csText,
0,
LVIS_SELECTED, 0, 0);
char * pchText = new char [csText.GetLengt h() +
1];
strcpy(pchText, (LPCTSTR)csText );
m_ctrlUserListC trl.SetItemData (iIndex,
(DWORD)pchText) ;
}
if
(sizeof(pInstDa ta->GetInstName( )/*.c_str()*/) 255)
continue;
//csText.Format(T EXT("%s"),
pInstData->GetInstName(). c_str());
csText = pInstData->GetInstName( );
m_ctrlUserListC trl.SetItemText (iIndex,
eUserViewListCo lumn::ASK_INST, csText);
memset(&buffer, 0, sizeof(buffer)) ;
sprintf(buffer, "%%.%df",
pSystemSetting->GetDecimalSize ());
csText.Format(b uffer, iterpart->GetSize());
m_ctrlUserListC trl.SetItemText (iIndex,
eUserViewListCo lumn::ASK_SIZE, csText);
memset(&buffer, 0, sizeof(buffer)) ;
sprintf(buffer, "%%.%df",
pSystemSetting->GetDecimalPric e());
csText.Format(b uffer, iter->GetPrice());
m_ctrlUserListC trl.SetItemText (iIndex,
eUserViewListCo lumn::ASK_PRICE , csText);
if (sizeof(iterpar t->GetTimestamp() .c_str()) >
255)
continue;
csText.Format(" %s",
iterpart->GetTimestamp() .c_str());
m_ctrlUserListC trl.SetItemText (iIndex,
eUserViewListCo lumn::ASK_TIME, csText);
}
}
}
VERIFY(m_ctrlUs erListCtrl.Sort Items( CompareFunction , r
einterpret_cast <DWORD>(&m_ctrl UserListCtrl))) ;
WRITE_LOG_FUNCT ION_EXIT("LRESU LT
CUserViewFrame: :OnNotifyNewDat a (WPARAM wParam,
PARAM
lParam)")
const char* strVariable1("C UserViewFrame:: OnNotifyNewData
END");
CUtility::LogDe bugInfo( strVariable1, strValue);
return 0;
}
Is there any chance the sprintf or CString Format function is creating
this problem.
I have spent lot of time it undertsanding this bug with no success. Any
help would be greatly appreciated.
Regards,
Sandy