Arch Linux

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#44681 - [leafpad] wipes file content when saving on gvfs

Attached to Project: Arch Linux
Opened by Vizitor (Vizitor) - Tuesday, 21 April 2015, 17:45 GMT
Last edited by Christian Hesse (eworm) - Saturday, 05 August 2017, 18:06 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Jan de Groot (JGC)
Christian Hesse (eworm)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No


When editing text file on samba shares, after saving AND exiting leafpad, complete text (you see that when opening again, with leafpad or other txt editor) is wiped out. I rarely use leafpad over LAN files, and can roughly say that last year 10/2014, there was no this bug.

Additional info:
* package version(s)
* config and/or log files etc.
3.19.3-3-ARCH x86_64, Mate Desktop, everything regular without any special modifications.

Steps to reproduce:
Open some text file with leafpad (make backup first!) on some of the samba shared text files over your LAN;
type few letters for testing, save and exit. Now, open it again - file is completely blank - no text at all.

This task depends upon

Closed by  Christian Hesse (eworm)
Saturday, 05 August 2017, 18:06 GMT
Reason for closing:  Fixed
Additional comments about closing:  leafpad
Comment by Doug Newgard (Scimmia) - Thursday, 23 April 2015, 02:46 GMT
I'm guessing leafpad uses gtk2 for this functionality, so I'm pulling in JGC, too.
Comment by Vizitor (Vizitor) - Saturday, 09 May 2015, 08:40 GMT
Just fully upgraded/updated system; kernel is now 4.0.1-1-ARCH x86_64, and bug is still here.
Comment by Benny R (hippieshaker) - Friday, 17 June 2016, 04:17 GMT
It happens on SFTP/SSH connections as well as SMB so I think it is a GVFS issue. Seems to only occur on text files less than 4096 bytes for me. Yes this is a dangerous bug - I was just lucky to notice before losing important notes.

If you reverse lines 232 & 233 in src/file.c so that it becomes:
gtk_text_buffer_set_modified(buffer, FALSE);

and recompile it seems to fix the bug - the files save correctly. I think the above change still makes sense logically? There must be some issue between GVFS and gtk_text_buffer_set_modified where the buffer is lost.
Comment by Vizitor (Vizitor) - Sunday, 17 July 2016, 21:25 GMT
File "leafpad" from 2016-05-03 is still with that bug; so I downloaded file from here ( and reversed those lines, installed it with ./configure-make-make install , (because I don't know how to makepkg / ABS ) , and this WORKS!

BTW, after Benny mention GVFS, I noticed that (with all those buggy versions) error ocures only if samba shares is mounted through file manager (which uses gvfs).
If I mount SAME LOCATION of Samba Share with "mount -t cifs // /mnt/v1 -o guest,sec=ntlm"
and then open some file, let's say "leafpad /mnt/v1/some_text_file" blanking/erasing text, does not occure.
Comment by Christian Hesse (eworm) - Friday, 04 August 2017, 09:44 GMT
I think the proposed fix is wrong. Can you please test the change from attached file?
Comment by Benny R (hippieshaker) - Saturday, 05 August 2017, 14:22 GMT
I can confirm the patch works.

Can you explain briefly why the line gtk_text_buffer_set_modified(buffer,FALSE); should go where you put it rather than where I suggested? I'm not a C or GTK programmer, but am learning. Why does the bug only appear on GVFS, not when saving locally? Cheers.
Comment by Christian Hesse (eworm) - Saturday, 05 August 2017, 18:05 GMT
This sets a watch on the buffer which emits a signal whenever it changes. Doing so after everything is does not make sense. ;)
Not sure why the original code works for regular filesystems but fails for gvfs. Probably undefined and/or racy behaviour.