Bug 486697 - kioworker crashes in TrashImpl::readInfoFile() when opening Dolphin or moving items to Trash when any trashinfo files have relative paths
Summary: kioworker crashes in TrashImpl::readInfoFile() when opening Dolphin or movin...
Status: CONFIRMED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Trash (show other bugs)
Version: 6.1.0
Platform: Neon Linux
: NOR crash
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords: regression
: 488428 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-05-07 03:39 UTC by main.zone4654
Modified: 2024-11-23 16:21 UTC (History)
4 users (show)

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


Attachments
Screencast of steps to reproduce (1.24 MB, video/webm)
2024-05-07 03:39 UTC, main.zone4654
Details
Crash Handler Information (2.01 KB, text/plain)
2024-05-07 03:40 UTC, main.zone4654
Details
kio coredump (3.09 KB, text/plain)
2024-05-08 00:18 UTC, main.zone4654
Details

Note You need to log in before you can comment on or make changes to this bug.
Description main.zone4654 2024-05-07 03:39:30 UTC
Created attachment 169254 [details]
Screencast of steps to reproduce

SUMMARY
Upon opening Dolphin, a notification pops up and says "kioworker closed unexpectly".
I feel this is associated with the Trash folder.

STEPS TO REPRODUCE
Click on the Dolphin launcher

OBSERVED RESULT
Notification shows "kioworker has crashed". Dolphin continues to work.
The notification will show again if I navigate to the trash can.
The trash folder shows "Loading cancelled".

EXPECTED RESULT
Dolphin opens.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE Neon
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0

ADDITIONAL INFORMATION
```
~ ❯❯❯ dolphin
ASSERT: "info.origPath[0] == QLatin1Char('/')" in file ./src/kioworkers/trash/trashimpl.cpp, line 782
KCrash: Application 'kioworker' crashing... crashRecursionCounter = 2
KCrash: Application Name = kioworker path = /usr/lib/x86_64-linux-gnu/libexec/kf6 pid = 929489
KCrash: Arguments: /usr/lib/x86_64-linux-gnu/libexec/kf6/kioworker trash  local:/run/user/1000/dolphinBwLHne.2.kioworker.socket 
KCrash: Attempting to start /usr/lib/x86_64-linux-gnu/libexec/drkonqi
kf5idletime_wayland: This plugin does not support polling idle time
org.kde.drkonqi.bugzilla: RuntimeException: "Failed to resolve bugzilla product"
org.kde.drkonqi: "Failed to resolve bugzilla product"
kf.kio.core: An error occurred during write. The worker terminates now.
kf.kio.core: An error occurred during write. The worker terminates now.
ASSERT: "info.origPath[0] == QLatin1Char('/')" in file ./src/kioworkers/trash/trashimpl.cpp, line 782
KCrash: Application 'kioworker' crashing... crashRecursionCounter = 2
KCrash: Application Name = kioworker path = /usr/lib/x86_64-linux-gnu/libexec/kf6 pid = 929772
KCrash: Arguments: /usr/lib/x86_64-linux-gnu/libexec/kf6/kioworker trash  local:/run/user/1000/dolphinFdhGMP.13.kioworker.socket 
KCrash: Attempting to start /usr/lib/x86_64-linux-gnu/libexec/drkonqi
kf5idletime_wayland: This plugin does not support polling idle time
org.kde.drkonqi.bugzilla: RuntimeException: "Failed to resolve bugzilla product"
org.kde.drkonqi: "Failed to resolve bugzilla product"
kf.kio.core: An error occurred during write. The worker terminates now.
QSocketNotifier: Invalid socket 10 and type 'Read', disabling...
QSocketNotifier: Invalid socket 10 and type 'Read', disabling...
QSocketNotifier: Invalid socket 11 and type 'Read', disabling...
```
Comment 1 main.zone4654 2024-05-07 03:40:06 UTC
Created attachment 169255 [details]
Crash Handler Information
Comment 2 main.zone4654 2024-05-07 03:56:49 UTC
Also, clicking "Move to trash" on desktop items fails and also crashes kioworker.
Comment 3 Nate Graham 2024-05-07 20:12:51 UTC
You're right, it does look trash-related. Unfortunately I can't reproduce the crash myself on current git master, and the backtrace is incomplete and missing debug symbols for the following lines that we need to figure out exactly what's going wrong:

#13 0x0000772d9d0f9b13 in ?? () from /usr/lib/x86_64-linux-gnu/qt6/plugins/kf6/kio/kio_trash.so
#14 0x0000772d9d0fe2f8 in ?? () from /usr/lib/x86_64-linux-gnu/qt6/plugins/kf6/kio/kio_trash.so
#15 0x0000772d9d0ffee6 in ?? () from /usr/lib/x86_64-linux-gnu/qt6/plugins/kf6/kio/kio_trash.so
#16 0x0000772da1b02748 in ?? () from /lib/x86_64-linux-gnu/libKF6KIOCore.so.6
#17 0x0000772da1aff616 in ?? () from /lib/x86_64-linux-gnu/libKF6KIOCore.so.6
#18 0x0000772da1bb266a in ?? () from /lib/x86_64-linux-gnu/libKF6KIOCore.so.6
#19 0x0000772d9d0fdae9 in kdemain () from /usr/lib/x86_64-linux-gnu/qt6/plugins/kf6/kio/kio_trash.so
#20 0x00005d048b9b15a0 in ?? ()

Could you please install debug symbols for KIO and attach a new symbolicated backtrace generated by using `coredumpctl gdb` in a terminal window? See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports#Retrieving_a_backtrace_using_coredumpctl for details about how to do this.

Thanks again!
Comment 4 main.zone4654 2024-05-08 00:18:28 UTC
Created attachment 169288 [details]
kio coredump
Comment 5 Nate Graham 2024-05-09 19:33:50 UTC
Thanks, that's helpful.

#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=130728306881152) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=130728306881152) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=130728306881152, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x000076e592442476 in __GI_raise (sig=6) at ../sysdeps/posix/raise.c:26
#4  0x000076e592deb48e in KCrash::defaultCrashHandler (sig=6) at ./src/kcrash.cpp:593
#5  <signal handler called>
#6  __pthread_kill_implementation (no_tid=0, signo=6, threadid=130728306881152) at ./nptl/pthread_kill.c:44
#7  __pthread_kill_internal (signo=6, threadid=130728306881152) at ./nptl/pthread_kill.c:78
#8  __GI___pthread_kill (threadid=130728306881152, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#9  0x000076e592442476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#10 0x000076e5924287f3 in __GI_abort () at ./stdlib/abort.c:79
#11 0x000076e592cfdb6e in qAbort () at ./src/corelib/global/qglobal.cpp:161
#12 0x000076e592cf820a in qt_message_fatal<QString&> (message=..., context=...) at ./src/corelib/global/qlogging.cpp:2025
#13 qt_message(QtMsgType, const QMessageLogContext &, const char *, typedef __va_list_tag __va_list_tag *) (msgType=msgType@entry=QtFatalMsg, context=..., msg=<optimized out>, ap=ap@entry=0x7fff8bcf3e40) at ./src/corelib/global/qlogging.cpp:374
#14 0x000076e592cfe511 in QMessageLogger::fatal (this=<optimized out>, msg=<optimized out>) at ./src/corelib/global/qlogging.cpp:889
#15 0x000076e592cc2ac2 in qt_assert (assertion=assertion@entry=0x76e58e4a64d0 "info.origPath[0] == QLatin1Char('/')", file=file@entry=0x76e58e4a6478 "./src/kioworkers/trash/trashimpl.cpp", line=line@entry=782) at ./src/corelib/global/qassert.cpp:68
#16 0x000076e58e48eb13 in TrashImpl::readInfoFile (trashId=0, info=..., infoPath=..., this=0x7fff8bcf47c0) at ./src/kioworkers/trash/trashimpl.cpp:782
#17 TrashImpl::infoForFile (this=0x7fff8bcf47c0, trashId=0, fileId=..., info=...) at ./src/kioworkers/trash/trashimpl.cpp:735
#18 0x000076e58e4932f8 in TrashImpl::list (this=0x7fff8bcf47c0) at ./src/kioworkers/trash/trashimpl.cpp:715
#19 0x000076e58e494ee6 in TrashProtocol::listRoot (this=0x7fff8bcf47a0) at ./src/kioworkers/trash/kio_trash.cpp:506
#20 TrashProtocol::listDir (this=0x7fff8bcf47a0, url=...) at ./src/kioworkers/trash/kio_trash.cpp:403
#21 0x000076e592e96748 in KIO::WorkerSlaveBaseBridge::listDir (this=0x620fcde81050, url=...) at ./src/core/workerbase_p.h:121
#22 0x000076e592e93616 in KIO::SlaveBase::dispatch (this=0x620fcde81050, command=71, data=...) at ./src/core/slavebase.cpp:1229
#23 0x000076e592f4666a in KIO::SlaveBase::dispatchLoop() [clone .constprop.0] (this=<optimized out>) at ./src/core/slavebase.cpp:350
#24 0x000076e592e90b3d in KIO::WorkerBase::dispatchLoop (this=this@entry=0x7fff8bcf47b0) at ./src/core/workerbase.cpp:27
#25 0x000076e58e492ae9 in kdemain (argc=<optimized out>, argc@entry=4, argv=<optimized out>) at ./src/kioworkers/trash/kio_trash.cpp:48
#26 0x0000620fcc5be5a0 in main (argc=5, argv=0x7fff8bcf4b38) at /usr/include/x86_64-linux-gnu/qt6/QtCore/qvarlengtharray.h:84
Comment 6 Nate Graham 2024-05-09 19:34:27 UTC
#15 0x000076e592cc2ac2 in qt_assert (assertion=assertion@entry=0x76e58e4a64d0 "info.origPath[0] == QLatin1Char('/')", file=file@entry=0x76e58e4a6478 "./src/kioworkers/trash/trashimpl.cpp", line=line@entry=782) at ./src/corelib/global/qassert.cpp:68

Perhaps "info.origPath" is empty, such that there is no character at index 0.
Comment 7 Nate Graham 2024-05-09 20:33:59 UTC
And it's an assert and you hit it because Neon builds with asserts on for user builds.
Comment 8 Nate Graham 2024-05-09 20:37:57 UTC
Can you please paste the output of running `cat ~/.config/*trashrc` in a terminal window?
Comment 9 main.zone4654 2024-05-09 21:04:12 UTC
       │ File: .config/ktrashrc
   1   │ [/home/xxx/.local/share/Trash]
   2   │ Days=7
   3   │ LimitReachedAction=0
   4   │ Percent=2
   5   │ UseSizeLimit=true
   6   │ UseTimeLimit=true

       │ File: .config/trashrc
   1   │ [NetworkShares]
   2   │ NextID=4
   3   │ smb://192.168.1.72/books:/home/xxx/books=1
   4   │ smb://192.168.1.72/downloads:/home/xxx/server_downloads=0
   5   │ smb://192.168.1.72/media:/home/xxx/media=3
   6   │ smb://192.168.1.72/media:/home/xxx/server=2
   7   │
   8   │ [Status]
   9   │ Empty=false
Comment 10 main.zone4654 2024-05-09 23:01:20 UTC
Hi Nate,

I’ve also checked the files in .local/share/Trash/info, here’s a few examples:

      │ File: Screenshot_20240418_233817.png.trashinfo
   1   │ [Trash Info]
   2   │ Path=/home/xxx/Downloads/Screenshot_20240418_233817.p
       │ ng
   3   │ DeletionDate=2024-05-06T17:29:56
───────┬───────────────────────────────────────────────────────
       │ File: Taylor.trashinfo
───────┼───────────────────────────────────────────────────────
   1   │ [Trash Info]
   2   │ Path=/home/xxx/Desktop/Taylor
   3   │ DeletionDate=2024-05-07T15:52:03

I don’t see any property called “origPath”.
Comment 11 main.zone4654 2024-05-10 04:31:24 UTC
Crash completely resolved after manually deleting everything in the .local/share/Trash folder.
Comment 12 main.zone4654 2024-05-11 10:47:30 UTC
I found the cause of the crash after bisecting the .local/share/Trash directory.

The root cause of the problem are the files in the ./Trash/info directory. There are many files like this:

```
[Trash Info]
Path=Anki2/addons21/291119185
DeletionDate=2024-04-26T00:50:13
```

The Path property is not an absolute path, hence "info.origPath[0] == QLatin1Char('/')" failed.
I'm pretty sure these files were deleted from within Anki (Flatpak). 

I wonder if Anki used the wrong API?
Comment 13 Nate Graham 2024-05-14 23:34:53 UTC
Hmm, you would think so, but after reading over the XDG trash spec again(https://specifications.freedesktop.org/trash-spec/trashspec-latest.html): I ran across the following:

> The key “Path” contains the original location of the file/directory, as either an absolute
> pathname (starting with the slash character “/”) or a relative pathname (starting with
> any other character). A relative pathname is to be from the directory in which the
> trash directory resides (for example, from $XDG_DATA_HOME for the “home trash” directory);
>  it MUST not include a “..” directory, and for files not “under” that directory, absolute
> pathnames must be used. The system SHOULD support absolute pathnames only in the “home
> trash” directory, not in the directories under $topdir. 

So relative pathnames are supported by the spec. Maybe the assert in our code is wrong, or maybe something changed in the universe surrounding it to make it start producing invalid results.
Comment 14 Nate Graham 2024-06-13 18:55:58 UTC
*** Bug 488428 has been marked as a duplicate of this bug. ***