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 153751 - gimp_image_set_filename() should check encoding
gimp_image_set_filename() should check encoding
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: libgimp
2.0.x
Other All
: Normal minor
: ---
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2004-09-26 01:24 UTC by Kite Lau
Modified: 2004-11-14 00:35 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Kite Lau 2004-09-26 01:24:12 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.
Comment 1 Sven Neumann 2004-09-26 09:46:36 UTC
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.
Comment 2 Kite Lau 2004-09-26 11:39:36 UTC
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
Comment 3 Sven Neumann 2004-09-26 17:26:23 UTC
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?
Comment 4 Kite Lau 2004-09-26 17:45:40 UTC
G_BROKEN_FILENAMES has been set to 1, and my glib installed is glib2-2.4.6
Comment 5 weskaggs 2004-09-28 20:40:57 UTC
changing status since reporter has responded with requested information.
Comment 6 Sven Neumann 2004-09-28 21:38:07 UTC
I think we will need a stack trace from the crash if we want to get any further
here.
Comment 7 Kite Lau 2004-09-30 04:22:43 UTC
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
  • #0 g_on_error_stack_trace
    from /usr/lib/libglib-2.0.so.0
  • #1 gimp_terminate
  • #2 gimp_fatal_error
  • #3 main

-------------------
Comment 8 Sven Neumann 2004-09-30 08:46:15 UTC
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.
Comment 9 Kite Lau 2004-10-02 07:44:07 UTC
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
Comment 10 zlb 2004-10-29 01:41:40 UTC
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.

Thread NaN (LWP 19320)

  • #0 strchr
    from /lib/tls/libc.so.6
  • #1 file_utils_uri_to_utf8_basename
  • #2 gimp_display_shell_update_title
  • #3 gimp_display_shell_update_title
  • #4 g_child_watch_add
    from /usr/lib/libglib-2.0.so.0
  • #5 g_main_depth
    from /usr/lib/libglib-2.0.so.0
  • #6 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #7 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #8 g_main_loop_run
    from /usr/lib/libglib-2.0.so.0
  • #9 plug_in_run
  • #10 procedural_db_execute
  • #11 file_save_as
  • #12 file_save_a_copy_dialog_show
  • #13 file_save_a_copy_dialog_show
  • #14 gimp_query_boolean_box
    from /usr/lib/libgimpwidgets-2.0.so.0
  • #15 g_cclosure_marshal_VOID
    from /usr/lib/libgobject-2.0.so.0
  • #16 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #17 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #18 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #19 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #20 gtk_dialog_response
    from /usr/lib/libgtk-x11-2.0.so.0
  • #21 gtk_dialog_new_with_buttons
    from /usr/lib/libgtk-x11-2.0.so.0
  • #22 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #23 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #24 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #25 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #26 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #27 gtk_button_clicked
    from /usr/lib/libgtk-x11-2.0.so.0
  • #28 gtk_button_get_relief
    from /usr/lib/libgtk-x11-2.0.so.0
  • #29 gtk_button_get_relief
    from /usr/lib/libgtk-x11-2.0.so.0
  • #30 gtk_marshal_VOID__UINT_STRING
    from /usr/lib/libgtk-x11-2.0.so.0
  • #31 g_cclosure_new_swap
    from /usr/lib/libgobject-2.0.so.0
  • #32 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #33 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #34 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #35 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #36 gtk_widget_send_expose
    from /usr/lib/libgtk-x11-2.0.so.0
  • #37 gtk_propagate_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #38 gtk_main_do_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #39 gdk_x11_register_standard_event_type
    from /usr/lib/libgdk-x11-2.0.so.0
  • #40 g_main_depth
    from /usr/lib/libglib-2.0.so.0
  • #41 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #42 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #43 g_main_loop_run
    from /usr/lib/libglib-2.0.so.0
  • #44 gtk_main
    from /usr/lib/libgtk-x11-2.0.so.0
  • #45 app_run
  • #46 main

Comment 11 zlb 2004-10-29 01:45:58 UTC
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.

Thread NaN (LWP 19320)

  • #0 strchr
    from /lib/tls/libc.so.6
  • #1 file_utils_uri_to_utf8_basename
  • #2 gimp_display_shell_update_title
  • #3 gimp_display_shell_update_title
  • #4 g_child_watch_add
    from /usr/lib/libglib-2.0.so.0
  • #5 g_main_depth
    from /usr/lib/libglib-2.0.so.0
  • #6 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #7 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #8 g_main_loop_run
    from /usr/lib/libglib-2.0.so.0
  • #9 plug_in_run
  • #10 procedural_db_execute
  • #11 file_save_as
  • #12 file_save_a_copy_dialog_show
  • #13 file_save_a_copy_dialog_show
  • #14 gimp_query_boolean_box
    from /usr/lib/libgimpwidgets-2.0.so.0
  • #15 g_cclosure_marshal_VOID
    from /usr/lib/libgobject-2.0.so.0
  • #16 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #17 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #18 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #19 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #20 gtk_dialog_response
    from /usr/lib/libgtk-x11-2.0.so.0
  • #21 gtk_dialog_new_with_buttons
    from /usr/lib/libgtk-x11-2.0.so.0
  • #22 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #23 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #24 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #25 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #26 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #27 gtk_button_clicked
    from /usr/lib/libgtk-x11-2.0.so.0
  • #28 gtk_button_get_relief
    from /usr/lib/libgtk-x11-2.0.so.0
  • #29 gtk_button_get_relief
    from /usr/lib/libgtk-x11-2.0.so.0
  • #30 gtk_marshal_VOID__UINT_STRING
    from /usr/lib/libgtk-x11-2.0.so.0
  • #31 g_cclosure_new_swap
    from /usr/lib/libgobject-2.0.so.0
  • #32 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #33 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #34 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #35 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #36 gtk_widget_send_expose
    from /usr/lib/libgtk-x11-2.0.so.0
  • #37 gtk_propagate_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #38 gtk_main_do_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #39 gdk_x11_register_standard_event_type
    from /usr/lib/libgdk-x11-2.0.so.0
  • #40 g_main_depth
    from /usr/lib/libglib-2.0.so.0
  • #41 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #42 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #43 g_main_loop_run
    from /usr/lib/libglib-2.0.so.0
  • #44 gtk_main
    from /usr/lib/libgtk-x11-2.0.so.0
  • #45 app_run
  • #46 main

Comment 12 zlb 2004-10-29 01:47:22 UTC
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.

Thread NaN (LWP 19320)

  • #0 strchr
    from /lib/tls/libc.so.6
  • #1 file_utils_uri_to_utf8_basename
  • #2 gimp_display_shell_update_title
  • #3 gimp_display_shell_update_title
  • #4 g_child_watch_add
    from /usr/lib/libglib-2.0.so.0
  • #5 g_main_depth
    from /usr/lib/libglib-2.0.so.0
  • #6 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #7 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #8 g_main_loop_run
    from /usr/lib/libglib-2.0.so.0
  • #9 plug_in_run
  • #10 procedural_db_execute
  • #11 file_save_as
  • #12 file_save_a_copy_dialog_show
  • #13 file_save_a_copy_dialog_show
  • #14 gimp_query_boolean_box
    from /usr/lib/libgimpwidgets-2.0.so.0
  • #15 g_cclosure_marshal_VOID
    from /usr/lib/libgobject-2.0.so.0
  • #16 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #17 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #18 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #19 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #20 gtk_dialog_response
    from /usr/lib/libgtk-x11-2.0.so.0
  • #21 gtk_dialog_new_with_buttons
    from /usr/lib/libgtk-x11-2.0.so.0
  • #22 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #23 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #24 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #25 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #26 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #27 gtk_button_clicked
    from /usr/lib/libgtk-x11-2.0.so.0
  • #28 gtk_button_get_relief
    from /usr/lib/libgtk-x11-2.0.so.0
  • #29 gtk_button_get_relief
    from /usr/lib/libgtk-x11-2.0.so.0
  • #30 gtk_marshal_VOID__UINT_STRING
    from /usr/lib/libgtk-x11-2.0.so.0
  • #31 g_cclosure_new_swap
    from /usr/lib/libgobject-2.0.so.0
  • #32 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #33 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #34 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #35 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #36 gtk_widget_send_expose
    from /usr/lib/libgtk-x11-2.0.so.0
  • #37 gtk_propagate_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #38 gtk_main_do_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #39 gdk_x11_register_standard_event_type
    from /usr/lib/libgdk-x11-2.0.so.0
  • #40 g_main_depth
    from /usr/lib/libglib-2.0.so.0
  • #41 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #42 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #43 g_main_loop_run
    from /usr/lib/libglib-2.0.so.0
  • #44 gtk_main
    from /usr/lib/libgtk-x11-2.0.so.0
  • #45 app_run
  • #46 main

Comment 13 zlb 2004-10-29 07:33:05 UTC
Sorry I posted my comment several times :)
Is there a way to delete duplicate messages?
Comment 14 Sven Neumann 2004-10-29 12:45:40 UTC
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.
Comment 15 Sven Neumann 2004-10-29 12:59:19 UTC
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.
Comment 16 Sven Neumann 2004-10-29 13:08:34 UTC
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.
Comment 17 zlb 2004-10-29 14:02:22 UTC
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 :)
Comment 18 Sven Neumann 2004-10-29 14:18:28 UTC
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.
Comment 19 zlb 2004-10-29 14:52:47 UTC
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 :)
Comment 20 Sven Neumann 2004-10-29 14:54:14 UTC
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.
Comment 21 Sven Neumann 2004-10-29 15:21:29 UTC
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).
Comment 22 Sven Neumann 2004-11-13 20:35:49 UTC
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.
Comment 23 Manish Singh 2004-11-14 00:35:28 UTC
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.