By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,835 Members | 1,909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,835 IT Pros & Developers. It's quick & easy.

Debug Assertion Failed! msvcr80d.dll!__loctotime64_t Expression: (((long)(yr-1900) >= _BASE_YEAR) && ((long)(yr - 1900) <=

P: n/a
It seems that windows file systems can have files dated to 1617, and
unfortunately if you call _findfirst/_findnext on such a directory,
msvcr80d will assert.

Is there some provision for changing msvcr80d so that this assert
doesn't happen?

Debug Assertion Failed!
File: dtoxtm64.c
Line: 67

Expression: (((long)(yr-1900) >= _BASE_YEAR) && ((long)(yr - 1900) <=
_MAX_YEAR64))

The top of the stack was:
msvcr80d.dll!__loctotime64_t(int yr=1617, int mo=11, int dy=3, int
hr=1, int mn=26, int sc=9, int dstflag=-1) Line 67 + 0x57 bytes C
msvcr80d.dll!__time64_t_from_ft(_FILETIME * pft=0x0012c52c) Line 253 +
0x25 bytes C
msvcr80d.dll!_findnext64i32(int hFile=1484232, _finddata64i32_t *
pfd=0x0012c684) Line 187 + 0xc bytes C

full details and stack can be found at:
https://bugzilla.mozilla.org/show_bug.cgi?id=331404

If there's some more appropriate group for this question, please let me
know. I searched around a bit, and this group seemed to be one of very
few candidates.

Mar 23 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Josh!
It seems that windows file systems can have files dated to 1617, and
unfortunately if you call _findfirst/_findnext on such a directory,
msvcr80d will assert.

Is there some provision for changing msvcr80d so that this assert
doesn't happen?
This is a limitation of the C-Standard not the CRT.
To handle date/times < 1900/1970 you must not use the C-Runtime.

YOu should use FindFirstFile/FindNextFile and FILETIME
full details and stack can be found at:
https://bugzilla.mozilla.org/show_bug.cgi?id=331404


And what should be the solution in the C-Runtime?

Greetings
Jochen
Mar 23 '06 #2

P: n/a
"Jochen Kalmbach [MVP]" <no********************@holzma.de> wrote in message
news:e6**************@TK2MSFTNGP11.phx.gbl...
Hi Josh!
It seems that windows file systems can have files dated to 1617, and
unfortunately if you call _findfirst/_findnext on such a directory,
msvcr80d will assert.

Is there some provision for changing msvcr80d so that this assert
doesn't happen?
This is a limitation of the C-Standard not the CRT.
To handle date/times < 1900/1970 you must not use the C-Runtime.

YOu should use FindFirstFile/FindNextFile and FILETIME
full details and stack can be found at:
https://bugzilla.mozilla.org/show_bug.cgi?id=331404


And what should be the solution in the C-Runtime?


It should most certainly not assert. Assertions should only catch program
errors, not exceptional conditions in the environment.

Greetings
Jochen

Mar 23 '06 #3

P: n/a
Hi Ben!
It should most certainly not assert. Assertions should only catch program
errors, not exceptional conditions in the environment.


asserts only happen in debug builds... and it is a good feature that it
asserts...

Greetings
Jochen
Mar 23 '06 #4

P: n/a
Hi Ben!
>>Is there some provision for changing msvcr80d so that this assert
doesn't happen?
This is a limitation of the C-Standard not the CRT.
To handle date/times < 1900/1970 you must not use the C-Runtime.

YOu should use FindFirstFile/FindNextFile and FILETIME
>>full details and stack can be found at:
https://bugzilla.mozilla.org/show_bug.cgi?id=331404
And what should be the solution in the C-Runtime?

It should most certainly not assert. Assertions should only catch program
errors, not exceptional conditions in the environment.
As a small addition:

The release version of the CRT never asserts.
BUT: In the VC8 CRT MS improved and extended many validation of
arguments and values inside the CRT!
Then it will crash you app (execute an breakpoint-instruction) if it
encounters some "unhandled" situation.
See "_VALIDATE_RETURN" macro.

So the following code will crash your app with the following error message:
Microsoft Visual Studio C Runtime Library has detected a fatal error in
CPP.exe.

You can verify this with the following example:

#include <windows.h>
#include <tchar.h>
#include <io.h>

int _tmain()
{
HANDLE h = CreateFile(_T("\\old.file"), GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, 0, NULL);
SYSTEMTIME st;
ZeroMemory(&st, sizeof(st));
st.wDay = 1;
st.wMonth = 1;
st.wYear = 1602;
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
SetFileTime(h, &ft, &ft, &ft);
CloseHandle(h);

_finddata32_t ff;
_findfirst32("\\old.file", &ff);
}
You can only prevent this by specifying and "invalid parameter handler":

#include <windows.h>
#include <tchar.h>
#include <io.h>

void myInvalidParameterHandler(const wchar_t* expression,
const wchar_t* function,
const wchar_t* file,
unsigned int line,
uintptr_t pReserved)
{
wprintf(L"Invalid parameter detected in function %s."
L" File: %s Line: %d\n", function, file, line);
wprintf(L"Expression: %s\n", expression);
}

int _tmain()
{
HANDLE h = CreateFile(_T("\\old.file"), GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, 0, NULL);
SYSTEMTIME st;
ZeroMemory(&st, sizeof(st));
st.wDay = 1;
st.wMonth = 1;
st.wYear = 1602;
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
SetFileTime(h, &ft, &ft, &ft);
CloseHandle(h);

_set_invalid_parameter_handler(myInvalidParameterH andler);

_finddata32_t ff;
_findfirst32("\\old.file", &ff);
}
But this might trigger some followup-errors, because the datetime-field
of the "ff" structure will be "NULL"...

Also there are some error, which can't be catched...
See: "SetUnhandledExceptionFilter" and VC8
http://blog.kalmbachnet.de/?postid=75

Greetings
Jochen
Dec 1 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.