Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-60172

QXmlQuery XSL apply-templates memory leak

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 5.8.0
    • XML: QtXmlPatterns
    • None

    Description

      Valgrind reports a memory leak in QXmlQuery with the following simpleprogram:

      #include <QCoreApplication>
      #include <QXmlQuery>
      
      auto transform =
              R"XSL(<?xml version="1.0" encoding="UTF-8"?>
              <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
                  <xsl:output method="text" encoding="UTF-8"/>
                  <xsl:template match="/root">
                      <xsl:apply-templates select="*"/>
                  </xsl:template>
              </xsl:stylesheet>)XSL";
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          QXmlQuery query(QXmlQuery::XSLT20);
          query.setFocus("<root><test/></root>");
          query.setQuery(transform);
      
          return 0;
      }
      

      valgrind --tool=memcheck --leak-check=full --leak-resolution=high ./apply-templates 2> log.txt

      log.txt

      ==3524== 712 (24 direct, 688 indirect) bytes in 1 blocks are definitely lost in loss record 199 of 211
      ==3524==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==3524==    by 0x4FFF8C4: QPatternist::ParserContext::modeFor(QXmlName const&) (qparsercontext_p.h:344)
      ==3524==    by 0x4FF090B: QPatternist::XPathparse(QPatternist::ParserContext*) (querytransformparser.ypp:3621)
      ==3524==    by 0x4F4EF0F: QPatternist::ExpressionFactory::createExpression(QExplicitlySharedDataPointer<QPatternist::Tokenizer> const&, QExplicitlySharedDataPointer<QPatternist::StaticContext> const&, QXmlQuery::QueryLanguage, QExplicitlySharedDataPointer<QPatternist::SequenceType const> const&, QUrl const&, QXmlName const&) (qexpressionfactory.cpp:149)
      ==3524==    by 0x4F50E72: QPatternist::ExpressionFactory::createExpression(QIODevice*, QExplicitlySharedDataPointer<QPatternist::StaticContext> const&, QXmlQuery::QueryLanguage, QExplicitlySharedDataPointer<QPatternist::SequenceType const> const&, QUrl const&, QXmlName const&) (qexpressionfactory.cpp:123)
      ==3524==    by 0x4F00811: QXmlQueryPrivate::expression(QIODevice*) (qxmlquery_p.h:252)
      ==3524==    by 0x4EFE51D: QXmlQuery::setQuery(QIODevice*, QUrl const&) (qxmlquery.cpp:429)
      ==3524==    by 0x4EFF0D7: QXmlQuery::setQuery(QString const&, QUrl const&) (qxmlquery.cpp:448)
      ==3524==    by 0x400DC9: main (main.cpp:19)
      

      I only see this leak when using the 'apply-templates' XSL node.

      Attachments

        1. log.txt
          24 kB
        2. main.cpp
          0.7 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            crobertd Robert Daniels
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes