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

CreateDIBSection causes application to exit when using too many QGraphicsProxyWidgets in a scene

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.12
    • QPA: Windows
    • None
    • Windows

    Description

      I have an application with a QGraphicsScene that will crash if there are too many items added. The minimum amount of structure the items need to cause a crash is a QGraphicsRectItem that parents a QGraphicsProxyWidget that has a QWidget inside it. A QGraphicsRectItem alone is not enough to cause the issue, it only seems to exist once the QGraphicsProxyWidget is added. The message I get when the application crashes is "createDIB: CreateDIBSection failed (100x70, format:6)".

      I've attached a minimum version of the code capable of causing the issue and it seems to reliably crash when 4991 items are added. Through some debugging I have discovered that the crash resides within qwindowsnativeimage.cpp when createDIB calls CreateDIBSection which unexpectedly returns NULL. There is code directly after this that logs the error with q_fatal causing the application to immediately exit. This suggests that it is known that CreateDIBSection could return NULL and the intended behavior is to exit, however, I cannot afford to have my application unexpectedly exit. I can't see any reason that the application should fail when using less that 5k proxy widgets in a scene when I seem to be able to add 100k QGraphicsRectItems (that don't have a proxy widget) to a scene with performance being the only limiting factor. This is also only an issue on Windows operating systems.

      Through further debugging I discovered that this issue seems to be somewhat related to the Windows GDI object limit. By default on Windows 10 the limit is 10,000 objects. I updated HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\GDIProcessHandleQuota to 20,000 and then I was able to add twice as many items to the scene before hitting the same CreateDIBSection crash.

      Additionally, I also start seeing lots of errors being logged after about 3300 items have been added to the scene but they do not seem to have any effect on the application. The most common error seen here is "WindowCreationData::create: CreateWindowEx failed (The current process has used all of its system allowance of handles for Window Manager objects.)"

      Attachments

        1. main.cpp
          2 kB
          Chemical Hamster
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            owolff Oliver Wolff
            chemicalhamster Chemical Hamster
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes