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

Floating point in raster drawBitmap together with strict QImage::scanLine causes assertion "i >= 0 && i < height()"

    XMLWordPrintable

Details

    • Linux/X11
    • a43d86fe1 (dev), 824d29360 (6.7), 0f09f744b (6.6), bea4d640a (tqtc/lts-6.5), 17d29130b (tqtc/lts-6.2), d37f2b3a3 (tqtc/lts-5.15)

    Description

      Tested on CentOS7 Qt-5.12, but it seems that the same code ( drawBitmap(), scanLine(), qRound() ) appears in current Qt versions, too.

       

      There is partial back-trace in gdb:

      ...
      #3  0x00007f9ef2007f4b in QMessageLogger::fatal (this=this@entry=0x7ffd14334260, msg=msg@entry=0x7f9ef22c7788 "ASSERT: \"%s\" in file %s, line %d") at global/qlogging.cpp:887
      #4  0x00007f9ef2001493 in qt_assert (assertion=assertion@entry=0x7f9eee25cd86 "i >= 0 && i < height()", file=file@entry=0x7f9eee25cd64 "image/qimage.cpp", line=line@entry=1587) at global/qglobal.cpp:3201
      #5  0x00007f9eedeec4cd in QImage::scanLine (this=this@entry=0x277d4e0, i=19) at image/qimage.cpp:1587
      #6  0x00007f9eee0a372e in QRasterPaintEngine::drawBitmap (this=this@entry=0x101745a0, pos=..., image=..., fg=fg@entry=0x2fe9480) at painting/qpaintengine_raster.cpp:3492
      #7  0x00007f9eee0af83f in QRasterPaintEngine::drawPixmap (this=0x101745a0, pos=..., pixmap=...) at painting/qpaintengine_raster.cpp:2129
      #8  0x00007f9eee0c5b23 in QPainter::drawPixmap (this=0x7ffd14335270, p=..., pm=...) at painting/qpainter.cpp:5078
      #6  0x00007f9eee0a372e in QRasterPaintEngine::drawBitmap (this=this@entry=0x101745a0, pos=..., image=..., fg=fg@entry=0x2fe9480) at painting/qpaintengine_raster.cpp:3492

      ...

      (gdb) frame 6

      #6  0x00007f9eee0a372e in QRasterPaintEngine::drawBitmap (this=this@entry=0x101745a0, pos=..., image=..., fg=fg@entry=0x2fe9480) at painting/qpaintengine_raster.cpp:3492

      3492            const uchar *src = image.scanLine(y - qRound(pos.y()));
      (gdb) p w
      $4 = 24
      (gdb) p h
      $5 = <optimized out>          <- But it is 19
      (gdb) p ymax
      $6 = 46
      (gdb) p pos
      $8 = (const QPointF &) @0x7ffd14334b80: {xp = 110.89918919389669, yp = 26.499999999999996}
      (gdb) p y
      $9 = 45

      (gdb) frame 5
      #5  0x00007f9eedeec4cd in QImage::scanLine (this=this@entry=0x277d4e0, i=19) at image/qimage.cpp:1587
      1587        Q_ASSERT(i >= 0 && i < height());
      (gdb) p i
      $1 = 19

      The result for scanLine() is 19, so there is an assertion error inside:
      "i >= 0 && i < height()"

       

      I think that mixing floating point calculations for iterating together with strict scanLine() (without additional checks before), is not a good idea. Probably, the function drawBitmap() should iterate via existing image lines, but not via the calculated screen Y coordinate.

      Attachments

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

        Activity

          People

            vgt Eirik Aavitsland
            mirovski36 Martin Ottmar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: