| Summary: | KIO worker fails to create if the application name is longer than 66 characters | ||
|---|---|---|---|
| Product: | [Frameworks and Libraries] frameworks-kio | Reporter: | Frank Fischer <frank-fischer> |
| Component: | Open/save dialogs | Assignee: | KIO Bugs <kio-bugs-null> |
| Status: | CONFIRMED --- | ||
| Severity: | normal | CC: | kdelibs-bugs-null, nicolas.fella, sitter |
| Priority: | NOR | ||
| Version First Reported In: | 6.10.0 | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
We are probably hitting a socket name limit here. Out of curiosity, how did you find this? (In reply to Nicolas Fella from comment #1) > We are probably hitting a socket name limit here. > > Out of curiosity, how did you find this? The problem occurred in the Lazarus IDE for free pascal if using the Qt5 or Qt6 backends. Lazarus (whether this is a good idea is a different question) changes the application title depending on the current project's path, i.e. by default it includes the full project path in the application title. And this title can become quite long. Someone in their forum found out that setting the application title to something different (i.e. shorter, not including the project path) seems to solve the problem (the application title is a user setting in Lazarus). I hit the same problem and realized that it occurred only for some projects, but not for all, and from there, only for some application titles but not for all. The rest of the story was just playing around and trying to find a small example to demonstrate the issue. So currently, at least for Lazarus, this is a real problem not just an artificial one (luckily one with simple workaround for now). I see. That looks like an unintended misuse of the Qt API. QCoreApplication::applicationName() isn't supposed to be used for user-visible application titles. That's what QGuiApplication::applicationDisplayName() is for. Compare https://doc.qt.io/qt-6/qcoreapplication.html#applicationName-prop and https://doc.qt.io/qt-6/qguiapplication.html#applicationDisplayName-prop > QTemporaryFile socketfile(prefix + QLatin1Char('/') + appName + QStringLiteral("XXXXXX.%1.kioworker.socket").arg(s_socketCounter.fetchAndAddAcquire(1)));
Meanwhile Qt internally builds on sockaddr_un which has a 108 character limit. We could probably just chop off appNames that are too long though that breaks the uniqueness of the path.
Maybe the better option would be to sha1 the entire app name and the counter, then use the hash as file name. It'd be of predictable length.
(In reply to Nicolas Fella from comment #3) > I see. That looks like an unintended misuse of the Qt API. > QCoreApplication::applicationName() isn't supposed to be used for > user-visible application titles. That's what > QGuiApplication::applicationDisplayName() is for. > > Compare https://doc.qt.io/qt-6/qcoreapplication.html#applicationName-prop > and https://doc.qt.io/qt-6/qguiapplication.html#applicationDisplayName-prop Thanks a lot, in particular for pointing out the applicationTitle issue. It has been changed in Lazarus and works fine. So at least the bug on the Lazarus side has been closed thanks to your hint. |
SUMMARY If the kio file dialog is called via the xdg mechanism, e.g. by Qt's QFileDialog using native dialogs, and the application title is longer than 66 characters, the dialog fails with an error message. STEPS TO REPRODUCE Consider the following test program: ---- #include <QApplication> #include <QFileDialog> int main(int argc, char **argv) { QApplication app(argc, argv); // this works // app.setApplicationName(QString(66, 'x')); // this fails app.setApplicationName(QString(67, 'x')); QFileDialog::getOpenFileName(nullptr, "open file"); return app.exec(); } ---- OBSERVED RESULT The application shows error message: "Unable to create KIO worker. Can not create a socket for launching a KIO worker for protocol 'tags'." EXPECTED RESULT The file dialog works. SOFTWARE/OS VERSIONS Operating System: Void KDE Plasma Version: 6.2.5 KDE Frameworks Version: 6.10.0 Qt Version: 6.8.1 Kernel Version: 6.12.12_1 (64-bit) Graphics Platform: Wayland Processors: 12 × AMD Ryzen 5 PRO 7530U with Radeon Graphics Memory: 14.4 GiB of RAM Graphics Processor: AMD Radeon Graphics ADDITIONAL INFORMATION