Bug 408350

Summary: Dolphin crashes on copy overwrite skip all existing files
Product: [Frameworks and Libraries] frameworks-kio Reporter: weltqgel
Component: generalAssignee: David Faure <faure>
Status: RESOLVED FIXED    
Severity: crash CC: andreas, ascaris, chabot.daniel.01, danirtoma, elvis.angelaccio, kdelibs-bugs, nate
Priority: NOR    
Version: 5.58.0   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In: 5.62.0
Sentry Crash Report:
Attachments: Trace file marked as useful
New crash information added by DrKonqi
New crash information added by DrKonqi

Description weltqgel 2019-06-05 16:26:57 UTC
Created attachment 120603 [details]
Trace file marked as useful

SUMMARY
Dolphin crashes hard on copy transaction, when trying to copy a folder from an internal drive over to an external drive (NTSF), when the external drive has already a subset (an incomplete earlier copy) of that folder. Point may be that the folder has a significant number of files (about 30000)

STEPS TO REPRODUCE
1. Copy folder from /media/benjamineon/QDATA to /media/benjamineon/WD-3T when the latter has a partial copy of the folder already.
2. Being asked by Dolphin what to do
3. Select apply to all and "Skip" --> Boom

OBSERVED RESULT
Crash

EXPECTED RESULT
Copying over the missing files only, skipping the existing files

SOFTWARE/OS VERSIONS 
Linux/KDE Plasma: KDE Neon
KDE Plasma Version: 5.15.5
KDE Frameworks 5.58.0
Qt 5.12.0 (kompiliert gegen 5.12.0)

ADDITIONAL INFORMATION
benjamineon@benjamineon-cirrus7:~$ screenfetch
              `..---+/---..`                benjamineon@benjamineon-cirrus7
          `---.``   ``   `.---.`            OS: KDE neon 5.15
       .--.`        ``        `-:-.         Kernel: x86_64 Linux 4.15.0-50-generic
     `:/:     `.----//----.`     :/-        Uptime: 1h 51m
    .:.    `---`          `--.`    .:`      Packages: 2493
   .:`   `--`                .:-    `:.     Shell: bash 4.4.19
  `/    `:.      `.-::-.`      -:`   `/`    Resolution: 1920x1080
  /.    /.     `:++++++++:`     .:    .:    DE: KDE 5.58.0 / Plasma 5.15.5
 `/    .:     `+++++++++++/      /`   `+`   WM: KWin
 /+`   --     .++++++++++++`     :.   .+:   GTK Theme: Breeze [GTK2/3]
 `/    .:     `+++++++++++/      /`   `+`   Icon Theme: breeze
  /`    /.     `:++++++++:`     .:    .:    Font: Noto Sans Regular
  ./    `:.      `.:::-.`      -:`   `/`    CPU: Intel Core i5-6500TE @ 4x 3.3GHz [27.8°C]
   .:`   `--`                .:-    `:.     GPU: intel
    .:.    `---`          `--.`    .:`      RAM: 5014MiB / 15896MiB
     `:/:     `.----//----.`     :/-       
       .-:.`        ``        `-:-.        
          `---.``   ``   `.---.`           
              `..---+/---..`
Comment 1 David Faure 2019-09-06 14:07:36 UTC
Git commit 4306dce1e8d9ca61ef5b7246bd602e21a5e63621 by David Faure, on behalf of Ahmad Samir.
Committed on 06/09/2019 at 14:07.
Pushed by dfaure into branch 'master'.

[CopyJob] Fix crash when copying an already existing dir and pressing "Skip"

Summary:
In copyNextFile() if all files have been skipped QList::erase() will
return end() iterator, accessing the element it denotes will cause
a segmentation fault. Make sure the iterator is valid if it's changed
inside the while loop, if we're going to use it before control reaches
the loop condition.

Add a unit test.
FIXED-IN: 5.62.0

Test Plan:
kioclient5 copy SOME_DIR_WITH_FILES DEST
kioclient5 copy --interactive SOME_DIR_WITH_FILES DEST

- In the "folder already exists" dialog enable "Apply to all" then hit "Skip"
- Without the patch you'd get a segmentation fault, with the patch the copy
  should finish as expected

All unit tests passed (except kiocore-kacltest, but that's unrelated).

Reviewers: #frameworks, dfaure

Reviewed By: dfaure

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D23708

M  +31   -0    autotests/jobtest.cpp
M  +2    -0    autotests/jobtest.h
M  +1    -1    src/core/copyjob.cpp

https://commits.kde.org/kio/4306dce1e8d9ca61ef5b7246bd602e21a5e63621
Comment 2 Ahmad Samir 2019-09-14 19:05:29 UTC
*** Bug 405914 has been marked as a duplicate of this bug. ***
Comment 3 Ahmad Samir 2019-09-14 19:07:32 UTC
*** Bug 409857 has been marked as a duplicate of this bug. ***
Comment 4 Chabot Daniel 2019-11-29 20:48:01 UTC
Created attachment 124191 [details]
New crash information added by DrKonqi

dolphin (18.12.2) using Qt 5.11.3

- What I was doing when the application crashed:

I was copying a large amount of photos files on an external USB drive and select skip if the file exixt.

Dolphin, version 18.12.2, crash every time i try to do this.

-- Backtrace (Reduced):
#6  0x00007ff907c9c243 in KIO::CopyJobPrivate::copyNextFile() () from /lib64/libKF5KIOCore.so.5
#7  0x00007ff907c9cecf in KIO::CopyJobPrivate::createNextDir() () from /lib64/libKF5KIOCore.so.5
#8  0x00007ff907c9fc0e in KIO::CopyJobPrivate::slotResultConflictCreatingDirs(KJob*) () from /lib64/libKF5KIOCore.so.5
#9  0x00007ff907ca257b in KIO::CopyJob::slotResult(KJob*) () from /lib64/libKF5KIOCore.so.5
[...]
#11 0x00007ff9070e6cb0 in KJob::result(KJob*, KJob::QPrivateSignal) () from /lib64/libKF5CoreAddons.so.5
Comment 5 Danir Toma 2020-07-27 12:53:57 UTC
Created attachment 130435 [details]
New crash information added by DrKonqi

dolphin (18.12.3) using Qt 5.9.7

- What I was doing when the application crashed:

Trying to copy files from one fish:// external device to another fish:// external device and choosing to Skip all existing files.

-- Backtrace (Reduced):
#7  0x00007f39c164a55d in KIO::Slave::gotInput (this=0x561188d99680) at /usr/src/debug/kio-5.55.0-lp151.3.9.1.x86_64/src/core/slave.cpp:419
#8  0x00007f39bd06f4df in QtPrivate::QSlotObjectBase::call (a=0x7ffcd90f3610, r=0x561188d99680, this=0x561188c1b8e0) at ../../include/QtCore/../../src/corelib/kernel/qobject_impl.h:101
[...]
#11 0x00007f39c15ec699 in KIO::Connection::readyRead (this=<optimized out>) at /usr/src/debug/kio-5.55.0-lp151.3.9.1.x86_64/build/src/core/KF5KIOCore_autogen/include/moc_connection_p.cpp:143
#12 KIO::ConnectionPrivate::dequeue (this=0x561188c0dc00) at /usr/src/debug/kio-5.55.0-lp151.3.9.1.x86_64/src/core/connection.cpp:46
#13 0x00007f39bd06ff32 in QObject::event (this=0x561188c5b350, e=<optimized out>) at kernel/qobject.cpp:1247