You receive a "#File Error#" error message in the place of a file name when you try to call _CrtMemDumpAllObjectsSince() to dump the objects on the CRT heap in Visual C++ (163370)
The information in this article applies to:
- Microsoft Visual C++ 4.0
- Microsoft Visual C++ 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q163370 SYMPTOMS When you call _CrtMemDumpAllObjectsSince() to dump the
objects on the CRT heap, you may see #File Error# in the place of a file name.
Following is an example of a dump where both a file name and the #File Error#
occurs.
Dumping objects ->
d1.cpp(11) : {27} normal block at 0x007609A0, 222 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
#File Error#(9) : {26} normal block at 0x00760900, 111 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
CAUSE The CRT adds a header to the beginning of every memory
block that is allocated. If you have defined the symbol _CRTDBG_MAP_ALLOC
before including crtdbg.h, this memory block header contains a pointer to the
name of the file where the CRT function that allocated the memory block was
called from. #File Error# is emitted instead of the file name when the
executing process does not have read access to the memory reference by this
pointer. There are two probable causes for not having read access to
the memory reference by this pointer: - Heap corruption. Overwriting the block of memory preceding
the block giving the #File Error# may have caused corruption in the block
header. Usually, there are other errors as well, such as "Damage after Normal
Block."
- The memory block was allocated in a DLL that was unloaded
prior to the _CrtMemDumpAllObjectsSince() call.
STATUS
This behavior is by design. Steps to reproduce the behavior- Type in the following code:
// d2.cpp
// Create d2.dll by compiling with: CL /LDd /MDd d2.cpp /link /debug
#include <malloc.h>
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
extern "C"
_declspec(dllexport)
void* a (int cnt) {
return malloc(cnt);
}
// d1.cpp
// Create d1.exe by compiling with: CL /MDd d1.cpp /link d2.lib /debug
#include <windows.h>
#include <malloc.h>
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
void main () {
HINSTANCE h = LoadLibrary("d2.dll");
void* (*f)(int) = (void* (*)(int))GetProcAddress(h,"a");
f(111);
malloc(222);
FreeLibrary(h);
_CrtMemDumpAllObjectsSince(0);
}
- Create the DLL(d2.dll) and the
application(d1.exe).
- Start Developer Studio with the following command: Make sure the output window is visible in the Developer
Studio.
- On the Build menu, select Debug and then Go.
Modification Type: | Major | Last Reviewed: | 6/2/2005 |
---|
Keywords: | kbtshoot kberrmsg kbcode kbCRT kbprb KB163370 kbAudDeveloper |
---|
|