delete指针出现_CrtIsValidHeapPointer(pUserData)错误

_CrtIsValidHeapPointer(pUserData)
_CrtIsValidHeapPointer(pUserData) in dbghelp.c
2006-10-14 18:19
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 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值