Official eMule-Board: Failure In Atl Leading To Uncatched Exception Fix - Official eMule-Board

Jump to content


Page 1 of 1

Failure In Atl Leading To Uncatched Exception Fix Originally posted in MorphXT section

#1 User is offline   Kro 

  • Member
  • PipPip
  • Group: Members
  • Posts: 29
  • Joined: 12-December 05

Posted 17 December 2005 - 10:57 AM

Debug assertion failure in ATL resulting in uncatched exception bugfix

Posted Image

CSharedFileList::AddFilesFromDirectory() scans various dirs to gather information about valuable files (eg. excludes thumbs.db from shared files).

CFileFind::GetLastWriteTime() is being called for every file to get its modification date. According to MSDN this method guarantees boolean result (with 0 denoting error), but there's no info about possible exception from CTime constructor called inside this method. It crashes if date is above some reasonable range.

Apparently I've had a file with some wacky date (picture here) which caused GetLastWriteTime() to throw an exception. WinDbg ~0kb result from debug session when exception hit below (MorphXT debug session line numbers differ):

0012cef0 00f582d0 00007133 00000006 00000010 emule!ATL::CTime::CTime+0x102 [f:\vs70builds\3077\vc\mfcatl\ship\atlmfc\include\atltime.inl @ 167]
0012cf30 00f58365 0012cf54 ffffffff 0012cf78 emule!ATL::CTime::CTime+0x80 [f:\vs70builds\3077\vc\mfcatl\ship\atlmfc\include\atltime.inl @ 206]
0012cf64 00edc3f6 02b29694 ffffffff 0012d8d4 emule!ATL::CTime::CTime+0x75 [f:\vs70builds\3077\vc\mfcatl\ship\atlmfc\include\atltime.inl @ 232]
0012cf80 00a114cc 0012d140 0012da54 0012da84 emule!CFileFind::GetLastWriteTime+0x56 [f:\vs70builds\3077\vc\mfcatl\ship\atlmfc\src\mfc\filefind.cpp @ 200]
0012d904 00a105fd 0012d9d0 0012e41c 0012da84 emule!CSharedFileList::AddFilesFromDirectory+0x6fc [d:\depot\morphxt\v76_02\srchybrid\sharedfilelist.cpp @ 539]
0012da60 00a1336f 02afbfb8 0012da78 00a133e0 emule!CSharedFileList::FindSharedFiles+0x2fd [d:\depot\morphxt\v76_02\srchybrid\sharedfilelist.cpp @ 417]
0012da6c 00a133e0 02afbfb8 0012e42c 00af0538 emule!CSharedFileList::Reload+0x2f [d:\depot\morphxt\v76_02\srchybrid\sharedfilelist.cpp @ 769]
0012da78 00af0538 02aec084 0012e4a4 0085ad63 emule!CSharedFileList::SetOutputCtrl+0x30 [d:\depot\morphxt\v76_02\srchybrid\sharedfilelist.cpp @ 779]
0012e42c 7739c3b7 00000000 00000113 00007e9a emule!CemuleDlg::StartupTimer+0x5a8 [d:\depot\morphxt\v76_02\srchybrid\emuledlg.cpp @ 783]


This file with messed up modification date was a reason for both errors reported in MorphXT mod section:
  • "Parameter is incorrect" error when applying configuration changes with silly-date file in shared directory
  • no possibility to upload anything (upload was blocked if file with wacky mod. date was first one parsed by emule; exception prevented from queueing other files)

Fix

SharedFileList.cpp:495

Is:

  CTime lwtime;
  if (!ff.GetLastWriteTime(lwtime)){
  	if (thePrefs.GetVerbose())
    AddDebugLogLine(false, _T("Failed to get file date of %s - %s"), ff.GetFilePath(), GetErrorMessage(GetLastError()));
  }
  uint32 fdate = (UINT)lwtime.GetTime();


Should be:

  CTime lwtime;
  uint32 fdate = (int)(-1);
  try
  {
  	if (!ff.GetLastWriteTime(lwtime)){
    if (thePrefs.GetVerbose())
    	AddDebugLogLine(false, _T("Failed to get file date of %s - %s (FindNextFile has never been called?)"), ff.GetFilePath(), GetErrorMessage(GetLastError()));
  	}
  	fdate = (UINT)lwtime.GetTime();
  }
  catch (CAtlException& e)
  {
  	if (thePrefs.GetVerbose())
    AddDebugLogLine(false, _T("Failed to get file date of %s - %s (wrong modification date %X)"), ff.GetFilePath(), GetErrorMessage(GetLastError()), e.m_hr);
  }
  catch (...)
  {
  	if (thePrefs.GetVerbose())
    AddDebugLogLine(false, _T("Failed to get file date of %s - %s (unidentified error)"), ff.GetFilePath(), GetErrorMessage(GetLastError()));
  }

Perhaps exception logging is to precise in this case - I'm not eMule dev. ;)

Best regards,
Kro
0

#2 User is offline   BlueSonicBoy 

  • Magnificent Member
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 396
  • Joined: 26-September 04

Posted 22 December 2005 - 10:49 PM

Kro, on Dec 17 2005, 05:57 AM, said:

Debug assertion failure in ATL resulting in uncatched exception bugfix
View Post

Thank you for that fix!! :+1:

Doing a quick search through the code, I found the same piece of code in PartFile.cpp, bool CPartFile::SavePartFile(). So it's a double fix! :flowers:
0

  • Member Options

Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users