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 515135 - glibmm needs the option not to abort programs with different encodings
glibmm needs the option not to abort programs with different encodings
Status: RESOLVED NOTABUG
Product: glibmm
Classification: Bindings
Component: strings
unspecified
Other opensolaris
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2008-02-08 03:15 UTC by Takao Fujiwara
Modified: 2008-03-22 15:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for glib/src/convert.ccg (7.59 KB, patch)
2008-02-08 03:16 UTC, Takao Fujiwara
none Details | Review
Example Test Case (692 bytes, text/plain)
2008-02-13 13:04 UTC, Takao Fujiwara
  Details
test_with_catch.cc (884 bytes, text/plain)
2008-03-22 09:40 UTC, Murray Cumming
  Details

Description Takao Fujiwara 2008-02-08 03:15:31 UTC
Currently if Glib::locale_from_utf8() receives different encodings, it aborts in Glib::ConvertError::throw_func.


Exception type class ConvertError has no handle.
stopped in __exdbg_notify_of_throw
Signal ABRT __lwp_kill
0xfcacaa88: __lwp_kill+0x0008:  bcc,a,pt  %icc,__lwp_kill+0x18  ! 0xfcacaa98

(dbx) where -h
  [1] __exdbg_notify_of_throw(0xffbff818, 0xffbff800, 0x1c1c, 0x1c00, 0x160f0, 0xfcd6e004): 0xfcd55a68 
  [2] _ex_debug_handshake1(0xfcd6e140, 0x0, 0x1, 0x16f68, 0xfcd6d758, 0xfcd6df28): 0xfcd56890 
  [3] _ex_throw_body(0xfcd6e140, 0x0, 0xffbffc58, 0x16ccc, 0x91918, 0xfcd6e140): 0xfcd56b0c 
  [4] __Crun::ex_throw(0xfcd6e140, 0x1, 0xff1c3820, 0x0, 0xfcd6d758, 0xfcd6df6c): 0xfcd56a68 
=>[5] Glib::ConvertError::throw_func(gobject = 0x46760) "convert.cc"
  [6] Glib::Error::throw_exception(gobject = 0x46760) "error.cc"
  [7] Glib::locale_from_utf8(utf8_string = CLASS) "convert.cc"
  [8] main(0x1, 0xffbffcbc, 0x22af0, 0x22800, 0xfadd0, 0xffbffc34): 0x11f98 

When we use g_locale_from_utf8(), the error handling is owned by each application. I'ld need the option to avoid that applications always abort with the different encodings.
I think we have the case that the actual users' directories have different encoded file contents or file names against the current locale.

I'm attaching the patch.
Comment 1 Takao Fujiwara 2008-02-08 03:16:49 UTC
Created attachment 104681 [details] [review]
Patch for glib/src/convert.ccg

The idea is to use warnings instead of error aboarts.

Could you review the patch?
Comment 2 Murray Cumming 2008-02-09 10:55:53 UTC
I don't understand why throwing an exception causes an abort. Maybe you could submit a small test case to show that.
Comment 3 Takao Fujiwara 2008-02-13 13:04:25 UTC
Created attachment 105139 [details]
Example Test Case

I attached the test case.
The second locale_from_utf8() or filename_to_utf8() always abort on none UTF-8 locales.

Actually I don't know the debugger message "Exception type class ConvertError has no handle.".

Thanks.
Comment 4 Murray Cumming 2008-02-20 13:29:00 UTC
It does not seem to abort for me:

murrayc@murrayc-desktop:~$ g++ test.cc `pkg-config gtkmm-2.4 --libs --cflags`
murrayc@murrayc-desktop:~$ ./a.out 
TRUE 
Character out of range for UTF-8
Character out of range for UTF-8

(Note to self: Those Character out of range strings are in the test itself.)


I am on Ubuntu. What are you using?
Comment 5 Takao Fujiwara 2008-02-21 05:52:57 UTC
> TRUE 
> Character out of range for UTF-8
> Character out of range for UTF-8

It seems you run the program on UTF-8 locale.
Could you try it on ja_JP.eucJP locale?
The message "Character out of range for UTF-8" should be localized because glib20.mo has the message.

I don't remember Ubuntu has none UTF-8 locales.
My platform is Solaris. 

I invoked "yum install glibmm" on Fedora 8 but it seems no RPMs.
Comment 6 Murray Cumming 2008-03-14 16:34:32 UTC
> Could you try it on ja_JP.eucJP locale?

Sorry, I don't know how to install that locale on Ubuntu? Do you have any idea? I do have ja_JP.UTF-8. 
Comment 7 Murray Cumming 2008-03-17 12:32:15 UTC
Maybe you could suggest a different locale that I am likely to have. I'd really like to reproduce this problem.
Comment 8 Takao Fujiwara 2008-03-19 06:54:31 UTC
I could reproduce this problem on Ubuntu 7.

% sudo localedef -i fr_FR -f ISO-8859-1 fr_FR.ISO8859-1
% ls /usr/share/locale-langpack/fr/LC_MESSAGES/glib20.mo
% env LANG=fr_FR.ISO8859-1 ./test

Then the exampl program causes SEGV.
Thanks.
Comment 9 Murray Cumming 2008-03-22 09:39:38 UTC
Yes, I could reproduce this, though I had to install the regular fr language support in Ubuntu first:

murrayc@murrayc-laptop:~/Desktop$ env LANG=fr_FR.ISO8859-1 ./a.out 
FALSE 
Caract�re hors des limites UTF-8
terminate called after throwing an instance of 'Glib::ConvertError'
Aborted (core dumped)
murrayc@murrayc-laptop:~/Desktop$ 

Here is the backtrace:

(gdb) bt
  • #0 __kernel_vsyscall
  • #1 raise
    from /lib/tls/i686/cmov/libc.so.6
  • #2 abort
    from /lib/tls/i686/cmov/libc.so.6
  • #3 __gnu_cxx::__verbose_terminate_handler
    from /usr/lib/libstdc++.so.6
  • #4 ??
    from /usr/lib/libstdc++.so.6
  • #5 std::terminate
    from /usr/lib/libstdc++.so.6
  • #6 __cxa_throw
    from /usr/lib/libstdc++.so.6
  • #7 Glib::ConvertError::throw_func
    at convert.cc line 430
  • #8 Glib::Error::throw_exception
    at error.cc line 180
  • #9 Glib::locale_from_utf8
    at convert.cc line 250
  • #10 main


Now I understand that it crashes because you have just not caught the exception. And it should throw an exception because you are trying to convert invalid data. Why not just use catch/try blocks as in this new test case? An exception doesn't have to mean that your application aborts.
Comment 10 Murray Cumming 2008-03-22 09:40:07 UTC
Created attachment 107786 [details]
test_with_catch.cc
Comment 11 Takao Fujiwara 2008-03-22 15:13:39 UTC
Thanks very much for your time and explanation.

I couldn't understand what the debuger meant and which errors should be caught.
I'm closing this as "Not a Bug".