Bug 453421 - Okular corrupts file while saving the archive
Summary: Okular corrupts file while saving the archive
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 22.04.0
Platform: Flatpak Linux
: NOR major
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-05 13:44 UTC by nameless2800
Modified: 2022-07-05 19:20 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 22.04.3


Attachments
The error message that appears when it crashes or when you try to open the file again. (4.46 KB, image/png)
2022-05-05 13:44 UTC, nameless2800
Details
A printscreen for the exact moment the error occur (239.29 KB, image/png)
2022-05-07 09:30 UTC, nameless2800
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nameless2800 2022-05-05 13:44:21 UTC
Created attachment 148582 [details]
The error message that appears when it crashes or when you try to open the file again.

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***
I'm using the flatpak Okular and, when using the freehand line tool and saving (I did not tried to reproduce it using other annotation tools), it crashes and corrupt the file making me lose the archive.
Sometimes it takes more time to crash and sometime less. Just keep making the lines and saving and eventually it will freeze for a couple seconds and close the file with an error message saying it was unable to reach the file.
I tried using the old version of Okular available in the repositores and wasn't able to reproduce the issue, so maybe its a new bug.

STEPS TO REPRODUCE
1. Make a freehand line
2. Save the document
3. Keep doing until it freezes.

OBSERVED RESULT
The file gets corrupted.

EXPECTED RESULT
Save the document properly and keep the work.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Albert Astals Cid 2022-05-05 21:19:10 UTC
I can not reproduce.

Can you attach a file you can reproduce this problem with?

Do you get a crash dialog report? Can you paste its contents?
Comment 2 nameless2800 2022-05-06 22:06:50 UTC
(In reply to Albert Astals Cid from comment #1)
> I can not reproduce.
> 
> Can you attach a file you can reproduce this problem with?
> 
> Do you get a crash dialog report? Can you paste its contents?

Sorry, I couldn't attach the file because it is a 13mb file. Maybe its something related with the file size? I got the same problem with another file, but it was a larger one with almost 40mb.
When it crash just appears an error message with this: Could not open file:///home/wolff/Downloads/TR Book.pdf. 
If you need the exact same file you can find it here: https://docero.com.br/doc/n05808e
Comment 3 Albert Astals Cid 2022-05-07 09:08:36 UTC
(In reply to nameless2800 from comment #2)
> (In reply to Albert Astals Cid from comment #1)
> > I can not reproduce.
> > 
> > Can you attach a file you can reproduce this problem with?
> > 
> > Do you get a crash dialog report? Can you paste its contents?
> 
> Sorry, I couldn't attach the file because it is a 13mb file. Maybe its
> something related with the file size? I got the same problem with another
> file, but it was a larger one with almost 40mb.
> When it crash just appears an error message with this: Could not open
> file:///home/wolff/Downloads/TR Book.pdf. 

Do you get an error message or it crashes? 

> If you need the exact same file you can find it here:
> https://docero.com.br/doc/n05808e

That address doesn't seem to exist, can you please check again?

Also it would be probably be useful to get the corrupted file
Comment 4 nameless2800 2022-05-07 09:30:58 UTC
Created attachment 148632 [details]
A printscreen for the exact moment the error occur
Comment 5 nameless2800 2022-05-07 09:36:17 UTC
(In reply to Albert Astals Cid from comment #3)
> (In reply to nameless2800 from comment #2)
> > (In reply to Albert Astals Cid from comment #1)
> > > I can not reproduce.
> > > 
> > > Can you attach a file you can reproduce this problem with?
> > > 
> > > Do you get a crash dialog report? Can you paste its contents?
> > 
> > Sorry, I couldn't attach the file because it is a 13mb file. Maybe its
> > something related with the file size? I got the same problem with another
> > file, but it was a larger one with almost 40mb.
> > When it crash just appears an error message with this: Could not open
> > file:///home/wolff/Downloads/TR Book.pdf. 
> 
> Do you get an error message or it crashes? 
> 

Sorry, it freeze, then show an error message then it closes. I attached a printscreen for the exact moment when the error occur.

> > If you need the exact same file you can find it here:
> > https://docero.com.br/doc/n05808e
> 
> That address doesn't seem to exist, can you please check again?
> 

Strange, it works here. Ayway I just did it again with this other file https://pt.br1lib.org/book/5210534/46b217 
Its the same I use in the printscreen I just uploaded.
It seems to me that you can reproduce with some files with 10mb or more. This one its 20mb.

> Also it would be probably be useful to get the corrupted file

Yeah, I can send it, but just dont know how or where upload it so you can get it. Since its a relatively big file I can't attach it here.
Comment 6 nameless2800 2022-05-07 10:06:46 UTC
(In reply to Albert Astals Cid from comment #3)
> (In reply to nameless2800 from comment #2)
> > (In reply to Albert Astals Cid from comment #1)
> > > I can not reproduce.
> > > 
> > > Can you attach a file you can reproduce this problem with?
> > > 
> > > Do you get a crash dialog report? Can you paste its contents?
> > 
> > Sorry, I couldn't attach the file because it is a 13mb file. Maybe its
> > something related with the file size? I got the same problem with another
> > file, but it was a larger one with almost 40mb.
> > When it crash just appears an error message with this: Could not open
> > file:///home/wolff/Downloads/TR Book.pdf. 
> 
> Do you get an error message or it crashes? 
> 
> > If you need the exact same file you can find it here:
> > https://docero.com.br/doc/n05808e
> 
> That address doesn't seem to exist, can you please check again?
> 
> Also it would be probably be useful to get the corrupted file

So, I just uploaded the corrupted file and the original one here: https://drive.google.com/drive/folders/1fcy0ML6lXLkUGqx6NvshwJruVbhUF7fW?usp=sharing
Hope it works.
Comment 7 Albert Astals Cid 2022-05-08 21:42:10 UTC
Cannot reproduce.

Which distribution are you using? (shouldn't matter but it's always good to know)
Comment 8 nameless2800 2022-05-09 11:00:36 UTC
(In reply to Albert Astals Cid from comment #7)
> Cannot reproduce.
> 
> Which distribution are you using? (shouldn't matter but it's always good to
> know)

Ok, now thats weird. I still can do it.
I'm using Linux Mint.
Comment 9 Albert Astals Cid 2022-05-09 20:53:09 UTC
Bringing back to reported until we can get someone from the developer team to reproduce this.
Comment 10 Tymek 2022-07-03 19:47:54 UTC
I have been encountering the very same issue using Okular Flatpak -- occurring on versions 21.12.3 and 22.04.x (haven't tested other Flatpak versions).  I just so happen to also be running Linux Mint (20.3).

After about an hour of using Okular's annotation features and hitting the save button on my PDF file, I eventually get the same save error and my PDF file is corrupt. I have partly figured-out why this happens, now I am wondering how to fix it.

It turns out:
At each PDF save operation Okular creates a copy of the latest PDF file under
     /run/user/1000/app/org.kde.okular 
(a tmpfs filesystem located in memory).  Depending on the size of the PDF file, sooner or later the number of PDF file copies accumulates and completely fills the tmpfs filesystem, and any further save operations fail, leading to the aforementioned corruption error.  The error will persist until a system reboot at which point the tmpfs filesystem is cleared.

How can this be disabled?  Is this behaviour attributable to Okular or Flatpak?

On another machine running Debian 11, I have a fairly recent version of Okular (20.12.3) running as a native application and this error does not occur.
Comment 11 Bug Janitor Service 2022-07-03 23:06:21 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/626
Comment 12 Albert Astals Cid 2022-07-04 17:43:44 UTC
Git commit e7db8c92ae398a0c75be471aea01d44d5880e8a4 by Albert Astals Cid.
Committed on 03/07/2022 at 23:05.
Pushed by aacid into branch 'release/22.04'.

Don't leave temp files around when saving

M  +12   -12   part/part.cpp

https://invent.kde.org/graphics/okular/commit/e7db8c92ae398a0c75be471aea01d44d5880e8a4