You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Emmanuel Taf <ma...@webmails.com> on 2003/09/22 17:50:37 UTC

Deleting something returned by XMLString::replicate crashes when application is using the release build of Xerces-C++ ?

Hi all,

I am using Visual C++ v6.0 sp5 on Windows XP sp1
and xerces-c++ version 2.3.0.

I try to execute the following example (compiling as a single threaded
run-time library, and linking with xerces binary either downloaded (or
recompiled as
single-threaded library : pb is the same)) :

...
int main(int argc, char* argv[]) {
    xercesc::XMLPlatformUtils::Initialize();

    char szHW[15] = "Hello World";
    printf("%s!\n", szHW);

    XMLCh* sLocalName = xercesc::XMLString::transcode(szHW);
    // copy (replicate)
    XMLCh* sLocalNameCopy = xercesc::XMLString::replicate(sLocalName);

    // release sLocalName
    printf("release sLocalName\n");
    xercesc::XMLString::release(&sLocalName);

    // release sLocalNameCopy
    printf("release sLocalNameCopy\n");
    // [1]
    xercesc::XMLString::release(&sLocalNameCopy);
    // [2]
//     delete [] sLocalNameCopy;
//     sLocalNameCopy = NULL;

    printf("The World is Beautiful !\n");

    xercesc::XMLPlatformUtils::Terminate();
    return 0;
}


it works when application is using the debug build.

output :

Hello World!
release sLocalName
release sLocalNameCopy
The World is Beautiful !


But unfortunately, with a release build, an error occurs : The world is
never beautiful :(

output :

Hello World!
release sLocalName
release sLocalNameCopy

HEAP[xercesctest.exe]: Invalid Address specified to RtlFreeHeap(
00330000,
00350F80 )



XMLString::release(&(XMLString::replicate(...))) doesn't not seem to
work in release mode.

(if i try  :
delete [] sLocalNameCopy;
sLocalNameCopy = NULL;
it works fine : but not with debug version)

is there an error in my program or a bug in xerces ?

This problem disappears when I compile my app as multi-threaded, but I
want it single threaded...

Thanks & Regards

Emmanuel T.


____________________________________________________________________
- http://www.WebMailSPro.com - >> 
Cr�er votre WebBased email pour avec votre propre nom de domaine 


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Deleting something returned by XMLString::replicate crashes when application is using the release build of Xerces-C++ ?

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,


Are you using the non-debug version in windows as well as it being single 
threaded?

Gareth

On Mon, 22 Sep 2003, Emmanuel Taf wrote:

> Hi all,
> 
> I am using Visual C++ v6.0 sp5 on Windows XP sp1
> and xerces-c++ version 2.3.0.
> 
> I try to execute the following example (compiling as a single threaded
> run-time library, and linking with xerces binary either downloaded (or
> recompiled as
> single-threaded library : pb is the same)) :
> 
> ...
> int main(int argc, char* argv[]) {
>     xercesc::XMLPlatformUtils::Initialize();
> 
>     char szHW[15] = "Hello World";
>     printf("%s!\n", szHW);
> 
>     XMLCh* sLocalName = xercesc::XMLString::transcode(szHW);
>     // copy (replicate)
>     XMLCh* sLocalNameCopy = xercesc::XMLString::replicate(sLocalName);
> 
>     // release sLocalName
>     printf("release sLocalName\n");
>     xercesc::XMLString::release(&sLocalName);
> 
>     // release sLocalNameCopy
>     printf("release sLocalNameCopy\n");
>     // [1]
>     xercesc::XMLString::release(&sLocalNameCopy);
>     // [2]
> //     delete [] sLocalNameCopy;
> //     sLocalNameCopy = NULL;
> 
>     printf("The World is Beautiful !\n");
> 
>     xercesc::XMLPlatformUtils::Terminate();
>     return 0;
> }
> 
> 
> it works when application is using the debug build.
> 
> output :
> 
> Hello World!
> release sLocalName
> release sLocalNameCopy
> The World is Beautiful !
> 
> 
> But unfortunately, with a release build, an error occurs : The world is
> never beautiful :(
> 
> output :
> 
> Hello World!
> release sLocalName
> release sLocalNameCopy
> 
> HEAP[xercesctest.exe]: Invalid Address specified to RtlFreeHeap(
> 00330000,
> 00350F80 )
> 
> 
> 
> XMLString::release(&(XMLString::replicate(...))) doesn't not seem to
> work in release mode.
> 
> (if i try  :
> delete [] sLocalNameCopy;
> sLocalNameCopy = NULL;
> it works fine : but not with debug version)
> 
> is there an error in my program or a bug in xerces ?
> 
> This problem disappears when I compile my app as multi-threaded, but I
> want it single threaded...
> 
> Thanks & Regards
> 
> Emmanuel T.
> 
> 
> ____________________________________________________________________
> - http://www.WebMailSPro.com - >> 
> Créer votre WebBased email pour avec votre propre nom de domaine 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 
> 

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org