Bug 333086 - Kate adds cruft to a file and then won't save the file anymore
Summary: Kate adds cruft to a file and then won't save the file anymore
Status: RESOLVED DUPLICATE of bug 323693
Alias: None
Product: kate
Classification: Unclassified
Component: application (show other bugs)
Version: 3.12.3
Platform: Fedora RPMs Linux
: NOR critical (vote)
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-04 23:58 UTC by digimer
Modified: 2014-04-06 03:25 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
The file that is getting corrupted in this bug report. (203.92 KB, application/octet-stream)
2014-04-05 18:53 UTC, digimer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description digimer 2014-04-04 23:58:12 UTC
Twice now, I was editing a (somewhat large) file and started getting errors from my program. Looking at the file in kate, everything looked fine. Eventually I realized that part of the end of the file (saw last 20ish lines) were repeated but not shown until I pressed F5. I tried to delete these lines and resave, and it *looked* like it saved, but pressing F5 caused the lines to reappear. 

I confirmed that the file was not being changed by watching the byte size and mtime of the file before and after trying to save. The file itself was fine though; I edited the file in vim to remove the cruft and it saved fine, so I don't think this was a disk error.

Both events happened on Fedora 20. The first time was a month or two ago. I thought it was a size issue (the file was almost exactly 400 KiB), and when I deleted enough of the file (moved some functions to another file), kate started working properly. Today though, the effected file was half the size, so I don't think it's size related. Between these two incidents, I am pretty sure (though not positive) that kate was updated.

Today when this happened, I closed and restarted kate but I still could not edit the file.

Reproducible: Sometimes

Steps to Reproduce:
1. I don't have a good reproducer, sorry. It happens seemingly very randomly.
2.
3.
Actual Results:  
File gets cruft appended and won't save changes

Expected Results:  
File saves changes and doesn't randomly copy lines from the end of the file.

I believe the first incident happened before a recent OS reinstall on a new hard drive, so I am pretty certain the issue is not drive related. I do use luks to encryption on the drives though, in case that matters.

RPM version: kate-4.12.3-1.fc20.x86_64
uname: Linux lemass.alteeve.ca 3.13.7-200.fc20.x86_64 #1 SMP Mon Mar 24 22:01:49 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Kate is the only KDE-based app I use. Normally I run it from my Gnome3 desktop (in case that matters, too).

I am marking this as critical, as it effectively corrupts the file and refuses to save changes once happened. Given the sporatic nature of it happening though, you may wish to alter this.
Comment 1 digimer 2014-04-05 18:33:26 UTC
I've hit this bug again. This time, I was able to check what was happening and realized I made a mistake in my report above. The file's mtime *does* change, but the size doesn't.

In this case, kate repeated the last two lines of the file:

====
diff --git a/cgi-bin/an-cluster.lib b/cgi-bin/an-cluster.lib
index 7c3b4dd..bd578c8 100755
--- a/cgi-bin/an-cluster.lib
+++ b/cgi-bin/an-cluster.lib
@@ -5502,3 +5502,6 @@ sub _make_hash_reference
 }
 
 1;
+
+1;
+
====

If I look at the file size and mtime, I see:

====
lemass:~/projects/an-cluster/an-cdb$ ls -la /var/www/cgi-bin/an-cluster.lib
-rwxrwxr-x 1 digimer digimer 208809 Apr  5 14:24 /var/www/cgi-bin/an-cluster.lib
====

If I delete the repeated/added lines and save the file, I see the mtime change, but not the file size:

====
lemass:~/projects/an-cluster/an-cdb$ ls -la /var/www/cgi-bin/an-cluster.lib
-rwxrwxr-x 1 digimer digimer 208809 Apr  5 14:26 /var/www/cgi-bin/an-cluster.lib
====

If I press <f5>, the just-deleted lines return. I took a short screen cast showing this: 

https://www.youtube.com/watch?v=ImZGaZaox8M

To confirm it's not a disk problem, I edited it in vim and saved the changes.

====
lemass:~/projects/an-cluster/an-cdb$ vim /var/www/cgi-bin/an-cluster.lib
lemass:~/projects/an-cluster/an-cdb$ ls -la /var/www/cgi-bin/an-cluster.lib
-rwxrwxr-x 1 digimer digimer 208804 Apr  5 14:32 /var/www/cgi-bin/an-cluster.lib
====

I still don't know how to trigger this on demand, but at this time, kate is no longer useful for me because this bug randomly breaks my files. :(
Comment 2 digimer 2014-04-05 18:49:44 UTC
I've been able to narrow down things a little.

I rebooted my computer, re-opened the file with kate and the problem remains. While playing around, I realized that adding lines to a file works fine. The problem happens when I delete lines. So I took another screen cast showing how kate properly saves when a bunch of lines are added to the file, then sticks garbage onto the end of the file when those new lines are deleted again. I edited the file in vim, saved and confirmed that the file was cleared up properly.

Screen cast:

https://www.youtube.com/watch?v=Gh4dCddueac

(you'll probably want to load it at 1080p and full screen to see what's happening better).
Comment 3 digimer 2014-04-05 18:53:07 UTC
More info;

I moved my ~/.kde directory out of the way and started kate again, causing it to create a new .kde directory. The problem persists, so that's not the issue either. I will attach a copy of the file that is breaking.
Comment 4 digimer 2014-04-05 18:53:56 UTC
Created attachment 85967 [details]
The file that is getting corrupted in this bug report.
Comment 5 Rex Dieter 2014-04-06 03:25:01 UTC

*** This bug has been marked as a duplicate of bug 323693 ***