GNOME Bugzilla – Bug 153751
gimp_image_set_filename() should check encoding
Last modified: 2004-11-14 00:35:28 UTC
Under locale of zh_CN.gbk, that is to set export LANG=zh_CN.gbk and export LC_ALL=zh_CN.gbk 1. Run gimp 2.04 or 2.05 2. open any jpg image 3. Add a new transparent layer 4. Save the image as another jpg image 5. Select export image 6. Gimp crashes on exporting the image And here is the error messgae from linux x-terminal: (jpeg:7681): LibGimpBase-WARNING **: jpeg: wire_read(): error (script-fu:7679): LibGimpBase-WARNING **: script-fu: wire_read(): segment fault It doest not happen when the locale is set to C etc.
I cannot reproduce this problem using the zh_CN.UTF-8 locale. I suspect that it is a problem with filename encodings. Did you certainly try this with gimp-2.0.5? There are a couple of checks in gimp 2.0.5 which are supposed to catch the problem of running gimp in a broken locale environment.
The locale I produced the problem with is zh_CN.gbk (which is most Chinese-speaking people set to) instead of your mentioned zh_CN.UTF-8. I did try this with gimp-2.0.5. Please double check. I tried zh_CN.utf8 and it is working with no problem. Regards, Kite
OK, so since you are not running an UTF-8 locale, filenames in your filesystem are probably not UTF-8 encoded then. Do you have the environment variable G_FILESYSTEM_ENCODING set to tell GIMP (or rather GLib) about the encoding of your filesystem? Or is G_BROKEN_FILENAMES set?
G_BROKEN_FILENAMES has been set to 1, and my glib installed is glib2-2.4.6
changing status since reporter has responded with requested information.
I think we will need a stack trace from the crash if we want to get any further here.
Here is the output from a stack trace. This time gimp did not crash completely, gimp windows turned blank and refused to response. I have to kill gimp. -------------- gimp --stack-trace-mode always ** (gimp:2743): WARNING **: Invalid borders specified for theme pixmap: /usr/share/themes/MacOS-X/gtk-2.0/entry2.png, borders don't fit within the image gimp: fatal error: Segment Fault
+ Trace 50617
-------------------
Well, you should probably first of all stop using that GTK+ theme, or alternatively fix it. If it gives you a warning, that is a bug. The behaviour of the application after such a warning is undefined so it doesn't make any sense to look for further errors after such a warning message. The stack trace doesn't show a crash and is thus useless.
Hi, I switched to another theme and it did not make any changes. I doubt it is not a problem with the theme. Once again, gimp did not crash but turned blank and refused to response once gimp run with option of --stack-trace-mode always. If gimp run without options appended, it crashed completely! If you have time to check youselves, you can set locale to zh_CN.gbk before running gimp by doing the following under xterminal. export LANG=zh_CN.gbk export LC_ALL=zh_CN.gbk I think you can guess through the Chinese menu :) Regards, Kite
I can reproduce the bug with gimp-2.0.5-0.fc2.3 under FC2. Here's a back trace produced under gdb: (I can rerun the test with an unstripped binary if you think it necessary): Detaching after fork from child process 19351. Detaching after fork from child process 19355. Program received signal SIGSEGV, Segmentation fault.
+ Trace 51438
Thread NaN (LWP 19320)
+ Trace 51440
+ Trace 51441
Sorry I posted my comment several times :) Is there a way to delete duplicate messages?
I'd suggest you change your filesystem encoding to UTF-8 and unset G_BROKEN_FILENAMES. The environment variable contains the word "broken" for a good reason.
The problem seems to be that the JPEG plug-in sets the filename of the preview image that it generates to "Export Preview". This string is translated and obviously the translated string cannot be expressed in the filesystem encoding.
I've added workaround for this problem to both branches: 2004-10-29 Sven Neumann <sven@gimp.org> * app/file/file-utils.c (file_utils_uri_to_utf8_filename): when the filename cannot be converted to UTF-8, warn and return the URI instead. This is a workaround for the crash described in bug #153751. This stops GIMP from crashing. The filename of the JPEG preview image is still broken and the change doesn't really count as a fix.
It is not easy for us to switch from zh_CN.GB* locale to zh_CN.UTF8, because we then have to convert all text files which are encoded in the GB encoding (or at least take care of), and all filenames containing Chinese characters, and pay much attention with the encoding issues every time when dealing with a text file because most text files from windows and from other people are GBK encoded ... Thanks for the workaround and I'll try it later. Hope a real fix will come up soon :)
You don't need to change the locale and you don't need to convert any text files. You just need to stop the broken filename encoding. All you need to do is to switch the filename encoding to UTF-8 and there are scripts that take care of converting all filenames.
It's still a big decision to make and I'm afraid of unexpected troubles ... I have just fetched your changes from CVS and applied it to gimp-2.0.5-0.fc2.3. GIMP stops from crashing and I can continue to live with the GBK locale :)
A real fix for the problem would involve adding checks to the PDB wrapper for gimp_image_set_filename() that ensure that it is called with a filename in the filesystem encoding which can safely be converted to UTF-8 and back. Perhaps we should then also add gimp_image_set_name_utf8(), a function that takes an UTF-8 encoded name (and checks if it can be converted to the local filesystem encoding). The JPEG plug-in could then use that function. At the moment the JPEG plug-in is definitely doing the wrong thing. What we could do right now is to use g_filename_from_utf8() in the jpeg plug-in and pass the result to gimp_image_set_filename(). I think I'll just do that now.
2004-10-29 Sven Neumann <sven@gimp.org> * plug-ins/common/jpeg.c: pass the name to filesystem encoding to gimp_image_set_filename(). Fixes bug #153751 for the JPEG plug-in. I will leave this report open with minor severity until better parameter checking has been added to the PDB wrapper(s).
This addresses a somewhat related bug in gimp_image_get_name() and improves the documentation for gimp_image_get_filename(): 2004-11-13 Sven Neumann <sven@gimp.org> * tools/pdbgen/pdb/image.pdb: document the fact that gimp_image_get_filename() returns the filename in the filesystem encoding. Fixed gimp_image_get_name() to actually return the name in UTF-8 encoding. * app/pdb/image_cmds.c * libgimp/gimpimage_pdb.c * app/vectors/gimpbezierstroke.h: formatting.
2004-11-13 Manish Singh <yosh@gimp.org> * tools/pdbgen/pdb/image.pdb: Adapted Sven's code into pdbgen so that gimp_image_set_filename() validates that it is called with a filename in the filesystem encoding which can safely be converted to UTF-8 and back. Fixes #153751. * app/pdb/image_cmds.c * libgimp/gimpimage_pdb.c: Regenerated.