搜索到以下东西
When I execute my program (it's multithread and has COM and dll),
there is an error message as follows:
Program D:/dongle_1/TestAP/bin/Debug/TestAP.exe
File: dbgheap.c
Line: 1132
Expression: _CrtIsValidHeapPointer(pUserData)
For information on how your program can cause an assertion failure, see
the Visual C++ documentation on asserts.
========================================
==========
I read the dbgheap.c and find the line 1132, it's as follows:
/*
* If this ASSERT fails, a bad pointer has been passed in. It
may be
* totally bogus, or it may have been allocated from another
heap.
* The pointer MUST come from the 'local' heap.
*/
1132: _ASSERTE(_CrtIsValidHeapPointer(pUserDat
a));
========================================
=====================I also use
google to find some answers.
They said
(1) If you are developing multithread application, be sure to link it
with
the correct runtime library(/MD, /MT). That what
"The pointer MUST come from the 'local' heap." means.
Check what "ruintime library" you use. It should be "Multi threaded (
debug ) DLL"
Roman
(2)
Not only must they match, they must both be DLL versions. If they're
static versions, each piece (the exe and the dll) will have their own
heap and the OP will still be deleting from mismatched heaps.
I'd also be suspicious of general design issues given the way the OP's
main program is having to clean up for the dll.
You'll get this problem if you use two different run-time libraries,
one to
allocate the memory and one to de-allocate the memory. Open up the
project
settings dialog, switch to C/C++ tab, set Category to Code Generation
and
check the Use run-time library combo box. These must match in any
modules
that share the task of allocating and destroying memory.
--
Randy Charles Morin
Author of Programming Windows Services
http://www.kbcafe.com
========================================
=============
If necessary, my dirty code is as follows (Please read from the bottom
up)
http://irc.csie.org:8888/125
Thanks in advance .
-jiing-
打开你的项目配置对话框,找到C/C++ ---> 代码生成
选择多线程调试dll
把所有的工程都设为多线程调试dll
本文描述了一个多线程程序中出现的内存指针验证失败的问题,该问题出现在Debug模式下,具体表现为程序运行时抛出关于内存指针验证的断言失败错误。文章探讨了可能的原因,包括使用不匹配的运行时库以及多线程应用中堆内存管理不当等问题,并给出了相应的解决方案。
1052

被折叠的 条评论
为什么被折叠?



