Bug 443559 - Crash with a 'repaired' corrupted .kra file
Summary: Crash with a 'repaired' corrupted .kra file
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: * Unknown (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Debian stable Linux
: NOR crash
Target Milestone: ---
Assignee: Halla Rempt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-10 17:01 UTC by Ahab Greybeard
Modified: 2021-10-11 10:15 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Original .kra~ backup file (2.90 MB, application/x-krita)
2021-10-10 17:02 UTC, Ahab Greybeard
Details
'recovered' .kra backup file (2.90 MB, application/x-krita)
2021-10-10 17:02 UTC, Ahab Greybeard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ahab Greybeard 2021-10-10 17:01:09 UTC
SUMMARY
A user had a corrupted .kra file after Command+S saving, then there was a crash.
The .kra file and its backup file could not be opened with the error message:
"The file does not exist..... Could not find root"

More details here:
https://krita-artists.org/t/help-krita-could-not-open-file-reason-the-file-doesnt-exist-could-not-find-root/30120/

A repair attempt, using ZipRepair gives a 'recovered' file that will crash the 4.4.8, 5.0.0-beta2 and the Oct 09 5.1.0-prealpha (git 45ea106) appimages on Debian 10 MATE.

The backup .kra file (renamed from Altha.kra~) and its 'recovered' form are attached.

When opened with the Oct 10 5.1.0-prealpha (git 45ea10672d) portable .zip running on Windows 10, there is no crash but it can't be opened with the error message:
"The file format cannot be parsed
Parsing error in root at line 31, column 28
Error message: unexpected character"

STEPS TO REPRODUCE
1. Open Altha-backup.kra
2. Use ZipRepair in an attempt to repair/recover it.
3. Open recovered-Altha-backup.kra

OBSERVED RESULT
1. It can't be opened. "The file does not exist..... Could not find root"
2. ZipRepair reports much repairing.
3. Instant crash.
There was no relevant log entry apart from 
"KRITA DID NOT CLOSE CORRECTLY"
The Terminal said "Segmentation fault".

EXPECTED RESULT
3. Error message - No Crash

SOFTWARE/OS VERSIONS
Krita

 Version: 5.1.0-prealpha (git 45ea106)
 Languages: en_GB, en, en, en_GB, en
 Hidpi: false

Qt

  Version (compiled): 5.12.11
  Version (loaded): 5.12.11

OS Information

  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 4.19.0-17-amd64
  Pretty Productname: Debian GNU/Linux 10 (buster)
  Product Type: debian
  Product Version: 10
  Desktop: MATE

OpenGL Info
 
  Vendor:  "NVIDIA Corporation" 
  Renderer:  "GeForce GTX 750 Ti/PCIe/SSE2" 
  Version:  "4.6.0 NVIDIA 460.73.01" 
  Shading language:  "4.60 NVIDIA" 
  Requested format:  QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
  Current format:    QSurfaceFormat(version 4.6, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
     Version: 4.6
     Supports deprecated functions true 
     is OpenGL ES: false 
  supportsBufferMapping: true 
  supportsBufferInvalidation: true 

QPA OpenGL Detection Info 
  supportsDesktopGL: true 
  supportsOpenGLES: true 
  isQtPreferOpenGLES: false 

useBufferInvalidation (config option): false


Hardware Information

  GPU Acceleration: auto
  Memory: 16039 Mb
  Number of Cores: 8
  Swap Location: /tmp

Current Settings

  Current Swap Location: /tmp
  Current Swap Location writable: true
  Undo Enabled: true
  Undo Stack Limit: 30
  Use OpenGL: true
  Use OpenGL Texture Buffer: true
  Disable Vector Optimizations: false
  Disable AVX Optimizations: false
  Canvas State: OPENGL_SUCCESS
  Autosave Interval: 900
  Use Backup Files: true
  Number of Backups Kept: 1
  Backup File Suffix: ~
  Backup Location: Same Folder as the File
  Backup Location writable: false
  Use Win8 Pointer Input: false
  Use RightMiddleTabletButton Workaround: false
  Levels of Detail Enabled: false
  Use Zip64: false


Display Information
Number of screens: 2
	Screen: 0
		Name: DVI-D-1
		Depth: 24
		Scale: 1
		Resolution in pixels: 1280x1024
		Manufacturer: Dell Inc.
		Model: DELL 1704FPV-
		Refresh Rate: 60
	Screen: 1
		Name: DVI-D-0
		Depth: 24
		Scale: 1
		Resolution in pixels: 1280x1024
		Manufacturer: Dell Inc.
		Model: DELL 1704FPV-
		Refresh Rate: 60



ADDITIONAL INFORMATION
Comment 1 Ahab Greybeard 2021-10-10 17:02:07 UTC
Created attachment 142305 [details]
Original .kra~ backup file
Comment 2 Ahab Greybeard 2021-10-10 17:02:51 UTC
Created attachment 142306 [details]
'recovered' .kra backup file
Comment 3 Halla Rempt 2021-10-11 10:09:50 UTC
Backtrace: 

Thread 1 "krita" received signal SIGSEGV, Segmentation fault.
0x00007ffff391f0c1 in unzCloseCurrentFile (file=0xff6464640000000e)
    at /home/halla/dev/b/ext_quazip/ext_quazip-prefix/src/ext_quazip/quazip/unzip.c:2026
2026        if (file==NULL)
(gdb) bt
#0  0x00007ffff391f0c1 in unzCloseCurrentFile (file=0xff6464640000000e)
    at /home/halla/dev/b/ext_quazip/ext_quazip-prefix/src/ext_quazip/quazip/unzip.c:2026
#1  0x00007ffff391a53e in QuaZipFile::close (this=0x555558f9dcb0)
    at /home/halla/dev/b/ext_quazip/ext_quazip-prefix/src/ext_quazip/quazip/quazipfile.cpp:482
#2  QuaZipFile::close (this=0x555558f9dcb0)
    at /home/halla/dev/b/ext_quazip/ext_quazip-prefix/src/ext_quazip/quazip/quazipfile.cpp:473
#3  0x00007ffff391a658 in QuaZipFile::~QuaZipFile (this=0x555558f9dcb0, __in_chrg=<optimized out>)
    at /home/halla/dev/b/ext_quazip/ext_quazip-prefix/src/ext_quazip/quazip/quazipfile.cpp:174
#4  0x00007ffff391a66d in QuaZipFile::~QuaZipFile (this=0x555558f9dcb0, __in_chrg=<optimized out>)
    at /home/halla/dev/b/ext_quazip/ext_quazip-prefix/src/ext_quazip/quazip/quazipfile.cpp:171
#5  0x00007ffff44fef46 in KoQuaZipStore::~KoQuaZipStore (this=0x55555910c570, __in_chrg=<optimized out>)
    at /home/halla/dev/deps/include/QtCore/qscopedpointer.h:116
#6  0x00007ffff44fefed in KoQuaZipStore::~KoQuaZipStore (this=0x55555910c570, __in_chrg=<optimized out>)
    at /home/halla/dev/krita/libs/store/KoQuaZipStore.cpp:60
#7  0x00007fffbc4de980 in KraConverter::~KraConverter (this=0x7fffffffbdc0, __in_chrg=<optimized out>)
    at /home/halla/dev/krita/plugins/impex/libkra/kra_converter.cpp:47
#8  0x00007fffbc500588 in KraImport::convert (this=<optimized out>, document=0x55555bc81a70, io=<optimized out>)
    at /home/halla/dev/krita/plugins/impex/kra/kra_import.cpp:46
#9  0x00007ffff7c7d79c in KisImportExportManager::doImport (this=0x5555565d2030, location=..., filter=...)
    at /home/halla/dev/krita/libs/global/kis_shared_ptr.h:63
#10 0x00007ffff7c7f02c in KisImportExportManager::convert (this=0x5555565d2030, direction=<optimized out>, 
    location=..., realLocation=..., mimeType=..., showWarnings=<optimized out>, exportConfiguration=..., 
    isAsync=<optimized out>, isAdvancedExporting=<optimized out>)
    at /home/halla/dev/deps/include/QtCore/qsharedpointer_impl.h:330
#11 0x00007ffff7c7fddb in KisImportExportManager::importDocument (this=this@entry=0x5555565d2030, location=..., 
    mimeType=...) at /home/halla/dev/krita/libs/global/kis_shared_ptr.h:206
#12 0x00007ffff7c6a9fa in KisDocument::openFile (this=0x55555bc81a70)
    at /home/halla/dev/krita/libs/ui/KisDocument.cpp:1735
#13 0x00007ffff7c6b2a9 in KisDocument::openPathInternal (this=0x55555bc81a70, path=...)
    at /home/halla/dev/krita/libs/ui/KisDocument.cpp:2264
#14 0x00007ffff7c6b9f1 in KisDocument::openPath (this=0x55555bc81a70, _path=..., flags=...)
    at /home/halla/dev/krita/libs/ui/KisDocument.cpp:1640
#15 0x00007ffff7c90105 in KisMainWindow::openDocumentInternal (this=<optimized out>, path=..., flags=...)
    at /home/halla/dev/krita/libs/ui/KisMainWindow.cpp:1114
#16 0x00007ffff7c9070d in KisMainWindow::openDocument (this=0x55555704dc90, path=..., flags=...)
    at /home/halla/dev/krita/libs/ui/KisMainWindow.cpp:1085
#17 0x00007ffff7c90bc5 in KisMainWindow::slotFileOpen (this=0x55555704dc90, isImporting=false)
    at /home/halla/dev/krita/libs/ui/KisMainWindow.cpp:1728
#18 0x00007ffff7c9f31b in KisMainWindow::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, 
    _id=<optimized out>, _a=<optimized out>)
    at /home/halla/dev/b-krita/libs/ui/kritaui_autogen/include/moc_KisMainWindow.cpp:373
#19 0x00007ffff5b040d0 in QMetaObject::activate(QObject*, int, int, void**) ()
   from /home/halla/dev/deps/lib/libQt5Core.so.5
#20 0x00007ffff6501a36 in QAction::triggered(bool) () from /home/halla/dev/deps/lib/libQt5Widgets.so.5
#21 0x00007ffff65040f2 in QAction::activate(QAction::ActionEvent) ()
   from /home/halla/dev/deps/lib/libQt5Widgets.so.5
#22 0x00007ffff65049bf in QAction::event(QEvent*) () from /home/halla/dev/deps/lib/libQt5Widgets.so.5
#23 0x00007ffff65080d6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /home/halla/dev/deps/lib/libQt5Widgets.so.5
#24 0x00007ffff65115d0 in QApplication::notify(QObject*, QEvent*) ()
   from /home/halla/dev/deps/lib/libQt5Widgets.so.5
#25 0x00007ffff7c4e57d in KisApplication::notify (this=<optimized out>, receiver=0x55555be782c0, 
    event=0x7fffffffcbd0) at /home/halla/dev/krita/libs/ui/KisApplication.cpp:687
#26 0x00007ffff5ad86ba in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
   from /home/halla/dev/deps/lib/libQt5Core.so.5
Comment 4 Halla Rempt 2021-10-11 10:11:51 UTC
Note: the recovered file is well and truly broken. Unzip says:

halla@thinkstation:~/bla$ unzip ../recovered_Altha-backup.kra 
Archive:  ../recovered_Altha-backup.kra
This Zip file has been recovered!
  inflating: mimetype                 bad CRC a703f0a1  (should be 51f8754d)
  inflating: maindoc.xml             
  error:  invalid compressed data to inflate
  inflating: documentinfo.xml        
error: invalid zip file with overlapped components (possible zip bomb)
halla@thinkstation:~/bla$
Comment 5 Halla Rempt 2021-10-11 10:12:09 UTC
Git commit 9a75453498f8b3e4d885685493e811ab81d5a096 by Halla Rempt.
Committed on 11/10/2021 at 10:09.
Pushed by rempt into branch 'krita/5.0'.

Check whether there is a quazip file before deleting it

(Note the file is still broken, but now Krita says what's wrong
with it.)

M  +4    -1    libs/store/KoQuaZipStore.cpp

https://invent.kde.org/graphics/krita/commit/9a75453498f8b3e4d885685493e811ab81d5a096
Comment 6 Halla Rempt 2021-10-11 10:13:22 UTC
Git commit 53163451b47aa47854c70a8b64f9d0bbf71838d9 by Halla Rempt.
Committed on 11/10/2021 at 10:13.
Pushed by rempt into branch 'master'.

Check whether there is a quazip file before deleting it

(Note the file is still broken, but now Krita says what's wrong
with it.)

(cherry picked from commit 9a75453498f8b3e4d885685493e811ab81d5a096)

M  +4    -1    libs/store/KoQuaZipStore.cpp

https://invent.kde.org/graphics/krita/commit/53163451b47aa47854c70a8b64f9d0bbf71838d9
Comment 7 Halla Rempt 2021-10-11 10:15:10 UTC
The backup file is also broken: 

file #1:  bad zipfile offset (local header sig):  0
maindoc.xml:  mismatching "local" filename (mimetype),
         continuing with "central" filename version
  inflating: maindoc.xml              bad CRC a703f0a1  (should be 51f8754d)


For whatever incredibly weird reason, the maindoc.xml file contains the mimetype...