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 "Paulo Zanoni (JIRA)" <xe...@xml.apache.org> on 2011/04/15 22:30:05 UTC
[jira] [Created] (XERCESC-1962) memory leak with XInclude
memory leak with XInclude
-------------------------
Key: XERCESC-1962
URL: https://issues.apache.org/jira/browse/XERCESC-1962
Project: Xerces-C++
Issue Type: Bug
Components: XInclude
Affects Versions: 3.1.1
Environment: Linux Ubuntu 10.10 i386
Reporter: Paulo Zanoni
When xerces-c++ is parsing files with XInclude, it leaks memory. You can check the memory leak by running "valgrind".
This behavior can be reproduced both with the "XInclude" binary and with custom code.
All you need to do is:
- create a parser
- set validation scheme to Val_Auto
- setDoNamespaces(true)
- setDoXInclude(true)
- parser.parse("example.xml");
I have tracked the bug. The "actual" leak is inside XIncludeUtils::reportError. It uses XMLPlatformUtils::loadMsgSet, which calls loadAMsgSet, which allocates memory and returns to its callee (see XMLPlatformUtils::loadAMsgSet inside utils/PlatformUtils.cpp). The memory allocated by loadAMsgSet is never freed.
The solution:
In file xinclude/XIncludeUtils.cpp, function XIncludeUtils::reportError, the pointer allocated by XMLPlatformUtils::loadMsgSet should be freed. For my testings, I just added a "delete erMsgLoader" at the end of the scope, but I am not sure this is enough (since I'm not sure if any of the functions between loadMsgSet and the end of the scope can throw exceptions). It is up to you, developers, find a proper solution =D
I'll attach examples.
I locally tested my patch (I rebuild the Ubuntu package) and it seems to have worked, but I didn't test much. I am not familiar with xerces-c code so I'm not sure if it can break anything.
Thanks,
Paulo
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] [Updated] (XERCESC-1962) memory leak with XInclude
Posted by "Paulo Zanoni (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESC-1962?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paulo Zanoni updated XERCESC-1962:
----------------------------------
Attachment: xinclude-example.xml
xinclude_leak.cpp
Files to reproduce the bug.
Compile and run with valgrind --leak-check=full
> memory leak with XInclude
> -------------------------
>
> Key: XERCESC-1962
> URL: https://issues.apache.org/jira/browse/XERCESC-1962
> Project: Xerces-C++
> Issue Type: Bug
> Components: XInclude
> Affects Versions: 3.1.1
> Environment: Linux Ubuntu 10.10 i386
> Reporter: Paulo Zanoni
> Labels: example, leak, patch,
> Attachments: xinclude-example.xml, xinclude_leak.cpp
>
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> When xerces-c++ is parsing files with XInclude, it leaks memory. You can check the memory leak by running "valgrind".
> This behavior can be reproduced both with the "XInclude" binary and with custom code.
> All you need to do is:
> - create a parser
> - set validation scheme to Val_Auto
> - setDoNamespaces(true)
> - setDoXInclude(true)
> - parser.parse("example.xml");
> I have tracked the bug. The "actual" leak is inside XIncludeUtils::reportError. It uses XMLPlatformUtils::loadMsgSet, which calls loadAMsgSet, which allocates memory and returns to its callee (see XMLPlatformUtils::loadAMsgSet inside utils/PlatformUtils.cpp). The memory allocated by loadAMsgSet is never freed.
> The solution:
> In file xinclude/XIncludeUtils.cpp, function XIncludeUtils::reportError, the pointer allocated by XMLPlatformUtils::loadMsgSet should be freed. For my testings, I just added a "delete erMsgLoader" at the end of the scope, but I am not sure this is enough (since I'm not sure if any of the functions between loadMsgSet and the end of the scope can throw exceptions). It is up to you, developers, find a proper solution =D
> I'll attach examples.
> I locally tested my patch (I rebuild the Ubuntu package) and it seems to have worked, but I didn't test much. I am not familiar with xerces-c code so I'm not sure if it can break anything.
> Thanks,
> Paulo
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] [Resolved] (XERCESC-1962) memory leak with XInclude
Posted by "Alberto Massari (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESC-1962?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alberto Massari resolved XERCESC-1962.
--------------------------------------
Resolution: Fixed
Fix Version/s: 3.2.0
Assignee: Alberto Massari
A fix is in SVN. Please verify
> memory leak with XInclude
> -------------------------
>
> Key: XERCESC-1962
> URL: https://issues.apache.org/jira/browse/XERCESC-1962
> Project: Xerces-C++
> Issue Type: Bug
> Components: XInclude
> Affects Versions: 3.1.1
> Environment: Linux Ubuntu 10.10 i386
> Reporter: Paulo Zanoni
> Assignee: Alberto Massari
> Labels: example, leak, patch,
> Fix For: 3.2.0
>
> Attachments: xinclude-example.xml, xinclude-leak.patch, xinclude_leak.cpp
>
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> When xerces-c++ is parsing files with XInclude, it leaks memory. You can check the memory leak by running "valgrind".
> This behavior can be reproduced both with the "XInclude" binary and with custom code.
> All you need to do is:
> - create a parser
> - set validation scheme to Val_Auto
> - setDoNamespaces(true)
> - setDoXInclude(true)
> - parser.parse("example.xml");
> I have tracked the bug. The "actual" leak is inside XIncludeUtils::reportError. It uses XMLPlatformUtils::loadMsgSet, which calls loadAMsgSet, which allocates memory and returns to its callee (see XMLPlatformUtils::loadAMsgSet inside utils/PlatformUtils.cpp). The memory allocated by loadAMsgSet is never freed.
> The solution:
> In file xinclude/XIncludeUtils.cpp, function XIncludeUtils::reportError, the pointer allocated by XMLPlatformUtils::loadMsgSet should be freed. For my testings, I just added a "delete erMsgLoader" at the end of the scope, but I am not sure this is enough (since I'm not sure if any of the functions between loadMsgSet and the end of the scope can throw exceptions). It is up to you, developers, find a proper solution =D
> I'll attach examples.
> I locally tested my patch (I rebuild the Ubuntu package) and it seems to have worked, but I didn't test much. I am not familiar with xerces-c code so I'm not sure if it can break anything.
> Thanks,
> Paulo
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] [Updated] (XERCESC-1962) memory leak with XInclude
Posted by "Paulo Zanoni (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESC-1962?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paulo Zanoni updated XERCESC-1962:
----------------------------------
Attachment: xinclude-leak.patch
Patch generated with "svn diff"
I have no idea if it can have "side effects". Please audit it.
> memory leak with XInclude
> -------------------------
>
> Key: XERCESC-1962
> URL: https://issues.apache.org/jira/browse/XERCESC-1962
> Project: Xerces-C++
> Issue Type: Bug
> Components: XInclude
> Affects Versions: 3.1.1
> Environment: Linux Ubuntu 10.10 i386
> Reporter: Paulo Zanoni
> Labels: example, leak, patch,
> Attachments: xinclude-example.xml, xinclude-leak.patch, xinclude_leak.cpp
>
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> When xerces-c++ is parsing files with XInclude, it leaks memory. You can check the memory leak by running "valgrind".
> This behavior can be reproduced both with the "XInclude" binary and with custom code.
> All you need to do is:
> - create a parser
> - set validation scheme to Val_Auto
> - setDoNamespaces(true)
> - setDoXInclude(true)
> - parser.parse("example.xml");
> I have tracked the bug. The "actual" leak is inside XIncludeUtils::reportError. It uses XMLPlatformUtils::loadMsgSet, which calls loadAMsgSet, which allocates memory and returns to its callee (see XMLPlatformUtils::loadAMsgSet inside utils/PlatformUtils.cpp). The memory allocated by loadAMsgSet is never freed.
> The solution:
> In file xinclude/XIncludeUtils.cpp, function XIncludeUtils::reportError, the pointer allocated by XMLPlatformUtils::loadMsgSet should be freed. For my testings, I just added a "delete erMsgLoader" at the end of the scope, but I am not sure this is enough (since I'm not sure if any of the functions between loadMsgSet and the end of the scope can throw exceptions). It is up to you, developers, find a proper solution =D
> I'll attach examples.
> I locally tested my patch (I rebuild the Ubuntu package) and it seems to have worked, but I didn't test much. I am not familiar with xerces-c code so I'm not sure if it can break anything.
> Thanks,
> Paulo
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org