Problem when releasing InputSource obtained through an EntityResolver
---------------------------------------------------------------------
Key: XALANC-455
URL: http://issues.apache.org/jira/browse/XALANC-455
Project: XalanC
Type: Bug
Components: XalanC
Versions: CurrentCVS, 1.9
Environment: MSVC6 / Win2k
Reporter: Alain Le Guennec
I think there is a problem when cleaning-up InputSources returned by a call to
resolveEntity() on an EntityResolver.
The problem lies in routine XSLTEngineImpl::parseXML(), at line 652 of file
XSLTEngineImpl.cpp:
A smart pointer of kind XalanMemMgrAutoPtr is used to manage the pointer to the
InputSource obtained from the EntityResolver.
However, Xerces' class InputSource inherits from XMemory, and this causes
trouble when the XalanMemMgrAutoPtr tries to free the memory.
Indeed, XMemory has customized new() and delete() operators that,
in addition to the space required to hold the object,
also allocates a little space for a special "header" placed just before.
The pointer returned by new() points just after the header, not at the
beginning of the allocated area.
In turn, XalanMemMgrAutoPtr calls the memory manager to deallocate the
InputSource,
but is not aware of the special header of XMemory objects, and so pass the
wrong address to delete()...
On my Windows machine, this systematically results in a bad memory access
exception.
I think this problem could also be the cause of the memory leak observed by
someone else on this list
(see thread "Changes, bugs, etc. between 1.8 and 1.9").
I guess some system allocators are just stricter than others when delete() is
given the wrong address.
I am not too sure how to best fix this problem.
I just replace the use of XalanMemMgrAutoPtr by a simple XalanAutoPtr at line
652, and I don't have any problem anymore.
Maybe it could also be possible to define a template specialization for
XalanMemMgrAutoPtr for type XMemory to account for the "header"?
Best regards,
Alain Le Guennec.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]