After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 744035 - Save As creates corrupt file
Save As creates corrupt file
Status: RESOLVED DUPLICATE of bug 730211
Product: GIMP
Classification: Other
Component: General
2.8.14
Other Windows
: Normal critical
: ---
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2015-02-05 11:02 UTC by Hz4Daz
Modified: 2016-05-03 12:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Associated GIMP file demonstrating bug (587.89 KB, application/octet-stream)
2015-02-05 11:02 UTC, Hz4Daz
Details
Additional source file (581.96 KB, application/octet-stream)
2015-02-06 14:57 UTC, Hz4Daz
Details
Corrupt output for original example file (588.34 KB, application/octet-stream)
2015-02-06 14:58 UTC, Hz4Daz
Details
Corrupt output for second example file (582.57 KB, application/octet-stream)
2015-02-06 14:58 UTC, Hz4Daz
Details

Description Hz4Daz 2015-02-05 11:02:19 UTC
Created attachment 296186 [details]
Associated GIMP file demonstrating bug

Saving the attached file ("Save As") which was created under older version of GIMP (2.6.?) - without making a single change to the file - reliably creates a corrupted file which will not load.

There seems to be no issue loading the original file, yet any attempt to make a backup copy will not work.
Comment 1 Hz4Daz 2015-02-05 12:54:46 UTC
Neglected to add full version information, as follows:

GNU Image Manipulation Program version 2.8.14
git-describe: GIMP_2_8_12-2-ge62e6fe

using GEGL version 0.2.0 (compiled against version 0.2.0)
using GLib version 2.40.0 (compiled against version 2.40.0)
using GdkPixbuf version 2.30.8 (compiled against version 2.30.8)
using GTK+ version 2.24.24 (compiled against version 2.24.23)
using Pango version 1.36.5 (compiled against version 1.36.5)
using Fontconfig version 2.11.1 (compiled against version 2.11.1)
using Cairo version 1.12.16 (compiled against version 1.12.16)
Comment 2 Michael Natterer 2015-02-05 13:37:38 UTC
Just tried with GIMP 2.8.14 from debian unstable. Saving as a different
filename creates an XCF that can be loaded without any problem.

Can somebody try on Windows please?
Comment 3 Michael Schumacher 2015-02-06 14:49:16 UTC
Works fine for me. 

Can you attach one example - or maybe two, to be able to check for differences - of the corrupt file?
Comment 4 Hz4Daz 2015-02-06 14:57:42 UTC
Created attachment 296280 [details]
Additional source file
Comment 5 Hz4Daz 2015-02-06 14:58:21 UTC
Created attachment 296281 [details]
Corrupt output for original example file
Comment 6 Hz4Daz 2015-02-06 14:58:50 UTC
Created attachment 296282 [details]
Corrupt output for second example file
Comment 7 Hz4Daz 2015-02-06 15:05:30 UTC
Files attached as requested.

I have two copies of the original (V 2.6.x) xcf file, each exhibiting the same problem.  The two copies were suffixed "1" and "2" for various editing stages.

In each instance I simply opened the File, make no changes and do a Save As to create a new file, suffixed with "-Save As".

Both save as files are corrupt, are slightly larger than the originals and fail at different points when opening:

The "1-Save As" puts a message on the main window footer "This file is corrupt!  I have loaded as much of it as I can, but it is incomplete.". Very little of the file loads.

The "2-Save As" shows a GIMP Dialog "GIMP Message" "Opening <filename> failed: This xcf file is corrupt!  I could not even salvage any partial image from it.".

Thanks for looking into this problem.
Comment 8 Massimo 2015-02-08 08:46:33 UTC
I compared with an hex editor (vim in effect) the corrupt
file attached to comment #5 with a copy saved locally and
valid. The difference is that many text layer parasites
have a property size of 0.




The question is: does this happen saving to a local disk
or is a network file system (SAMBA, NAS) involved?




The code, as in many other places, seeks back and forth:
first it writes a zero as the property size then it writes
the whole property, moves back to the size position,
overwrites the size and moves forward to the end.


In the case of a text layer the property size of the parasite
is redundant and after patching GIMP it is possible to load
the corrupt file.

Patch only for experimentation, not meant to be pushed to
the sources tree.

diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index b180377..93e93b9 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -879,7 +879,7 @@ xcf_load_layer_props (XcfInfo    *info,
           {
             glong base = info->cp;

-            while (info->cp - base < prop_size)
+            do
               {
                 GimpParasite *p = xcf_load_parasite (info);

@@ -889,8 +889,9 @@ xcf_load_layer_props (XcfInfo    *info,
                 gimp_item_parasite_attach (GIMP_ITEM (*layer), p, FALSE);
                 gimp_parasite_free (p);
               }
+            while (info->cp - base < prop_size);

-            if (info->cp - base != prop_size)
+            if (prop_size && info->cp - base != prop_size)
               gimp_message_literal (info->gimp, G_OBJECT (info->progress),
                                    GIMP_MESSAGE_WARNING,
                                    "Error while loading a layer's parasites");
Comment 9 Hz4Daz 2015-02-10 07:24:42 UTC
Hi Massimo,

Thanks for looking into this issue.

Your comments gave me pause to consider what I am doing:
Replacement of my desktop unit a while back resulted in the locally stored files being put onto a networked drive (NAS), including the ones I was having issue with.  I only attempted to edit them directly on the networked storage - it never occurred to me that this could be an issue, as no other applications had problems.

After your post, I have copied the files back to local storage and can successfully edit/save them there. So the actual "Save As" issue relates to GIMP writing to a NAS device.

Apologies for the misdirection - will this bug be reassigned to one about GIMP writes the xcf files to networked drives?

Many Thanks.
Comment 10 Massimo 2015-02-11 18:29:38 UTC
(In reply to Hz4Daz from comment #9)
> Hi Massimo,
> 
> Thanks for looking into this issue.
> 
> Your comments gave me pause to consider what I am doing:
> Replacement of my desktop unit a while back resulted in the locally stored
> files being put onto a networked drive (NAS), including the ones I was
> having issue with.  I only attempted to edit them directly on the networked
> storage - it never occurred to me that this could be an issue, as no other
> applications had problems.
> 
> After your post, I have copied the files back to local storage and can
> successfully edit/save them there. So the actual "Save As" issue relates to
> GIMP writing to a NAS device.
>

I did a search on: corrupt files saving NAS 
and there are many results. 

I'd make sure to have all software updated and if it is a 
dedicated hardware perhaps report the issue to their support forums.

> Apologies for the misdirection - will this bug be reassigned to one about
> GIMP writes the xcf files to networked drives?
> 
> Many Thanks.

Regarding GIMP probably it is the case to add a big warning
in the release notes or README or KNOWN_ISSUES to try to prevent
future data loss.
Comment 11 Michael Schumacher 2015-07-16 14:24:47 UTC
Is this a duplicate of bug 730211?
Comment 12 Michael Schumacher 2016-05-03 12:38:17 UTC
Let's assume that it is.

Thanks for taking the time to report this.
This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.

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