qt6-bb10/tests/auto/corelib/tools
Marc Mutz ca216b7bed QDuplicateTracker: shed memory_resource on clear()
The pmr::monotonic_buffer_resource ("pmr::mbr") strategy can only
allocate buffers; deallocation is a no-op. I chose it for
QDuplicateTracker because the tool was only used one-off: build it,
then destroy it. There were no other operations.

That changed when 090c7e3262 added
clear().

Calling pmr::unordered_set::clear() will deallocate the nodes (but not
the bucket array), but due to pmr::mbr, nothing is actually
deallocated, so memory that was freed by the container isn't actually
reused by it, later. IOW: repeated grow-clear-grow-clear cycles would
forever grow the monotonic_muffer_resource, using more and more memory
and thus appear to be leaking it.

This isn't exactly optimal behavior, so try to shed the pmr::mbr's
extra memory with a call to mbr::release().

Unfortunately, C++17 originally failed to nail down the semantics of
pmr::mbr::release(), prompting LWG 3120 in response to observed
implementation divergence. In particular, MSSTL, at the time of LWG
3120 filing, didn't appear to allow to allocate() after release(). In
our tests, it does allow it, it just never falls back to the original
(stack) buffer, and, looking at the implementation, it doesn't look
like it can do so anytime soon (it doesn't remember the buffer, and
everything is inline, so they would seem to need a BC break to fix it.

We tried to work-around the problem by hard-resetting 'res' by going
through a destroy-recreate cycle. pmr::mbr is neither copy- nor
move-constructible, so that blunt instrument is, unfortunately,
necessary (std::optional would be an alternative, but has overhead
that affects all platforms). This crashed, though, so just call
release() and handle MSSTL's failure to reuse the initial buffer as a
QoI issue.

For all platforms, before release(), we also need to make sure that
`set` no longer holds any references into it, and, since clear()
doesn't shed capacity, we need to use the C++11 version of the
swap-trick (swap is actually UB here, because the allocators differ):
move-assign a default-constructed set.

Amends 090c7e3262.

Fixes: QTBUG-132945
Pick-to: 6.5 6.2
Change-Id: I4796806e427602255439dcb1518aa9b661c7933e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 9f4325e67354ce6c4c98e7a206f17729b378dc04)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit d2c4f6df21629495ce6fe32653037b35a989d6f4)
2025-01-31 14:06:20 +00:00
..
collections tst_collections.cpp: fix RecursiveList comparison case 2024-12-04 15:14:25 +00:00
containerapisymmetry QHash: adapt to C++20 ranges not offering operator->() 2024-08-20 01:28:02 +00:00
qalgorithms Change license for tests files 2024-02-04 09:56:42 +01:00
qarraydata Change license for tests files 2024-02-04 09:56:42 +01:00
qatomicscopedvaluerollback Change license for tests files 2024-02-04 09:56:42 +01:00
qbitarray Tests: disable various compiler warnings 2024-07-12 00:48:40 +00:00
qcache Change license for tests files 2024-02-04 09:56:42 +01:00
qcommandlineparser QCommandLineParser: include the positional arguments' sizes in --help 2024-12-20 04:30:30 +00:00
qcontiguouscache Change license for tests files 2024-02-04 09:56:42 +01:00
qcryptographichash QCryptographicHash: hashInto(): check the buffer size earlier 2025-01-01 04:02:35 +00:00
qduplicatetracker QDuplicateTracker: shed memory_resource on clear() 2025-01-31 14:06:20 +00:00
qeasingcurve QEasingCurve: use comparison helper macros 2024-05-10 16:31:28 +02:00
qexplicitlyshareddatapointer Change license for tests files 2024-02-04 09:56:42 +01:00
qexplicitlyshareddatapointerv2 QExplicitlySharedDataPointerV2: Add unit-tests 2024-07-16 15:37:55 +00:00
qflatmap Change license for tests files 2024-02-04 09:56:42 +01:00
qfreelist QFreeList: return timer IDs with the serial included 2024-10-19 06:50:26 +00:00
qhash QHash: Unconceptify heterogeneous search code 2024-09-06 15:55:07 +00:00
qhashfunctions Fix QT_SUPPORTS_INT128 checks 2024-08-07 19:57:04 +00:00
qhashseed Fix test compilation issues with QtLite configuration 2024-05-06 14:29:02 +00:00
qline Tests: suppress has_denorm deprecation 2024-09-06 14:38:21 +00:00
qlist QList: fix std::to_address(QList::iterator) on older compilers 2024-10-29 01:10:27 +00:00
qmacautoreleasepool Change license for tests files 2024-02-04 09:56:42 +01:00
qmakearray Change license for tests files 2024-02-04 09:56:42 +01:00
qmap QMap: add missing qHash() overload 2024-02-09 20:33:05 +00:00
qmargins QMarginsF: add qFuzzyCompare and qFuzzyIsNull overloads 2024-05-10 15:33:40 +02:00
qmessageauthenticationcode Change license for tests files 2024-02-04 09:56:42 +01:00
qoffsetstringarray QOffsetStringArray: fix off-by-one error for the past-the-end elements 2024-07-25 20:06:41 +00:00
qpair Change license for tests files 2024-02-04 09:56:42 +01:00
qpoint QPoint(F): use comparison helper macros 2024-05-10 15:33:39 +02:00
qpointf Add qFuzzyCompare() and qFuzzyIsNull() overloads for QPointF 2024-05-10 15:33:39 +02:00
qqueue Change license for tests files 2024-02-04 09:56:42 +01:00
qrect QDebug: do not trigger integer overflow when printing a QRect 2025-01-29 10:50:18 +00:00
qringbuffer Change license for tests files 2024-02-04 09:56:42 +01:00
qscopedpointer Change license for tests files 2024-02-04 09:56:42 +01:00
qscopedvaluerollback Change license for tests files 2024-02-04 09:56:42 +01:00
qscopeguard Change license for tests files 2024-02-04 09:56:42 +01:00
qset QSet: don't detach in remove()/removeIf() if nothing is being removed 2025-01-31 14:06:18 +00:00
qsharedpointer Don't increase the refcount if qobject_cast failed 2024-09-05 12:29:51 +00:00
qsize QSize(F): use comparison helper macros 2024-05-14 14:33:21 +02:00
qsizef QSizeF: add qFuzzyCompare and qFuzzyIsNull overloads 2024-05-14 14:33:21 +02:00
qspan tst_QSpan: check QList<int> -> QSpan<const int> doesn't detach the former 2024-12-25 07:37:44 +00:00
qstl Change license for tests files 2024-02-04 09:56:42 +01:00
qtaggedpointer Change license for tests files 2024-02-04 09:56:42 +01:00
qtimeline Change license for tests files 2024-02-04 09:56:42 +01:00
qtyperevision QTypeRevision: fix support for 8-bit signed segments 2024-09-14 16:38:08 +00:00
quniquehandle Compare QUniqueHandles using comparesEqual and compareThreeWay 2025-01-22 19:31:26 +00:00
qvarlengtharray QVarLengthArray: re-publish Prealloc as a nested PreallocatedSize 2024-02-15 17:44:36 +00:00
qversionnumber QVersionNumber: use new comparison helper macros 2024-05-06 22:47:55 +02:00
CMakeLists.txt QExplicitlySharedDataPointerV2: Add unit-tests 2024-07-16 15:37:55 +00:00