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

QPixmap::fromImage() crashes in low memory situations

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.0.0
    • 4.8.1
    • Image formats
    • None
    • Qt 4.8.1, Win7 64bit, 2GB RAM, AMD CPU
    • c44d7eedfdfa80598c877bd2a708a8f126c25fc4

    Description

      This code produces a segfault:

      QPixmap pixmap = QPixmap::fromImage(image);

      where image is quite large, has an alpha channel and my memory is already pretty used up.

      I tracked the error through

      qpixmap.cpp line 2088: data->fromImage(image, flags);
      qpixmap_raster.cpp line 156: createPixmapForImage(image, flags, /* inplace = */false);
      qpixmap_raster.cpp line 459: sourceImage.d->format = QImage::Format_RGB32;

      And the the segfault occurs, because sourceImage.d is null.

      What happens is that the detaching (in line 458) tries to copy the image to get rid of the alpha channel, but on my machine there is not enough memory for that. As result, the image is null after detaching. This case is not checked/catched in QRasterPixmapData::createPixmapForImage().

      I'm not sure if conversion should happen in place to avoid this situation, or if this error actually can happen im low memory condition and therefore should be catched.

      Greetings,

      Gregor

      Attachments

        Issue Links

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

          Activity

            People

              kkalland Kim Motoyoshi Kalland (Inactive)
              grefab Gregor Fabritius
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes