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

50 % cpu usage and system memory exhaustion after calling QDomDocument::cloneNode( true ) if xml file contains entities in DOCTYPE section

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.6.3
    • 4.6.2
    • XML: DOM
    • None
    • Windows XP, using qt-4.6.2-SDK-windows
    • 4b3b9b792dfe2d25a271f042f23df22e8b9684f6

    Description

      Let say we have a xml file named 'first.xml' with content as follows:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE first [
      <!ENTITY secondFile SYSTEM "second.xml">
      ]>

      <first>
      <child>
      </child>
      </first>

      and we have a application code (main.cpp) as follows:

      #include <QApplication>
      #include <iostream>
      #include <QtXml>

      using namespace std;

      int main( int argc, char** argv )
      {
      QApplication app( argc, argv );

      QDomDocument iDomDocument;
      QFile iFile( first.xml );
      if ( false == iFile.open( QIODevice::ReadOnly ) )

      { cout << "Could not open file " << iFirstFileName.toStdString() << " error: " << iFile.error() << endl; return 1; }

      QString iErrorMessage = "";
      int iErrorLine;
      int iErrorColumn;
      if ( false == iDomDocument.setContent( &iFile, &iErrorMessage, &iErrorLine, &iErrorColumn ) )

      { cout << "Could not set content " << iErrorMessage.toStdString() << ", line: " << iErrorLine << ", column: " << iErrorColumn << endl; iFile.close(); return 2; }

      QDomDocument iDoc2 = iDomDocument.cloneNode( true ).toDocument();

      cout << "We are cool!" << endl;
      return 0;
      }

      after calling iDomDocument.cloneNode( true ).toDocument();
      my cpu usage goes to 50% (dual core processor) and memory usage started growing rapidly.

      Hope you will able to reproduce this.

      Regards
      Grzegorz Wolszczak

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            phartman Peter Hartmann (closed Nokia identity) (Inactive)
            grzechu81 Grzegorz Wolszczak
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes