Bug 483626 - Creating a KIconLoader instance causes application to wait at application exit
Summary: Creating a KIconLoader instance causes application to wait at application exit
Status: REPORTED
Alias: None
Product: frameworks-kiconthemes
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 6.0.0
Platform: Microsoft Windows Microsoft Windows
: NOR major
Target Milestone: ---
Assignee: Christoph Feck
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-15 06:46 UTC by Hernan Martinez
Modified: 2024-03-16 08:41 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Minimum code to repro (777 bytes, application/x-zip-compressed)
2024-03-15 06:46 UTC, Hernan Martinez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hernan Martinez 2024-03-15 06:46:39 UTC
Created attachment 167231 [details]
Minimum code to repro

SUMMARY

I found this with Kdenlive when compiling it in MSYS2's UCRT64 in Windows. But attached there's minimum reproducible code.

The application at exit displays the following message on the console before waiting indefinitely:
`QEventDispatcherWin32::wakeUp: Failed to post a message (Invalid window handle.)`

I don't know if that message is related to the issue.


The main thread stack when the application waits indefinitely:
```
ntdll.dll!ntdll!ZwWaitForAlertByThreadId (Unknown Source:0)
ntdll.dll!ntdll!TpWorkOnBehalfClearTicket (Unknown Source:0)
ntdll.dll!ntdll!RtlDllShutdownInProgress (Unknown Source:0)
ntdll.dll!ntdll!RtlWaitOnAddress (Unknown Source:0)
KernelBase.dll!WaitOnAddress (Unknown Source:0)
Qt6Core.dll![Unknown/Just-In-Time compiled code] (Unknown Source:0)
libKF6IconThemes.dll!KIconLoaderGlobalData::~KIconLoaderGlobalData(KIconLoaderGlobalData * const this) (x:\Github\MINGW-packages\mingw-w64-kiconthemes\src\kiconthemes-6.0.0\src\kiconloader.cpp:146)
libKF6IconThemes.dll!QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_s_globalData>::~Holder(QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_s_globalData> * const this) (c:\msys64\ucrt64\include\qt6\QtCore\qglobalstatic.h:48)
libKF6IconThemes.dll!__tcf_2() (c:\msys64\ucrt64\include\qt6\QtCore\qglobalstatic.h:91)
ucrtbase.dll!ucrtbase!.sys_nerr (Unknown Source:0)
ucrtbase.dll!ucrtbase!_o_free (Unknown Source:0)
ucrtbase.dll!ucrtbase!_execute_onexit_table (Unknown Source:0)
libKF6IconThemes.dll!_CRT_INIT(HANDLE hDllHandle, HANDLE hDllHandle@entry, DWORD dwReason, DWORD dwReason@entry, LPVOID lpreserved, LPVOID lpreserved@entry) (c:\M\B\src\mingw-w64\mingw-w64-crt\crt\crtdll.c:130)
libKF6IconThemes.dll!__DllMainCRTStartup(HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) (c:\M\B\src\mingw-w64\mingw-w64-crt\crt\crtdll.c:196)
ntdll.dll!ntdll!RtlActivateActivationContextUnsafeFast (Unknown Source:0)
ntdll.dll!ntdll!LdrShutdownProcess (Unknown Source:0)
ntdll.dll!ntdll!RtlExitUserProcess (Unknown Source:0)
kernel32.dll!KERNEL32!ExitProcess (Unknown Source:0)
ucrtbase.dll!ucrtbase!exit (Unknown Source:0)
ucrtbase.dll!ucrtbase!exit (Unknown Source:0)
__tmainCRTStartup() (c:\M\B\src\mingw-w64\mingw-w64-crt\crt\crtexe.c:269)
mainCRTStartup() (c:\M\B\src\mingw-w64\mingw-w64-crt\crt\crtexe.c:188)
```

STEPS TO REPRODUCE
1. Build the attached source code
2. Run application and close the main window

OBSERVED RESULT
Application does not exit.

EXPECTED RESULT
Application exits.

Package Type: Unknown/Default
Qt: 6.6.2 (built against 6.6.2 x86_64-little_endian-llp64)
Frameworks: 6.0.0
System: Windows 11 Version 23H2
Kernel: winnt 10.0.22631
CPU: x86_64
Windowing System: windows
Comment 1 Hernan Martinez 2024-03-15 17:16:57 UTC
Code to reproduce:
```
#include <QApplication>
#include <QWidget>
#include <KIconTheme>

int main(int arc, char *argv[])
{
    QApplication app(arc, argv);

    KIconLoader loader;

    QWidget window;
    window.resize(250, 150);
    window.setWindowTitle("Close this window");
    window.show();

    return app.exec();
}
```
Comment 2 Hernan Martinez 2024-03-15 23:16:05 UTC
I just build all deps and KIconThemes with MINGW64 instead of UCRT64, the issue with the same stack trace persists.
Comment 3 Biswapriyo Nath 2024-03-16 07:41:09 UTC
This may not be an issue in KDE. The issue was first reported here https://bugreports.qt.io/browse/QTBUG-84498

Then this patch fixed the issue https://invent.kde.org/packaging/craft-blueprints-kde/-/blob/06d9723560fbbf4b02a911206a1f4b077f82cd7f/libs/qt5/qtbase/qdbus-manager-quit-5.7.patch

Then msys2 imported that patch for qt5-base here https://github.com/msys2/MINGW-packages/commit/f6eacbcdd74cc836294e8e7337c5d3cf772a3117
Comment 4 Hernan Martinez 2024-03-16 08:41:19 UTC
Understood
At least now, with the repro code, one can reproduce the issue 100% of the time.