Tests were leaking objects even if all tests passed. In two cases,
there just wasn't a delete at all, in a third, the existing delete
wasn't reached because of a QSKIP.
tst_QPropertyAnimation is now, locally, LSan-clean.
Pick-to: 6.3 6.2 5.15
Change-Id: Ia53d6f6e467f1d2598a7c50efcdf3a3732fe54df
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Qt's WinRT support was removed long time ago.
Change-Id: I60b220e970072c3450e3793862d6f68801d2b5b3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
QByteArray and QString honor a reserve(n) faithfully, meaning that if
n > capacity(), then capacity() == n after the reserve() call.
This is expected behavior, and also what libstdc++'s std::vector does.
The problem is QStringBuilder's op+=, which calls reserve()
unconditionally to ensure capacity for its resize-after-append
magic. If a user builds up a string by repeatedly appending
string-builder expressions, these repeated minimal-progress reserve
calls destroy the string's natural geometric capacity growth, turning
it linear instead, and hence the whole construction becomes quadratic.
Fix by calling reserve() only when necessary, and for a maximum of
O(logN) times, N being the separate calls to QStringBuilder's op+=.
This guarantees amortized-linear runtime of string building again.
Need to insert an explicit detach() call in reserve()'s stead, lest a
detach() in the following data() would reset capacity() to size().
Copied a useful comment from the QByteArray case to the QString case.
[ChangeLog][QtCore][QStringBuilder] Fixed quadratic behavior when
repeatedly appending string-builder expressions (using operator+=) to
QString/QByteArray objects.
Pick-to: 6.3 6.2
Change-Id: I1c210a8d0026c227e55e5e30a46fb747660bb66e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
This removes some calculations that are not required in
80% of the cases where d->erase() is being called (as
the return value is ignored). When removing lots of
elements from the hash, the ++it could loop quite a
bit until it found the next valid item in the hash.
This chain of changes combined improve the overall performance of
QHash by 10-50% depending on the operation. Deletes are twice
as fast, reads around 20% faster, inserts around 10% faster.
Task-number: QTBUG-91739
Fixes: QTBUG-98436
Change-Id: I2d82a7c9dd1dd0a4da8402e6d95bfd620caeff3a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Due to the way Qt 5 and 6 registered type names, they end up producing
different type names for the same content for a typedef. For example,
because Q_DECLARE_METATYPE can't manage a comma (it's a macro), users
are forced to write something like:
using MyTypeMap = QMap<QString, MyType>
Q_DECLARE_METATYPE(MyTypeMap)
Qt 5's Q_DECLARE_METATYPE's argument "MyTypeMap" was the only name we
knew about the type, so that's what got saved in the stream. However, Qt
6 QtPrivate::typenameHelper is much more clever and obtains the name
from the compiler itself, so it "sees through" the typedef and registers
"QMap<QString,MyType>" as the official type name.
If another library/plugin has a different typedef name for the same type
(e.g., StringTypeMap), it's indeterminate which type gets saved and will
even change from run to run (depends on the QHash order).
[ChangeLog][QtCore][QDataStream] If QDataStream is used with a
QDataStream::Version < Qt_6_0 to serialize a user type that was
registered via a typedef with the metatype system, the typedef's name is
used in the stream instead of the non-typedef name. This restores
compatibility with Qt 5, allowing existing content to read the same
QDataStreams; reading from older Qt 6 versions should not be affected.
(Note: if more than one typedef name is registered, it's indetermine
which name gets used)
Fixes: QTBUG-96916
Pick-to: 6.3 6.2
Change-Id: I2bbf422288924c198645fffd16a8d811aa58201e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
The result variable was expanded at configure time rather than at
script execution time due to missing escaping.
A tidbit of information, the result variable can contain not only an
exit code, but a string as well.
For example on arm macOS with a crashed test it contains
'SIGTRAP'.
Curiously if the crashing executable is executed directly without
CMake, 'Trace/BPT trap: 5' is shown instead, perhaps because of
the shell.
Amends 3ef6af024b
Pick-to: 6.2 6.3
Change-Id: I50e57922abfc6eccde205c6252eebfda510bad41
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
... and add some additional checks that hopefully leave the next
reader of the code a little less confused than this one was.
Pick-to: 6.3 6.2 5.15
Change-Id: I73c1b9b1ed1683e3b2de0d811d9b20d65464dff4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
By using the bucketForHash function we can loop through and find
some appropriate keys to test the edge-case. This will then
automatically keep the test working even if some internals
of QHash changes.
We do this because certain changes which change the bucket the
pre-selected keys would end up in could make the test a no-op,
without warning. And recent and upcoming changes have changed
both this and erase(). We limit the search-space to
the minimum numBuckets * 4, where minimum numBuckets is current
128.
Change-Id: I13b0bce15ee884144e3248846be34667fb5d35cc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Introduces a QHashPrivate::Data::Bucket class. This class
helps avoid repeated bitshift and masking operations when
locating bucket entries in the hash.
Change signature of some internal methods to use Bucket
instead of the private iterator, so we can avoid repeated
encoding/decoding steps for the bucket index.
Task-number: QTBUG-91739
Task-number: QTBUG-98436
Change-Id: I9ed2205bf886f9c20a5be109fd88456eec4d1540
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The result variable was expanded at configure time rather than at
script execution time due to missing escaping.
A tidbit of information, the result variable can contain not only an
exit code, but a string as well.
For example on arm macOS with a crashed test it contains
'SIGTRAP'.
Curiously if the crashing executable is executed directly without
CMake, 'Trace/BPT trap: 5' is shown instead, perhaps because of
the shell.
Amends 3ef6af024b
Pick-to: 6.2 6.3
Change-Id: I50e57922abfc6eccde205c6252eebfda510bad41
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
... and add some additional checks that hopefully leave the next
reader of the code a little less confused than this one was.
Pick-to: 6.3 6.2 5.15
Change-Id: I73c1b9b1ed1683e3b2de0d811d9b20d65464dff4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
If after.isNull(), then we called memcpy with a nullptr, which is UB,
even if the size is zero, too.
memmove() has the same precondition.
Fix by guarding the memcpy() call with an explicit length check.
The Qt 5.15 code is sufficiently different to not attempt to pick
there.
Pick-to: 6.3 6.2
Change-Id: I86a2f00ede6ca8fab8d4222f84dccf375c4a2194
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
It seems not needed anymore with modern toolchains.
Pick-to: 6.3
Change-Id: Ic5386cad4576b10f49fd74212f3514e26cfb0abe
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Both are FALSE by default, so no point in explicitly setting
them to FALSE.
In addition, dbus/listnames is a command line tool. No reason
to set WIN32_EXECUTABLE, MACOSX_BUNDLE here.
Pick-to: 6.3
Change-Id: I99aaf27a0267c5575bd2ee5b6183991fce721f44
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Building the example when not on android makes little
sense. Therefore just error out in this case.
Pick-to: 6.3
Change-Id: Ib7325156bcd8ffd1b9b3e67174d878f5731a4a4f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
We can't remove Q_GLOBAL_STATIC_WITH_ARGS, for compatibility reasons.
It's also the only way to pass uniform initialization (i.e., initialize
the value as value{with_braces}), though I don't think this is used
almost anywhere due to the fact that you couldn't pass more than one
argument. But Q_APPLICATION_STATIC is new in 6.3, so we have time to
change it.
[ChangeLog][QtCore][QGlobalStatic] The Q_GLOBAL_STATIC macro is now
variadic. Any extra arguments are used as constructor arguments,
obliterating the need to use Q_GLOBAL_STATIC_WITH_ARGS().
Pick-to: 6.3
Change-Id: Ib42b3adc93bf4d43bd55fffd16be3656a512fe53
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Use NSDMI and let the compiler generate the default ctor, too.
Statically assert that it's still noexcept (we marked it as such,
because MSVC still doesn't noexcept(auto) when an SMF is =default'ed.
Simplify the other ctors, too, relying on NSDMI. Keep one instance of
tailOffset(0), in the 'reserving' ctor, because it's inconsistent with
the other ctors which all do tailOffset{chunk.size()}, so it's best to
leave this explicit, lest the next reader wonders whether it was
forgotten.
Pick-to: 6.3
Change-Id: I0d9f91aa5bc89377c4144589df8786b502e956a4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Also regenerate the expected output for tst_selftests, to match new
output. Changed one line source code in tst_seftests for the
same purpose.
Change-Id: I930ba4bb290568d6f67a8910a781725f01f08bf1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Without the fix, some tests from tst_selftests were failing with:
Invalid MIT-MAGIC-COOKIE-1 key
Change-Id: I2d07f28d9b2c69fe8575fdf10b362d962f456970
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
These days, we perform the alias check unconditionally, so the remainder of the function can assume that *this and after do not overlap. So memcpy() suffices, we don't need memmove().
Pick-to: 6.3 6.2
Change-Id: Ib6966facfe643b0aaf50d902709f5fe926bed527
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
memcpy() mustn't be called with a nullptr, even if the size is zero.
Fixes ubsan error:
tst_qiodevice.cpp:561:15: runtime error: null pointer passed as argument 1, which is declared to never be null
Even though ubsan only complained about one of them, fix all three
occurrences of the pattern in the test.
Pick-to: 6.3 6.2 5.15
Change-Id: I5c06ab4a20a9e9f8831392c46c6969c05248fdac
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The first case is simple, as it's a static overflow. Theoretically,
the compiler would be allowed to just remove the complete function as
dead code. This is an error left from the port from int to qsizetype:
Qt 5.15 there has uint(MaxAllocSize) + 1, so use quint here again,
qint64 is wrong.
In the second case, we _may_ reach alloc == MaxAllocSize. Check that,
if we do, we don't then add 1 to it.
Pick-to: 6.3 6.2
Change-Id: I93044ed6f1b77559642fa1e4e8f313cf59eeeb79
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Was likely an oversight.
Amends 9f559699cc
Pick-to: 6.2 6.3
Change-Id: I13c2e4cc32e68c1ce98f59a932e3448250b0679b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
- add test resources to binaries
- link Qt::Gui to tst_qpointer for static build case
Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I311827b9c641eaf9537091b051c15f9fcbcb9f0c
Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
- There is no space symbol in the expression evaluation by GHS compiler.
Because of space in prefix constant, begin pointer is moved too far and
skips 1 letter in the class name. In result, on testing stage we see:
I/O: FAIL! : tst_QObject::property() Compared strings are not the same
I/O: Actual (property.typeName()) : ropertyObject::Alpha
I/O: Expected ("PropertyObject::Alpha"): PropertyObject::Alpha
Pick-to: 6.2 6.3
Change-Id: I52759860fd26b8d50df96dcc4ab0a6b005329a9f
Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Now that all platforms can deal with the full tst_QMetaType again,
remove the last traces of the workaround.
Pick-to: 6.3
Change-Id: I530cab8413f8b68903991b30a1f29b5871877a88
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The variable idx isn't used outside the respective loops, so make it loop-local.
Change-Id: I62807cb244b068ce4df42812a0e4b99a1f488adc
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Says ubsan:
qstring.cpp:10484:17: runtime error: applying non-zero offset 18446744073709551614 to null pointer
If we search for a null needle, we stored 0-1 in a size_t variable and
unconditionally appied that offset to the needle's data() pointer. That
being the nullptr, ubsan complained.
To fix, set sl_minus_1 to 0 if it would underflow. In that case,
sl_minus_1, n, and h, are not used, anyway, so their values don't
matter as long as we don't invoke UB.
Pick-to: 6.3 6.2 5.15
Change-Id: Idca4e845c77838dfc84acdb68bbbc98382b5e1d5
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QHash::operator[] could grow the hash even if the key being
looked up already existed. This in turn invalidated all iterators.
Avoid this by refactoring findOrInsert() to not grow if the key
already exists.
Added advantage is that this should make lookups of existing keys
slightly faster.
Fixes: QTBUG-97752
Pick-to: 6.3 6.2
Change-Id: I9df30459797b42c434ba0ee299fd1d55af8d2313
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Instead of returning the total number of logical processors in the
system, which we may not be allowed to wholly run on, use the affinity
set that the calling thread is allowed to use.
Implemented for Linux and FreeBSD only, with up to 4x the number of
processors than CPU_SETSIZE has as default (that would be 4096 logical
processors on Linux, 1024 on FreeBSD). Implementation for Windows is
possible, but the API there is always limited to 64, so I'm unsure if it
is correct. Darwin (macOS) does not have this capability.
Testing:
$ ./tst_qthread idealThreadCount | grep QDEBUG
QDEBUG : tst_QThread::idealThreadCount() Ideal thread count: 8
$ taskset 3 ./tst_qthread idealThreadCount | grep QDEBUG
QDEBUG : tst_QThread::idealThreadCount() Ideal thread count: 2
[ChangeLog][QtCore][QThread] idealThreadCount() will now return the
number of logical processors that the current process (thread) has
assigned in its affinity set, instead of the total number of processors
in the system. These two numbers can be different if the process is
launched by the parent with a different affinity set, with tools like
Linux's taskset(1) or schedtool(1). This is currently implemented for
Linux and FreeBSD.
Change-Id: I2cffe62afda945079b63fffd16bd086f64f5f314
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Simplifies further the code with C++11 unrestricted unions.
Pick-to: 6.3
Task-number: QTBUG-99122
Change-Id: Ib42b3adc93bf4d43bd55fffd16c0b6677441bf55
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
The Node::replace overloads and the Node::create method are not used
anywhere (including in QHash).
Pick-to: 6.2 6.3
Change-Id: I1f1f8c847c8f1181cd31d95d01997226f94b5fc4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Let the compiler generate the copy and move SMFs.
Statically assert that the move SMFs are still noexcept.
Pick-to: 6.3
Change-Id: I1c569bdf893a5f2cda972c0dd8196cab62494fcb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Let's see whether splitting the TUs has made the test amenable to be
compiled with MinGW again.
Pick-to: 6.3
Change-Id: Icde1bad20943c7648dbb119ca879bce62325bd6c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
It's only user, QRingBuffer::read(), calls it on an rvalue, so we
don't need the lvalue overload, and we can devil-may-care-like just
std::move(chunk) in the non-isShared() case.
Change-Id: I99c16862f5586125c6346ce5f969dc735de738b8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
These classes are used in their respective tests, but since these only
seem to access data members, the missing export macro was never
detected. UBSan, however, checks the type_info on each access, so it
needs the (polymorphic) class exported.
Do so (for -developer-builds).
Change-Id: I97b41cfb5dd7f1665cdf4f7a819a42fbf0388621
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Only individual members were exported, but that's not enough; ubsan
needs the vtable and type_info:
qtbase/src/plugins/tls/openssl/CMakeFiles/QTlsBackendOpenSSLPlugin.dir/qtls_openssl.cpp.o:(.data.rel+0x1f8): undefined reference to `typeinfo for QSslSocketPrivate'
Pick-to: 6.3 6.2
Change-Id: Ic22805af1ac7f4b3ad48532e4ba689d12ee4a4b9
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Just use the QByteArray(ptr, n) ctor instead of the (n,
Qt::Uninitialized) one + memcpy() + std::move().
Pick-to: 6.3
Change-Id: I127219c21556e683d15136f7e6f7b3576b7b2444
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
There's no sense in copying a ring buffer. Moving is enough. This
marks an important step on the way to preventing accidental copies of
ring buffer content, because the 'QList buffers' member can now no
longer be implicitly shared. While the compiler will still emit the
code for detach()ing, it will now never be executed.
Pick-to: 6.3
Change-Id: I968bfe3e50c46720ed4baca55c99c1f9c518f653
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The majority of append() callers in QtBase pass rvalues, so overload
append() to avoid the need for manipulating QBA's atomic ref counts.
Also adjust a caller that could pass by rvalue, but didn't, to do so.
Pick-to: 6.3
Change-Id: I3d9e60b0d04ef837bfdc526e1f0f691a151006f9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The only users of more than one read- or write channel are the SCTP
code and QProcess. SCTP being pretty rare, optimize for the common
case of at most two QRingBuffers for reading (QProcess) and one for
writing. Even with more channels, QVLA shouldn't be slower than QList
- on the contrary.
Need to adjust tst_toolsupport and TypeInformationVersion, as
QFilePrivate::fileName has changed.
Pick-to: 6.3
Change-Id: I3baf982ba1f4dc51463be8730e414f6164072d8b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The string returned from QStringView::utf16() is, in general, not
NUL-terminated, as OutputDebugString() requires. Though we only ever
call win_outputDebugString_helper() with an actual QString, it's not
100% clear said QString doesn't originate from, say, a QStringLiteral,
in which case QString::utf16() would have to (an does) detach() to
ensure the NUL-termination.
So, take by const QString&, but use QStringView::mid() to avoid
copying the substring content twice.
Amends a049325cc7.
Pick-to: 6.3 6.2 5.15
Change-Id: Ie42a6000c75c6a55d629621d89e0cf498b174d29
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This amends commit 0bea727cac or rather
reverts it and applies a different fix for QTBUG-98843.
Use file(WRITE) instead of configure_file or file(CONFIGURE). This
command doesn't have the line endings issues in CMake 3.19 (see
QTBUG-98843). It's not problematic that the .bat file gets a new
timestamp on every configuration step, since we don't add dependencies
on it.
Fixes: QTBUG-99223
Task-number: QTBUG-98843
Change-Id: Ibdcd0e4703bf6df42c6a6d0bb2f35c5144bbe30a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Without this, it won't compile with the -developer-build configure
option (warnings are errors)
Pick-to: 6.3 6.2
Change-Id: I114370e918d63bd6e8855b5f750999cf372e2f6d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Implement socket notifier support using Emscripten’s
socket callbacks.
This is sufficient for supporting non-blocking (tunneled)
TCP and UDP sockets on the main thread.
Change-Id: Ib9ee2698d029fb94d954c6872f8e118b0aa15499
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Emscripten implements support for tunneling TCP and
UDP sockets through a WebSockets connection. This support
is implement for the BSD sockets API, which means that
Qt’s existing socket classes can be used, with some
adjustments.
For example, the flow for making a TCP connection to
example.com:1515 can look like this:
1) The application resolves “example.com”.
Emscripten creates an internal mapping to a private
IP and returns that IP: 172.29.1.0.
2) The application connects to 172.29.1.0:1515.
Emscripten makes a WebSocket connection to example.com:1515,
and forwards the TCP data over this connection
3) On example.com:1515, a WebSockify intermediate server
accepts the WebScoket connection and forwards the
TCP data to the target sever, as specified by the
WebSockify configuration.
Emscripten’s local getaddrinfo() implementation is fast,
which means don’t need caching or the thread pool. Instead,
special-case lookupHostImpl() for Q_OS_WASM. The implementation
calls QHostInfoAgent::lookup() and then posts resultReady
using QHostInfoResult.
Change-Id: Iaf31efb701ae7cc11752a63cc6b8346d4f09107e
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>