VirtualBox

Changeset 99448 in vbox


Ignore:
Timestamp:
Apr 19, 2023 12:49:35 AM (20 months ago)
Author:
vboxsync
Message:

FE/Qt: Explanation of the QPointer heap issue when using a debug Qt build on windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r99446 r99448  
    23712371#if 1 /* With a debug Qt 5.15.2 (r175) build and paged heap on windows, the ~QPointer destructor will trigger heap corruption
    23722372         (VERIFIER STOP 0000000000000010: pid 0x253C: corrupted start stamp).  Clearing the QPointer prior to deletion works
    2373          around the issue (calling clear() after delete just triggers the problem a few lines earlier). */
     2373         around the issue (calling clear() after delete just triggers the problem a few lines earlier).
     2374
     2375         Update: The issue is using different allocator and free heap routines.   When using a debug Qt build on windows,
     2376                 it is linked against the debug runtime DLL (ucrtbased.dll), while this code is still using the release
     2377                 runtime DLL (ucrtbase.dll).  The QtSharedPointer::ExternalRefCountData instance is allocated by
     2378                 Qt5CoreVBoxd!QtSharedPointer::ExternalRefCountData::getAndRef() using the debug heap allocator, which adds
     2379                 an additional 48 byte header on the object.  When we delete and the clear/destroy the QPointer instance
     2380                 here, we'll be doing the freeing, but since we don't link with ucrtbased.dll, we'll use the regular
     2381                 heap routines that doesn't expect a 48 byte header and they probably think we're handing them a garbage
     2382                 pointer.
     2383
     2384                 The workaround here, moves the deleting of the QtSharedPointer::ExternalRefCountData structure from
     2385                 this module to the QObject destructor, which lives in the same module as where it was allocated and
     2386                 will be using the same allocator.  So, either we subclass the QPointer<> template and formalize this
     2387                 pattern a bit better, so a workaround can be done in one place, or we do some build time / makefile
     2388                 checks for this and forces the use of the debug CRT for the whole of VBox as well (not all that tempting)... */
    23742389    QIMessageBox *pSafe = pMessageBox;
    23752390    pMessageBox.clear();
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette