https://bugs.kde.org/show_bug.cgi?id=526853
Bug ID: 526853
Summary: Folder size counting ("Show size of contents") changes
the process working directory from a worker thread
(fts_open without FTS_NOCHDIR)
Classification: Applications
Product: dolphin
Version First 26.08.1
Reported In:
Platform: Other
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: view-engine: general
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Target Milestone: ---
SUMMARY
KDirectoryContentsCounterWorker::walkDir()
(src/kitemviews/private/kdirectorycontentscounterworker.cpp:35) runs in a
worker thread and calls
fts_open(path, FTS_COMFOLLOW | FTS_PHYSICAL | FTS_XDEV, nullptr)
fts(3) on FTS_NOCHDIR: "As a performance optimization, the fts functions change
directories as they walk the file hierarchy. This has the side-effect that an
application cannot rely on being in any particular directory during the
traversal. This option turns off this optimization, and the fts functions will
not change the current directory."
In addition, fts_close() restores the directory that was current when
fts_open() was called, so it also overwrites a working directory that another
thread set in the meantime.
The working directory is shared by all threads of the process, so code running
inside Dolphin that uses relative paths breaks while the counter runs. Ark's
Compress actions run inside Dolphin and are affected (separate Ark report).
This code only runs with Folder size "Show size of contents"; the default "Show
number of items" uses KIO::listDir.
STEPS TO REPRODUCE
1. Configure Dolphin > View > Content Display > Folder size: "Show size of
contents".
2. In Details view, open a folder whose subfolders contain many files (here two
with about 45,000 and 50,000 entries) and that also contains a folder with
several GB of data.
3. Right-click the large folder > Compress > Compress to "<name>.zip".
OBSERVED RESULT
After a few seconds the notification reports the job as finished, but no
archive exists (5 of 5 attempts). An LD_PRELOAD shim around libzip showed that
Ark started with the working directory set to the parent folder and relative
paths, zip_close() failed with "Can't open file: No such file or directory",
and afterwards the process working directory was a subfolder of a sibling
folder that the size counter was walking.
EXPECTED RESULT
The size counter does not change the process working directory.
SUGGESTED FIX
Add FTS_NOCHDIR to the fts_open() flags. fts then uses full paths instead of
changing directories; the performance impact was not measured.
SOFTWARE/OS VERSIONS
Arch Linux, KDE Plasma 6.7.5, KDE Frameworks 6.30.0, Qt 6.11.2, Dolphin
26.08.1, Ark 26.08.1
ADDITIONAL INFORMATION
Drafted with an AI assistant (Claude) from source reading, logs and tests on
the reporter's system.
--
You are receiving this mail because:
You are watching all bug changes.