Fix segmentation fault on object free when using extension#11
Open
eric-hemasystems wants to merge 1 commit intoglejeune:masterfrom
Open
Fix segmentation fault on object free when using extension#11eric-hemasystems wants to merge 1 commit intoglejeune:masterfrom
eric-hemasystems wants to merge 1 commit intoglejeune:masterfrom
Conversation
If a XSL file activates an extension. For example:
<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:func="http://exslt.org/functions" extension-element-prefixes="func">
</xsl:stylesheet>
Then we load two instances of the library both referencing that XSL
file:
require 'xml/xslt'
xslt1 = XML::XSLT.new()
xslt1.xsl = 'xslt.xsl'
xslt2 = XML::XSLT.new()
xslt2.xsl = 'xslt.xsl'
Then we get a segmentation fault. I believe this is because of the:
xsltCleanupGlobals();
xmlCleanupParser();
xmlMemoryDump();
that is run whenever a XML::XSLT object is garbage collected. While
the XSLT tutorial does suggest these methods be called:
http://xmlsoft.org/XSLT/tutorial/libxslttutorial.html#cleanup
If you look at the documentation to `xmlCleanupParser` you will see
it is clear this should only be done when the library is no longer
needed:
http://xmlsoft.org/html/libxml-parser.html#xmlCleanupParser
Since our other instance may still be using the library it now gets an
error when it tries to cleanup it's stylesheet that is using an
extension.
This commit removes that freeing of memory as we don't really have any
idea when the calling application might be done with the library. This
is also per the recommendation in the documentation where it says:
It's sometimes very hard to guess if libxml2 is in use in the
application, some libraries or plugins may use it without notice. In
case of doubt abstain from calling this function...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a XSL file activates an extension. For example:
Then we load two instances of the library both referencing that XSL file:
Then we get a segmentation fault. I believe this is because of the:
that is run whenever a XML::XSLT object is garbage collected. While the XSLT tutorial does suggest these methods, if you look at the documentation to
xmlCleanupParseryou will see it is clear this should only be done when the library is no longer needed:Since our other instance may still be using the library it now gets an error when it tries to cleanup it's stylesheet that is using an extension.
This commit removes that freeing of memory as we don't really have any idea when the calling application might be done with the library. This is also per the recommendation in the documentation where it says: