Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Sun, 19 Aug 2007 14:55:32 +0100,    group: microsoft.public.platformsdk.com_ole        back       


Problems using CComBSTR.   
Hi,l I have a problem, where my debug builds are working, but in release  
comfiguration, my appliction crashes when I create a CComBSTR object.

I don't need to do much to make it crash, the following code always fails  
for me..

CoInitialize(NULL);
CComBSTR MyString( "Apples" );


Now I know the Coinitialise suceeds, why should I not be able to create a  
CComBSTR?  And why the difference between debug and release?

I am using VS2003 C++ enviroment.  My application does link to lots of  
other libraries..

Any tips?

Thanks.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
date: Sun, 19 Aug 2007 14:55:32 +0100   author:   Mark Gillespie

Re: Problems using CComBSTR.   
"Mark Gillespie"  wrote in message
news:op.txa7mu2ij2q9yy@xplaptop.draytek
> Hi,l I have a problem, where my debug builds are working, but in
> release comfiguration, my appliction crashes when I create a CComBSTR
> object.
> I don't need to do much to make it crash, the following code always
> fails for me..
>
> CoInitialize(NULL);
> CComBSTR MyString( "Apples" );
>
>
> Now I know the Coinitialise suceeds, why should I not be able to
> create a CComBSTR?  And why the difference between debug and release?

Most likely, you are corrupting the heap in some other, possibly 
completely unrelated, piece of code. E.g. a buffer overrun in a 
dynamically allocated array. When this happens, the problem manifests 
only when some later allocation accidentally happens to hit corrupted 
data structures.

The difference between a debug and release build is that in debug build, 
a memory allocation request adds some padding around the allocated 
buffer, precisely to detect buffer overruns when the memory is freed. 
But, while it's not yet freed, a small overrun does not break the 
program in debug build the way it does in release.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Sun, 19 Aug 2007 11:53:09 -0400   author:   Igor Tandetnik

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us