Re: Throwing from DLL causes heap corruption
On Fri, 11 Jan 2008 14:16:19 -0800, Kenneth Porter
<shiva.blacklist@sewingwitch.com> wrote:
I have a DLL linked to my own app that works fine when throwing from DLL to
application. But with a customer application I get a heap corruption
exception when the thrown exception goes out of scope in the catch clause.
I've copied the stack below. To the best of my knowledge, both app and DLL
are linked against the VC6 multi-threaded debug DLL runtime. Any idea
what's going wrong here?
_CrtIsValidHeapPointer(const void * 0x09b56480) line 1697
_free_dbg_lk(void * 0x09b56480, int -572662307) line 1044 + 9 bytes
_free_dbg(void * 0x09b56480, int -572662307) line 1001 + 13 bytes
operator delete(void * 0x09b56480) line 49 + 16 bytes
MSVCRTD! exception::~exception(void) + 45 bytes
AxisSafetyException::~AxisSafetyException() + 208 bytes
MSVCRTD! DestructExceptionObject(struct EHExceptionRecord *,unsigned char)
+ 85 bytes
MSVCRTD! __FrameUnwindToState + 807 bytes
MSVCRTD! __FrameUnwindToState + 458 bytes
MSVCRTD! __InternalCxxFrameHandler + 800 bytes
MSVCRTD! __InternalCxxFrameHandler + 227 bytes
MSVCRTD! __CxxFrameHandler + 44 bytes
NTDLL! 7c9037bf()
NTDLL! 7c90378b()
NTDLL! 7c90eafa()
MSVCRTD! _CxxThrowException@8 + 57 bytes
There was a VC5/6 bug that caused double-destruction of exception objects
under certain circumstances. Here's an example of the sort of code that
elicits it:
http://groups.google.com/group/microsoft.public.vc.language/msg/ff9d579765bed5b7
--
Doug Harrison
Visual C++ MVP