This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/15940] New: strerror() returns useless string "???" in a typical use of PostgreSQL


http://sourceware.org/bugzilla/show_bug.cgi?id=15940

            Bug ID: 15940
           Summary: strerror() returns useless string "???" in a typical
                    use of PostgreSQL
           Product: glibc
           Version: 2.12
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: tsunakawa.takay at jp dot fujitsu.com
                CC: drepper.fsp at gmail dot com

Hello,

When LC_CTYPE=C and LC_MESSAGES=ja_JP.UTF-8, strerror() returns "???" (the
number of questionmarks depends on the original message).  This locale
combination is used in a typical Japanese environment with PostgreSQL, and
"???" makes troubleshooting very difficult.  This should happen with all
non-English LC_MESSAGES.

Please see the bug report of PostgreSQL below.  One of the core members of
PostgreSQL community thinks that this is a glibc's bug, and I think so, too.

http://www.postgresql.org/message-id/2782A2665E8342DF8695F396DBA80C88@maumau

I know strerror() calls gettext(), and gettext() returns "???" when it cannot
convert messages to the codeset specified by bind_textdomain_codeset() or
LC_CTYPE.  However, "???" is totally useless.  strerror() should return the
English message or some useful message like "errno=EIO" to enable
troubleshooting.

The following is a sample program to reproduce the problem.  Use like this:

$ gcc strerror.c
$ export LC_CTYPE=C
$ export LC_MESSAGES=ja_JP.UTF-8 (or any non-English locale)
$ ./a.out

For information, On Solaris 10, this outputs a Japanese message with Solaris's
strerror() (not glibc's one).

Or, is there any safe way to change the codeset for strerror()?  Using
bind_textdomain_codeset("libc") was rejected because it is an undocumented
behavior of glibc and its effect is unknown.  Calling setlocale(LC_CTYPE, )
every time strerror() is called doesn't seem good, because I'm afraid
setlocale() is heavy.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <locale.h>
#include <libintl.h>
#include <langinfo.h>

int
main(int argc, char *argv[])
{
 setlocale(LC_CTYPE, "");
 setlocale(LC_COLLATE, "");
    setlocale(LC_MESSAGES, "");

    /*    bind_textdomain_codeset("libc", "UTF-8");*/
    printf("%s\n", strerror(ENOENT));

    return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]