https://bugs.kde.org/show_bug.cgi?id=524932

            Bug ID: 524932
           Summary: Kio-worker crashes when file exceeds the disk limit
    Classification: Frameworks and Libraries
           Product: frameworks-kio
      Version First 6.29.0
       Reported In:
          Platform: Arch Linux
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Trash
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

DESCRIPTION

When KDE trash is set to auto remove upon size limit, as in .config/ktrashrc:

cat ~/.config/ktrashrc
[/home/<username>/.local/share/Trash]
Days=7
LimitReachedAction=1
Percent=5
UseSizeLimit=true
UseTimeLimit=false

Deleting a file larger than current remain will crash.

STEPS TO REPRODUCE
1. Set the trashbin with upper limit 5.00% and remove oldest file when full
2. Fill the trashbin, in my case kioclient openProperties trash:/ reports
remaining space: total 23.2GiB, 52.2MiB remaining.
3. Trying to delete a file less than 52.2MiB, in my case:
> truncate -s 52M ./trash-file
> kioclient mv ./trash-file trash:/
> (command executed correctly)
4. remove the trash-file, perform a delete larger than 52.2MiB, in my case:
> trancate -s 53M ./trash-file
>  LANG=C.UTF-8 kioclient mv ./trash-file trash:/
> KCrash: Application 'kioworker' crashing... crashRecursionCounter = 2
> kioclient: The process for the trash protocol died unexpectedly.

OBSERVED RESULT

The client crashes with following traceback:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  __pthread_kill_implementation (threadid=<optimized out>,
signo=signo@entry=11, no_tid=no_tid@entry=0) at pthread_kill.c:44
44            return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO
(ret) : 0;
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>,
signo=signo@entry=11, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007f1b2829a243 in __pthread_kill_internal (threadid=<optimized out>,
signo=11) at pthread_kill.c:89
#2  0x00007f1b2823e5d0 in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26
#3  0x00007f1b28d69f29 in KCrash::defaultCrashHandler (sig=11) at
/usr/src/debug/kcrash/kcrash-6.29.0/src/kcrash.cpp:653
#4  <signal handler called>
#5  QHashPrivate::iterator<QHashPrivate::Node<QByteArray,
TrashSizeCache::SizeAndModTime> >::node (this=<optimized out>)
    at /usr/include/qt6/QtCore/qhash.h:805
#6  QHash<QByteArray,
TrashSizeCache::SizeAndModTime>::const_iterator::operator-> (this=<optimized
out>)
    at /usr/include/qt6/QtCore/qhash.h:1206
#7  TrashImpl::adaptTrashSize (this=0x7ffe7174bdd0, origPath=..., trashId=0)
    at /usr/src/debug/kio/kio-6.29.0/src/kioworkers/trash/trashimpl.cpp:1327
#8  0x00007f1b22fff922 in TrashImpl::moveToTrash
(this=this@entry=0x7ffe7174bdd0, origPath=..., trashId=trashId@entry=0,
fileId=...)
    at /usr/src/debug/kio/kio-6.29.0/src/kioworkers/trash/trashimpl.cpp:391
#9  0x00007f1b22ffff8f in TrashProtocol::copyOrMoveToTrash
(this=this@entry=0x7ffe7174bdb0, src=..., dest=..., 
    action=action@entry=TrashProtocol::Move) at
/usr/src/debug/kio/kio-6.29.0/src/kioworkers/trash/kio_trash.cpp:271
#10 0x00007f1b2300078b in TrashProtocol::rename (this=0x7ffe7174bdb0,
oldURL=..., newURL=..., flags=...)
    at /usr/src/debug/kio/kio-6.29.0/src/kioworkers/trash/kio_trash.cpp:187
#11 0x00007f1b28ef7043 in KIO::WorkerSlaveBaseBridge::rename
(this=0x55f4718b3dc0, src=..., dest=..., flags=...)
    at /usr/src/debug/kio/kio-6.29.0/src/core/workerbase_p.h:135
#12 0x00007f1b28ef093e in KIO::SlaveBase::dispatch (this=0x55f4718b3dc0,
command=73, data=...)
    at /usr/src/debug/kio/kio-6.29.0/src/core/slavebase.cpp:1185
#13 0x00007f1b28ef0ec6 in KIO::SlaveBase::dispatchLoop (this=0x55f4718b3dc0)
    at /usr/src/debug/kio/kio-6.29.0/src/core/slavebase.cpp:329
#14 0x00007f1b22ffd4e7 in kdemain (argc=<optimized out>, argv=<optimized out>)
    at /usr/src/debug/kio/kio-6.29.0/src/kioworkers/trash/kio_trash.cpp:52
#15 0x000055f440597240 in main (argc=<optimized out>, argv=0x7ffe7174c118) at
/usr/include/qt6/QtCore/qvarlengtharray.h:91


EXPECTED RESULT

The file should delete correctly, by popping out old files.

SOFTWARE/OS VERSIONS
Operating System (available in the Info Center app, or by running `kinfo` in a
terminal window): Arch Linux
KDE Plasma Version: 6.7.4
KDE Frameworks Version: 6.29.0
Qt Version: 6.11.2

ADDITIONAL INFORMATION

>From the bt I have identified the error point: 
https://invent.kde.org/frameworks/kio/-/blob/master/src/kioworkers/trash/trashimpl.cpp?ref_type=heads#L1327
fileSizeFreed = dirCache.constFind(info.path().toUtf8())->size;
and seems the node returns end() and causing a dereference error? 

There might be inconsistencies in trash info/directorysizes. Maybe we need some
utilities to reconstruct the trash database?

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to