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

Access violation when drawing scaled images with certain dimensions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 4.5.3, 5.4.1
    • Fix Version/s: 5.9.5
    • Component/s: GUI: Painting
    • Labels:
      None

      Description

      When drawing certain QImages on a scaled painter with certain dimensions, an access violation occurs in qt_scale_image_32bit().

      The problem can be reproduced using the following test program using Qt 4.5.3 and Qt 4.6.2 on windows (32bit and 64bit). Under Linux, no access violation occurrs, but valgrind displays read errors in the same location the access violation occurs under windows (see the end of the case for the valgrind output).

      It runs without an error by modifying some of the parameters slightly (e.g. using a height of 661 pixels instead of 662 for the source image).

      #include <QPainter>
      
      int main(int argc, char *argv[])
      {
      	QImage srcImage( QSize( 923, 662 ), QImage::Format_RGB32 );
      	srcImage.fill(0);
      	QImage destImage( QSize( 71, 71 ), QImage::Format_RGB32 );
      	destImage.fill(0);
      	QPainter p( &destImage );
      	const double scale = 0.076923076923076927;
      	p.scale( scale, scale );
      	const QPointF offset( 0, 111.5 );
      	p.translate( offset );
      	p.drawImage( 0, 0, srcImage );
      }
      

      ==28594== Invalid read of size 4
      ==28594== at 0x42EC7F5: void qt_scale_image_32bit<Blend_RGB32_on_RGB32_NoAlpha>(unsigned char*, int, unsigned char const*, int, QRectF const&, QRectF const&, QRect const&, Blend_RGB32_on_RGB32_NoAlpha) (in /home/mdo/devel/repo sitory/source/cpp/External/Qt/4.5.3/linux/gcc34/lib/libQtGui.so.4)
      ==28594== by 0x42EB45D: qt_scale_image_rgb32_on_rgb32(unsigned char*, int, unsigned char const*, int, QRectF const&, QRectF const&, QRect const&, int) (in /home/mdo/devel/repository/source/cpp/External/Qt/4.5.3/linux/gcc34/lib /libQtGui.so.4)
      ==28594== by 0x43983D6: QRasterPaintEngine::drawImage(QRectF const&, QImage const&, QRectF const&, QFlags<Qt::ImageConversionFlag>) (in /home/mdo/devel/repository/source/cpp/External/Qt/4.5.3/linux/gcc34/lib/libQtGui.so.4)
      ==28594== by 0x43950A1: QRasterPaintEngine::drawImage(QPointF const&, QImage const&) (in /home/mdo/devel/repository/source/cpp/External/Qt/4.5.3/linux/gcc34/lib/libQtGui.so.4)
      ==28594== by 0x432226B: QPainter::drawImage(QPointF const&, QImage const&) (in /home/mdo/devel/repository/source/cpp/External/Qt/4.5.3/linux/gcc34/lib/libQtGui.so.4)
      ==28594== by 0x8048CBA: QPainter::drawImage(int, int, QImage const&, int, int, int, int, QFlags<Qt::ImageConversionFlag>) (qpainter.h:887)
      ==28594== by 0x8048BA0: main (main.cpp:12)
      ==28594== Address 0x70ec728 is not stack'd, malloc'd or (recently) free'd
      ==28594==
      ==28594== ERROR SUMMARY: 3 errors from 1 contexts (suppressed: 75 from 2)

        Attachments

        1. qt-qblendfunctions.patch
          2 kB
        2. main.cpp
          0.4 kB

          Issue Links

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

            Activity

              People

              Assignee:
              vgt Eirik Aavitsland
              Reporter:
              mdoppler Michael Doppler
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes