Validation error in CRT calling _osfile () in VS 2008?

I have a C ++ code base that works for a long time. The code base was an outdated set of VS 2003 projects that I recently migrated to VS 2008. The migration seemed to be successful in that the resulting program was built and launched.

I reinstalled my OS and all applications on a new drive, and now when I try to debug the program in the debugger, I get an assertion error inside CRT chsize(really, _chsize_s). In particular (with the base trimmed, excluding security checks):

FILE * testfile = fopen("P:\\_Dan\\local\\foogoo.txt", "w");
int filehandle = fileno(testfile);
chsize(filehandle, 0);
fwrite("goohoo", 1, 6, testfile);
fclose(testfile);

The debug statement is done internally chsize- in particular, in the CRT source code file chsize.c in the following line:

 _VALIDATE_CLEAR_OSSERR_RETURN_ERRCODE((_osfile(filedes) & FOPEN), EBADF);

... where filedesappropriate filehandle.

, , - , ​​ VS ( VS 2008), VS 8.0 - , , VS 2008. VS 2005 ( 2003). .

.

* - chsize. . .

+5
2

chsize. c-runtime, , (/MTd) , DLL (/MDd) , . /MDd .

, , Visual Studio - , . , ( , ).

+4

. , MT. , , , _VALIDATE_RETURN ((osfile (fh) FOPEN), EBADF, -1) setmode.c CRT .

_osfile , osfile __pioinfo (01802EEDB0h). , CRT. __pioinfo - 01E619540h. , , MT.

, , . , .

+1

All Articles