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

QWebView::setUrl() crashes application when passed local directory

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P2: Important
    • None
    • 5.0.2
    • WebKit
    • None

    Description

      In certain cases calling QWebView::setUrl(QUrl("file:///<directory>")) causes Qt to crash.

      When QWebView::setUrl() is called on a local text file, followed by a call to setUrl() specifying a local file that happens to be a directory, the entire Qt application crashes.

      For example, the following sequence of calls will crash Qt:

      QWebView wv;
      wv.setUrl(QUrl("file:///C:/Windows/win.ini"));
      wv.setUrl(QUrl("file:///C:/Windows"));
      wv.show();

      Assuming that C:/Windows/win.ini and C:/Windows exist. Interestingly enough if the setUrl("...win.ini") call is missing the application does not crash.

      A temporary workaround for users of Qt is to never call setUrl() on a directory. In the long term Qt should not crash on this input.

      The following errors were detected in the QtCreator application output:

      Starting D:\code\build-seturl-crash-test-case-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\seturl-crash-test-case...
      QIODevice::read: maxSize argument exceeds QByteArray size limit
      Invalid parameter passed to C runtime function.
      Invalid parameter passed to C runtime function.
      terminate called after throwing an instance of 'std::bad_alloc'
      what(): std::bad_alloc
      LEAK: 3 RenderObject
      LEAK: 1 Page
      LEAK: 1 Frame
      LEAK: 4 WebCoreNode
      D:\code\build-seturl-crash-test-case-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\seturl-crash-test-case exited with code 3

      This crash only happens when running the application inside Qt Creator with <CTRL>-R. It does not happen when running it in the debugger using <F5>.

      The crash symptom on Windows is that an error dialog shows up, followed by a force quit. Screenshots of both are attached to this ticket.

      I was unfortunately unable to obtain a stack trace.

      Attachments

        1. main.cpp
          0.3 kB
          Francis Anthill
        2. crash-3.png
          71 kB
          Francis Anthill
        3. crash-2.png
          77 kB
          Francis Anthill
        4. crash-1.png
          79 kB
          Francis Anthill
        5. components.xml
          4 kB
          Francis Anthill
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            annulen Konstantin Tokarev
            francisanthill Francis Anthill
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes