summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin
Commit message (Collapse)AuthorAgeFilesLines
* QFactoryLoader: remove the porting hack to complete the port to CBORThiago Macieira2021-11-042-20/+5
| | | | | Change-Id: I3eb1bd30e0124f89a052fffd16a6f632c62bcef5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPluginLoader/ELF: fix Clang ASan buildsThiago Macieira2021-11-041-1/+9
| | | | | | | | | | | | | | | | | | | Clang aligns the object at 32-byte boundaries even though we specifically asked for alignof(void*), so tell it not to sanitize the address of the plugin object. Tested with Clang 12 and 13. GCC seems not to be affected, even when ASan is enabled. If this doesn't work, we may need to accept reading a note that is improperly aligned. I don't think the output will be actually a correct note because the intra-note alignment will be wrong (I carefully chose the ELF note name so it would not require alignment, but that's only valid up to 8-byte alignments). Fixes: QTBUG-97941 Change-Id: Ice04365c72984d07a64dfffd16b422fe074d8a70 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QFactoryLoader: continue the port from JSON to CBORThiago Macieira2021-10-203-20/+43
| | | | | | | | | | | | | | This continues the effort from the previous commit, by not passing through the JSON conversion at all, and simply using CBOR directly. The port in qtbase is complete, but in order to support the conversion in other modules without introducing breakages, there's a temporary class used for converting to QPluginParsedMetaData from QJsonObject. It'll be removed once all other modules have finished converting. Change-Id: I2de1b4dfacd443148279fffd16a3ed4ddaf34afc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: keep the CBOR data as CBORThiago Macieira2021-10-206-78/+110
| | | | | | | | | | Since QJsonValue and QCborValue use the same backend, we may as well use the CBOR frontend classes, which means we avoid an unnecessary conversion until later. Change-Id: I2de1b4dfacd443148279fffd16a3e2f56cd74c0b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPluginLoader: use constexpr variables for detecting debug pluginsThiago Macieira2021-10-181-10/+14
| | | | | | | | | | | For MSVC it's clear that the plugin and Qt must match, since they would be linking to different runtime assemblies otherwise. For all other systems, including MinGW on Windows, there's no such thing. But we insist on MinGW debug-and-release builds matching. Change-Id: I3eb1bd30e0124f89a052fffd16a6aa52c7f8b9c0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: Move the plugin metadata to a note in ELF platformsThiago Macieira2021-10-182-17/+249
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few systems, like OpenWRT, may strip the section table off the resulting binaries (see [1]), making it impossible for us to pinpoint the exact location of the Qt plugin metadata. This commit moves the meta data to a location that is identifiable even in fully stripped binaries: an ELF note. By naming our section ".note.qt.metadata", we instruct the linker to place it along the other notes and to mark it in the program header section. Another advantage is that the notes are usually in the very beginning of the file, as they are used by the dynamic linker itself, so we'll need to read much less of the full contents. The unit test is modified not to attempt to strip the plugin of debugging data. In fact, we add something to the end that would, otherwise, be matched as (invalid) metadata. The following was produced with GCC 11 and GNU binutils ld 2.36.1. Section Headers: [Nr] Name Type Addr Off Size ES Flags Lk Inf Al [ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0 [ 1] .note.gnu.property NOTE 00000000000002a8 000002a8 00000030 0 A 0 0 8 [ 2] .note.gnu.build-id NOTE 00000000000002d8 000002d8 00000024 0 A 0 0 4 [ 3] .note.qt.metadata NOTE 00000000000002fc 000002fc 000001ac 0 A 0 0 4 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align ... NOTE 0x0002a8 0x00000000000002a8 0x00000000000002a8 0x000030 0x000030 R 0x8 NOTE 0x0002d8 0x00000000000002d8 0x00000000000002d8 0x0001d0 0x0001d0 R 0x4 The Qt metadata note is 4-byte aligned and can thus be found in the second note section, which spans from 0x02d8 to 0x02d8+0xac=0x0384. GNU readelf -n can even show it: Displaying notes found in: .note.qt.metadata Owner Data size Description qt-project! 0x0000018f Unknown note type: (0x74510001) description data: 01 06 03 81 bf ...... ff I chose 0x7451 as the prefix for our notes, even though they're already namespaced by the owner in the first place, because eu-readelf mistakenly tries to interpret note 1 as a GNU ABI tag regardless of owner. The owner name was chosen to be 12 bytes long, so the ELF note header is 24 bytes in total. There's no space wasted because the payload needs to be aligned to 32-bit anyway and I didn't want to use only 4 characters (header total size 16 bytes) so we'd skip the "GNU" note on size, without string comparison. And I couldn't think of a 4-character representative string ("QtP" ?). [1] https://github.com/openwrt/video/issues/1 Fixes: QTBUG-96327 Change-Id: I2de1b4dfacd443148279fffd16a3987729346567 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: add qt_plugin_query_metadata_v2() to dynamic pluginsThiago Macieira2021-10-112-13/+29
| | | | | | | | | | They return a pointer to the actual header, skipping the magic string. This is done in preparation for the header located in an ELF note, which won't have the magic. Change-Id: I3eb1bd30e0124f89a052fffd16a8229bec2ad588 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: suppress the "QTMETADATA !" magic in static pluginsThiago Macieira2021-10-112-6/+17
| | | | | | | | | | | | | | | | The .qtmetadata section is already suppressed for static plugins, but we carried this unnecessary magic string. For library file formats where we don't have a scanner (Windows COFF PE), a library that linked multiple static plugins could end up with multiple metadata found. We can't suppress the header because the version of moc could be different to the version of Qt, so we need to read the header version too. Right now, the version isn't output by moc (all the logic is in qplugin.h), but this could change again in the future. In any case, 4 extra bytes are not a big deal, so the header stays. Change-Id: I3eb1bd30e0124f89a052fffd16a82088d8303081 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QElfParser: rewrite using elf.hThiago Macieira2021-10-063-167/+499
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This rewrite uses the actual structures supplied by the system's C library, so it should be easier to read. It removes hardcoded constants with little evident meaning in favor of sizeof() and the macros from that header. It also removes advancing the data pointer in favor of having absolute offsets. The resulting implementation is stricter than the original, checking more fields in the header. Because the QPluginLoader and QFactoryLoader users may make decisions based on availability of plugins before attempting to load them, it's better to be stricter here than to fail later when trying to dlopen() them. Debugging and testing are much improved. Instead of stored artifacts, I added a routine to modify a valid plugin to make it invalid, given the conditions we've found so far. If you turn debugging on for this category, you'll see things like: not-elf.fcqdMq.so : Not an ELF file (invalid signature) wrong-word-size.QrnSAx.so : ELF 32-bit LSB (GNU/Linux), version 1, shared library or PIC executable, x86-64 invalid-word-size.bOkXvp.so : Invalid ELF file (class 0), LSB (GNU/Linux) unknown-word-size.ogYKeF.so : Invalid ELF file (class 66), LSB (GNU/Linux) wrong-endian.owiElX.so : ELF 64-bit MSB (GNU/Linux), version 1, shared library or PIC executable, x86-64 invalid-endian.FRxClR.so : ELF 64-bit invalid endianness (0) (GNU/Linux) unknown-endian.FfvRrP.so : ELF 64-bit invalid endianness (65) (GNU/Linux) elf-version-0.gPTdpQ.so : ELF 64-bit LSB (GNU/Linux), file version 0 elf-version-2.jlIUUg.so : ELF 64-bit LSB (GNU/Linux), file version 2 executable.LlXiFp.so : ELF 64-bit LSB (GNU/Linux), version 1, executable, x86-64 relocatable.UsOYuy.so : ELF 64-bit LSB (GNU/Linux), version 1, relocatable, x86-64 core-file.hqvNRz.so : ELF 64-bit LSB (GNU/Linux), version 1, core dump, x86-64 invalid-type.CIJgfS.so : ELF 64-bit LSB (GNU/Linux), version 1, unknown type 259, x86-64 wrong-arch.UcNmgz.so : ELF 64-bit LSB (GNU/Linux), version 1, shared library or PIC executable, AArch64 file-version-0.lZYuda.so : ELF 64-bit LSB (GNU/Linux), version 0, shared library or PIC executable, x86-64 file-version-2.ucfdwL.so : ELF 64-bit LSB (GNU/Linux), version 2, shared library or PIC executable, x86-64 no-sections.rSjsHh.so : ELF 64-bit LSB (GNU/Linux), version 1, shared library or PIC executable, x86-64 no-sections.rSjsHh.so : contains 0 sections of 64 bytes at offset 0 ; section header string table (shstrtab) is entry 0 no-sections.rSjsHh.so : no section table present, not able to find Qt metadata qtmetadata-executable.vrxcIf.so : ELF 64-bit LSB (GNU/Linux), version 1, shared library or PIC executable, x86-64 qtmetadata-executable.vrxcIf.so : contains 42 sections of 64 bytes at offset 997256 ; section header string table (shstrtab) is entry 41 qtmetadata-executable.vrxcIf.so : shstrtab section is located at offset 996831 size 423 qtmetadata-executable.vrxcIf.so : section 0 name "" type NULL flags X offset 0x0 size 0x0 qtmetadata-executable.vrxcIf.so : section 1 name ".note.gnu.property" type NOTE flags AX offset 0x2a8 size 0x30 qtmetadata-executable.vrxcIf.so : section 2 name ".note.gnu.build-id" type NOTE flags AX offset 0x2d8 size 0x24 qtmetadata-executable.vrxcIf.so : section 3 name ".hash" type HASH flags AX offset 0x300 size 0x44c qtmetadata-executable.vrxcIf.so : section 4 name ".gnu.hash" type 0x6ffffff6 flags AX offset 0x750 size 0x3b8 qtmetadata-executable.vrxcIf.so : section 5 name ".dynsym" type DYNSYM flags AX offset 0xb08 size 0xd50 qtmetadata-executable.vrxcIf.so : section 6 name ".dynstr" type STRTAB flags AX offset 0x1858 size 0x15d8 qtmetadata-executable.vrxcIf.so : section 7 name ".gnu.version" type 0x6fffffff flags AX offset 0x2e30 size 0x11c qtmetadata-executable.vrxcIf.so : section 8 name ".gnu.version_r" type 0x6ffffffe flags AX offset 0x2f50 size 0xb0 qtmetadata-executable.vrxcIf.so : section 9 name ".rela.dyn" type RELA flags AX offset 0x3000 size 0x480 qtmetadata-executable.vrxcIf.so : section 10 name ".rela.plt" type RELA flags AX offset 0x3480 size 0x7e0 qtmetadata-executable.vrxcIf.so : section 11 name ".init" type PROGBITS flags AX offset 0x4000 size 0x1b qtmetadata-executable.vrxcIf.so : section 12 name ".plt" type PROGBITS flags AX offset 0x4020 size 0x550 qtmetadata-executable.vrxcIf.so : section 13 name ".plt.got" type PROGBITS flags AX offset 0x4570 size 0x8 qtmetadata-executable.vrxcIf.so : section 14 name ".text" type PROGBITS flags AX offset 0x4580 size 0x110e qtmetadata-executable.vrxcIf.so : section 15 name ".fini" type PROGBITS flags AX offset 0x5690 size 0xd qtmetadata-executable.vrxcIf.so : section 16 name ".rodata" type PROGBITS flags AX offset 0x6000 size 0x473 qtmetadata-executable.vrxcIf.so : section 17 name ".qtversion" type PROGBITS flags AX offset 0x6478 size 0x10 qtmetadata-executable.vrxcIf.so : section 18 name ".qtmetadata" type PROGBITS flags AX offset 0x64a0 size 0x19b qtmetadata-executable.vrxcIf.so : found .qtmetadata section qtmetadata-writable.stzwrk.so : ELF 64-bit LSB (GNU/Linux), version 1, shared library or PIC executable, x86-64 Change-Id: I42eb903a916645db9900fffd16a4437af9728eea Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: pass the direct header to qJsonFromRawLibraryMetaData()Thiago Macieira2021-10-045-7/+23
| | | | | | | | This is done in preparation for storing the metadata without the magic string in static plugins and in ELF notes. Change-Id: I3eb1bd30e0124f89a052fffd16a820454dd56d3e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: add error messages to the qt_get_metadata()Thiago Macieira2021-10-041-6/+7
| | | | | | | This is the already-loaded counterpart to the file scanning code Change-Id: I3eb1bd30e0124f89a052fffd16a81f518fa95f0d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: simplify handling of exact results from Q{Elf,Mach}ParserThiago Macieira2021-10-042-41/+27
| | | | | | | | | | Those two scanners always return exact results, if the metadata is present, so we don't need to re-scan (haven't needed since Qt 5.0). Especially since we scan from the end, we were spending cycles doing unnecessary work. Change-Id: I42eb903a916645db9900fffd16a4ccfdc7342278 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Q{Elf,Mach}Parser: harmonize the arguments passedThiago Macieira2021-10-045-69/+51
| | | | | | | | | | | | | | Both functions took a QString for the input file name, but while the ELF parser had an optional QLibrary pointer (which was never null) where to store the error string, the Mach-O parser received a pointer to a QString. So make both of them take a single in/out QString pointer, which has the file name on input and is cheap for us because of COW. Drive-by fix the name of the static function in qmachparser.cpp from "ns" (which stood for "not suitable") to "notfound". Change-Id: I3eb1bd30e0124f89a052fffd16a8182f4f8541c3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: update the arch requirements to match the x86-64 ISA levelsThiago Macieira2021-10-043-7/+79
| | | | | | | | | | When we created the functionality, the levels were not yet standardized. Now they are and you can use -march=x86-64-v3 (for example) to get to them. We're making a split between "v1" and "baseline" here for the benefit of 32-bit, which is not included in the ISA levels. Change-Id: I2de1b4dfacd443148279fffd16a397a700b9a15a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: use one global metadata magic stringThiago Macieira2021-10-042-34/+20
| | | | | | | And use QByteArrayView where applicable. Change-Id: I2de1b4dfacd443148279fffd16a39ec22908f75f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: move some of the logic from moc's output to qplugin.hThiago Macieira2021-10-041-8/+68
| | | | | | | | | | | | | | This will allow us to make changes in QtCore itself, without having to worry about moc compatibility. The output uses an #ifdef so this version of moc can still be used to compile earlier versions of Qt (usually, in cross-compilation environments). See discussion in the mailing list[1]. [1] https://lists.qt-project.org/pipermail/development/2021-September/041732.html Change-Id: I2de1b4dfacd443148279fffd16a39784c80c5f3b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: change the generic metadata scan to forwardsThiago Macieira2021-10-041-30/+10
| | | | | | | | | | | The reason it scanned backwards was valid, but unfortunately that doesn't work if the metadata magic appears in the debug info that comes after the metadata. Task-number: QTBUG-67461 Change-Id: I2bbf422288924c198645fffd16a9276767ca2589 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* src/corelib/plugin: sort #includesThiago Macieira2021-10-047-44/+40
| | | | | Change-Id: I2de1b4dfacd443148279fffd16a3e4bdb1a49f88 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: reorganize findPatternUnloaded and remove two bool variablesThiago Macieira2021-09-241-16/+9
| | | | | | | | The compiler ought to figure them out, but we can just help it. Change-Id: I42eb903a916645db9900fffd16a4981ac966f982 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Q{Elf,Mach}Parser: simplify the return codesThiago Macieira2021-09-246-73/+57
| | | | | | | | | | | | | | | | | The multi-state return code was a legacy of how Arvid wrote the ELF parser code back in the day, the fact that it scanned for two different types of plugins in Qt 4 and that the metadata could exist in different places. None of that matters nowadays: who cares if the file is a corrupt binary, not a valid binary, does not have the right architecture, or has no suitable section? It's not a plugin, period. The Qt 4 plugin mechanism was removed for Qt 5.0 in commit 7443895857fdaee132c8efc643e471f02b3d0fa4 ("Remove support for Qt 4 style plugins"). Change-Id: I42eb903a916645db9900fffd16a442d800399b98 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QPlugin: don't use QFile::read() if map() fails on UnixThiago Macieira2021-09-241-2/+15
| | | | | | | | If we can't mmap(), then libdl won't be able to either. Pick-to: 6.2 Change-Id: I42eb903a916645db9900fffd16a492a1ac25903f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Switch a comma operator to a IILEGiuseppe D'Angelo2021-09-191-1/+1
| | | | | | | | | A comma operator results in a discarded-value expression, meaning the compiler is going to complain the moment we mark QMutexLocker as nodiscard. Turn the comma into a functionally equivalent IILE. Change-Id: I33826902c8471016490aac25160b70c609dafd90 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Don't unload libraries on Darwin-based operating systemsTor Arne Vestbø2021-09-171-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can't guarantee that the library didn't define Objective-C classes that still have lingering references, resulting in warnings such as: Attempt to use unknown class 0x10e52e110. And possibly crashes such as: thread #1, queue = 'com.apple.main-thread' frame #0: 0x00007fff203829ee libsystem_kernel.dylib`__ulock_wait + 10 frame #1: 0x00007fff203fa0c5 libsystem_platform.dylib`_os_unfair_lock_lock_slow + 162 frame #2: 0x00007fff2026226b libobjc.A.dylib`unmap_image + 85 frame #3: 0x000000010001e11f dyld`dyld::removeImage(ImageLoader*) + 557 frame #4: 0x000000010002291d dyld`dyld::garbageCollectImages() + 956 frame #5: 0x000000010002e35d dyld`dlclose + 191 frame #6: 0x00007fff203cf1c9 libdyld.dylib`dlclose + 183 frame #7: 0x0000000103f9f2f1 libQt6Core_debug.6.dylib`QLibraryPrivate::unload_sys(this=0x000000011ba2c7d0) at qlibrary_unix.cpp:294:9 frame #8: 0x0000000103f93f3f libQt6Core_debug.6.dylib`QLibraryPrivate::unload(this=0x000000011ba2c7d0, flag=UnloadSys) at qlibrary.cpp:614:36 frame #9: 0x0000000103f971fb libQt6Core_debug.6.dylib`QLibraryStore::cleanup() at qlibrary.cpp:425:22 frame #10: 0x0000000103f970f9 libQt6Core_debug.6.dylib`qlibraryCleanup() at qlibrary.cpp:447:5 frame #11: 0x0000000103f970d1 libQt6Core_debug.6.dylib`(anonymous namespace)::qlibraryCleanup_dtor_class_::~qlibraryCleanup_dtor_class_(this=0x00000001041edd38) at qlibrary.cpp:449:1 frame #12: 0x0000000103f930f5 libQt6Core_debug.6.dylib`(anonymous namespace)::qlibraryCleanup_dtor_class_::~qlibraryCleanup_dtor_class_(this=0x00000001041edd38) at qlibrary.cpp:449:1 frame #13: 0x00007fff202e5d25 libsystem_c.dylib`__cxa_finalize_ranges + 316 frame #14: 0x00007fff202e6010 libsystem_c.dylib`exit + 53 frame #15: 0x00007fff203d1f44 libdyld.dylib`start + 8 frame #16: 0x00007fff203d1f3d libdyld.dylib`start + 1 thread #5, queue = 'com.apple.root.user-interactive-qos', stop reason = signal SIGABRT frame #0: 0x00007fff203a356e libsystem_kernel.dylib`__abort_with_payload + 10 frame #1: 0x00007fff203a4fbd libsystem_kernel.dylib`abort_with_payload_wrapper_internal + 80 frame #2: 0x00007fff203a4f6d libsystem_kernel.dylib`abort_with_reason + 19 frame #3: 0x00007fff202749e3 libobjc.A.dylib`_objc_fatalv(unsigned long long, unsigned long long, char const*, __va_list_tag*) + 114 frame #4: 0x00007fff20274971 libobjc.A.dylib`_objc_fatal(char const*, ...) + 135 frame #5: 0x00007fff20255ccb libobjc.A.dylib`lookUpImpOrForward + 881 frame #6: 0x00007fff2025539b libobjc.A.dylib`_objc_msgSend_uncached + 75 frame #7: 0x00007fff22f368d6 AppKit`-[_NSWindowTransformAnimation setCurrentProgress:] + 42 frame #8: 0x00007fff22f37a8a AppKit`__55-[NSAnimation(NSInternal) _advanceTimeWithDisplayLink:]_block_invoke + 31 frame #9: 0x00007fff22d0774f AppKit`NSPerformVisuallyAtomicChange + 132 frame #10: 0x00007fff22f379dc AppKit`-[NSAnimation(NSInternal) _advanceTimeWithDisplayLink:] + 172 frame #11: 0x00007fff22e9a184 AppKit`-[NSScreenDisplayLink _fire] + 180 frame #12: 0x00007fff2362f0b4 AppKit`___NSRunLoopTimerCreateWithHandler_block_invoke + 34 frame #13: 0x00007fff204c6be9 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20 frame #14: 0x00007fff204c66dd CoreFoundation`__CFRunLoopDoTimer + 927 frame #15: 0x00007fff204c623a CoreFoundation`__CFRunLoopDoTimers + 307 frame #16: 0x00007fff204ace13 CoreFoundation`__CFRunLoopRun + 1988 frame #17: 0x00007fff204abf8c CoreFoundation`CFRunLoopRunSpecific + 563 frame #18: 0x00007fff2123d607 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 frame #19: 0x00007fff22f378f0 AppKit`-[NSAnimation(NSInternal) _runBlocking] + 453 frame #20: 0x00007fff22f376ae AppKit`__42-[NSAnimation(NSInternal) _runInNewThread]_block_invoke + 97 frame #21: 0x0000000104edb032 libdispatch.dylib`_dispatch_call_block_and_release + 12 frame #22: 0x0000000104edc264 libdispatch.dylib`_dispatch_client_callout + 8 frame #23: 0x0000000104ef04ac libdispatch.dylib`_dispatch_root_queue_drain + 828 frame #24: 0x0000000104ef0d3f libdispatch.dylib`_dispatch_worker_thread2 + 127 frame #25: 0x0000000104f7eac7 libsystem_pthread.dylib`_pthread_wqthread + 244 frame #26: 0x0000000104f7dae3 libsystem_pthread.dylib`start_wqthread + 15 This has been e.g. observed when a QNSWindow isn't closed and released at application quit as expected. Although that is a corner case that shouldn't happen, the general case is still valid. Fixes: QTBUG-96208 Pick-to: 6.2 5.15 Change-Id: I6c9d220e6f5389707baf7ae983f3156e8e51c316 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Doc: Centralize RFC documentation-links in rfc.qdocLuca Di Sera2021-09-161-1/+1
| | | | | | | | | | | | | | | | | | | | In the effort of repairing broken links as per QTBUG-96127, a series of RFC links referring to `tools.ietf.org/html/*` were modified to point to the new address that the site redirected to. To simplify executing a similar task and to diminish the duplication of manually inserted urls, the already existing `rfc.qdoc` file, containing `\externalpage` commands directing to RFC locations, was enhanced with links to all RFCs that were mentioned in the current documentation, so as to aggregate this common category of links. All links pointing to a `ietf` domain inside QDoc documentation blocks were then changed to use the newly provided external-references. Task-number: QTBUG-96127 Pick-to: 6.2 Change-Id: I2a52eb6aa8c9e346f64ef1a627b039220d9f6c2a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QElfParser: stop trying to look into the .rodata sectionThiago Macieira2021-09-141-3/+2
| | | | | | | | | | The return code NoQtSection was not being handled at all, so hasMetaData remained equal to false. This was probably not intended, but has been like that since Qt 5.0. See previous commit for details. Change-Id: I42eb903a916645db9900fffd16a4445eff9a082c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QPlugin: make the macros match the scanning code for ELF systemsThiago Macieira2021-09-142-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | For ELF platforms with a GCC-compatible compiler, the QElfParser has been ignoring the .rodata section ever since Qt 5.0 commit 7443895857fdaee132c8efc643e471f02b3d0fa4 ("Remove support for Qt 4 style plugins"). That change removed handling of return value QElfParser::NoQtSection from the ELF parser, which meant that the plugins without a .qtmetadata section were never considered plugins. In other words, for those systems, the __attribute__ macro is mandatory. For systems with a GCC-incompatible compiler, there were only two in Qt 5.x's lifetime: Oracle/Sun Solaris with SunCC and IBM AIX with IBM xlC compiler. Neither compiler supports C++17 according to [1], so they can't be in use in Qt 6. IBM xlC now comes with a Clang-based front-end for users who need Qt 6 and the OpenIndiana distribution of Open Source Solaris has been using GCC since 2012. So make the macros mandatory from now on. [1] https://en.cppreference.com/w/cpp/compiler_support#C.2B.2B17_features Change-Id: I42eb903a916645db9900fffd16a443745446cc64 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QElfParser: remove one more unnecesary variable from the ELF parserThiago Macieira2021-09-142-3/+2
| | | | | | | | There's no need to keep this variable in the class. Pick-to: 6.2 Change-Id: I2de1b4dfacd443148279fffd16a35775d56d3e45 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QElfParser: don't attempt to parse ELF files of the wrong endiannessThiago Macieira2021-09-142-21/+12
| | | | | | | | | | | | | | There's no sense in continuing to parse. We'll never be able to load such a plugin anyway. This simplifies the code generation a lot because now all the read<T> calls become unconditional qFromUnaligned<T>, which is just a memcpy(), which for primitive types the compiler will simply emit a memory load into a register. Task-number: QTBUG-96327 Pick-to: 6.2 Change-Id: I2de1b4dfacd443148279fffd16a3574daf010635 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin/QFactoryLoader: remove Qt 5 plugin remnantsThiago Macieira2021-09-141-3/+0
| | | | | | | | | | | Qt 6.x does not need to be able to read the old Qt 5-based binary JSON metadata. The QT_WARNING_DISABLE_DEPRECATED was needed in 5.15 while we used the then-deprecated functions to decode. Pick-to: 6.2 Change-Id: I2de1b4dfacd443148279fffd16a39ee074da3ef4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QPlugin: remove Q_EXTERN_C macroThiago Macieira2021-09-141-13/+4
| | | | | | | | | Our plugins are code generated by moc, so always C++. I don't know when the last time it was that you could declare plugins from C. Pick-to: 6.2 Change-Id: I2de1b4dfacd443148279fffd16a35e466f8a4c20 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QElfParser: don't use int for the enumThiago Macieira2021-09-133-4/+5
| | | | | | | | An enum shows the proper values in the debugger... Pick-to: 6.2 Change-Id: I2de1b4dfacd443148279fffd16a3a5848196983c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Doc: fix a bunch of qdoc warnings from wrong prototypesVolker Hilsheimer2021-09-031-2/+2
| | | | | | | | | * name method parameters consistently with their declaration * don't document parameters that are not there Pick-to: 6.2 Change-Id: I06ae9fdca357ed29eb7a72802f149eb4914181f4 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QLibrary: use QStringTokenizer in isLibrary()Marc Mutz2021-08-211-15/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rewrite the whole function for readability _and_ performance: - Extract Method isValidSuffix() as a lambda - Extract Method isNumeric() as a lambda - Use a C array of QLatin1String instead of a QStringList to hold the statically-sized list of candidate suffixes. This has the nice side-effect that the compiler will now throw an error in case the #ifdef'ery yields zero candidates (C arrays cannot have no elements), e.g. when porting to a new platform. - Last, not least, replace the parsing with a loop that makes clear what's going on and which is forward-iteration-only-compatible, so we can use QStringTokenizer directly, without toContainer() to get a random-access sequence. Need to use the C++20 version of all_of(), since QStringTokenizer uses sentinels instead of end-iterators. Even though we use higher-level constructs now, the code is still more efficient than the index-twisting we had before. Change-Id: I9f3faf3e30f58c9eb8a1487a7ca190681e87767b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QLibrary: remove dead checkMarc Mutz2021-08-181-2/+1
| | | | | | | | | | The variable `i` is initially `suffixPos + 1` and is then incremented further. It therefore can never be equal to `suffixPos` (ints don't overflow, that would be UB, and suffixPos doesn't change its value), so don't check for that. Change-Id: I3870ddf6ee550cad6c24fececf2a0b662a33d750 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLibrary: succeed early for .dylib on DarwinMarc Mutz2021-08-161-4/+5
| | | | | | | | | | Drag the cheap check for 'fileName.endsWith(".dylib")' to before the expensive operations (QFileInfo creation, extraction and splitting of completeSuffix(), building of suffix candidate list, ...), at the cost of a duplicated Q_OS_DARWIN check. Change-Id: I8ed764f18f0beb8ad24c30ab806ecc5452159601 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUuid: port to QAnyStringViewMarc Mutz2021-07-302-42/+26
| | | | | | | | | | | | | | | | | Remove the QString/QStringView/QLatin1String/const char* overloads from the API, but not the ABI. As a drive-by, replace a use of QStringView::left() by truncate(), as suggested by a comment. [ChangeLog][QtCore][QUuid] The from-string constructor and the fromString() function now take QAnyStringView (was: overload set with a subset of QString, QByteArray, const char*, QLatin1String, QStringView each). Change-Id: If7fa26cfbef9280480c78b669d9f5f14118995ed Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUuid: port fromRfc4122() to QByteArrayViewMarc Mutz2021-07-282-15/+17
| | | | | | | | | Remove the QByteArray overload from the API, but not the ABI. Adapt callers. Change-Id: I88aa09cbca3b89d0b249ce336ebe49c4b352c9e1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QUuid: remove Windows-only pre-C++11 constructor implementationMarc Mutz2021-07-091-11/+0
| | | | | | | Amends bd62dc13919556c6dc564df25cbf0ddf456c05e7. Change-Id: Iba10e7d70e7bd9d7c6068632dd2f429a52945463 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUuid: clean up pre C++11 constructorsMarc Mutz2021-07-081-26/+0
| | | | | | | | | All compilers Qt 6 supports support C++11 Uniform Initialization now. Change-Id: I1ddcc506347db1770c535047ebe2547ff33d843e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QLibrary: fix some implicit QFlags->int conversionsGiuseppe D'Angelo2021-05-122-3/+3
| | | | | | | Either be explicit, or just use QFlags directly. Change-Id: I18cbea4eaa1a0a4bce7665b735e7d785f7a196b2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Android: take JavaVM() from QJniEnvironment and not QtAndroidPrivateAssam Boudjelthia2021-02-111-2/+3
| | | | | | | Task-number: QTBUG-89482 Pick-to: 6.1 Change-Id: Idfd442afc90c00e672b28b43c78c789813f46c7d Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-071-38/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Adjust code format, add space after 'if'Zhang Sheng2020-11-161-1/+1
| | | | | | Change-Id: Ice081c891ff7f4b766f49dd4bd5cf18c30237acf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Android: fix crash by passing the right Handle to dlsym()Assam Boudjelthia2020-11-031-2/+2
| | | | | | | | | | | | dlsym() should be taking a Handle that is created by dlopen() instead of pHnd. * https://linux.die.net/man/3/dlsym Fixes: QTBUG-84849 Pick-to: 5.15 Change-Id: Ic192736268ef9cbfdb86cf66d20082b14070ba00 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Doc: Fix various documentation issues for Qt CoreTopi Reinio2020-10-311-2/+2
| | | | | | | Task-number: QTBUG-86295 Change-Id: I3bf7d4b1533d4fc81114d353b19beaf4ea9b93b2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Whitespace cleanup in corelib/ mimetypes, plugin and threadAllan Sandfeld Jensen2020-10-2114-38/+33
| | | | | | | Done with selective application of clang-format Change-Id: Iee6bf2426de81356b6d480629ba972f980b6d93d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-071-1/+1
| | | | | | | | | This time based on grepping to also include documentation, tests and examples previously missed by the automatic tool. Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix some qdoc warnings from QStaticPluginVolker Hilsheimer2020-09-281-28/+25
| | | | | | | | | | | | | | Move all the documentation for that class into one place, and remove rawMetaData documentation and references; it is a private variable, and shouldn't be documented. The instance member is a function pointer type variable, but should be treated as a member function. Even with a Q_QDOC ifdef'ery we can't fix that warning (we would get a lot of new warnings instead), so leave that as is for now. Change-Id: I951aaafad8dca5ed2533ace69931f002eb97996a Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QStaticPlugin: Reorder class membersVolker Hilsheimer2020-09-251-5/+4
| | | | | | | | Address ### Qt6 comment. Task-number: QTBUG-85700 Change-Id: I31b65a76662b3dcdfa1400a3747c2e3c730b5ee3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLibrary: Use QTaggedPointer for the did_load flagUlf Hermann2020-09-222-19/+19
| | | | | | | | This makes the size nicely aligned and conveniently intializes everything to the right values. Change-Id: Ibad2defbbd323fd5cdd4bed8374f40558d80acc0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>