bugGNU gettext - Bugs: bug #44645, libintl_setlocale() still caches...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #44645: libintl_setlocale() still caches settings under Mac OS X

Submitted by:  Guido Flohr <gflohr>
Submitted on:  Fri 27 Mar 2015 10:14:44 AM UTC  
 
Category:  End-user / runtime Severity:  3 - Normal
Item Group:  None Status:  Not a Bug
Privacy:  Public Assigned to:  Bruno Haible <haible>
Open/Closed:  Closed

( Jump to the original submission)

Sun 16 Sep 2018 07:31:22 PM UTC, comment #10: 

Okay, agreed.

Guido Flohr <gflohr>
Project Member
Sun 16 Sep 2018 05:36:38 PM UTC, comment #9: 

We will not implement that gettext() notices changes of the locale, without an override of setlocale via libintl_setlocale.

The reason is simply performance: going through setlocale(LC_MESSAGES,NULL) for every gettext() call would be prohibitively expensive.

We shall document the requirement to use this override from <libintl.h> in bug #38162.

Bruno Haible <haible>
Project AdministratorIn charge of this item.
Tue 31 Mar 2015 07:24:48 AM UTC, comment #8: 

Yes, that's what I meant.  Wait for the call to libintl_setlocale() in order to be sure that it is reachable from the application code.

It would help in the vast majority of cases but not when different languages are mixed.  Still I think it would be a good idea because using the C preprocessor for function call wrappers imho isn't a robust solution.

Guido Flohr <gflohr>
Project Member
Tue 31 Mar 2015 12:56:56 AM UTC, comment #7: 

> You could enable the caching from inside libintl_setlocale(). That still wouldn't be perfect but catches at least the simple cases.


I might not get what you mean correctly, but are you suggesting that we could disable the current caching mechanism until libintl_setlocale() is called?  That sounds like an interesting idea, though:

> Probably I have to provide a wrapper around setlocale() in the Perl binding that calls libintl_setlocale() if it is present.


yes, I suppose this is the preferred way.

Daiki Ueno <ueno>
Project Administrator
Mon 30 Mar 2015 07:56:09 AM UTC, comment #6: 

You could enable the caching from inside libintl_setlocale().  That still wouldn't be perfect but catches at least the simple cases.

Probably I have to provide a wrapper around setlocale() in the Perl binding that calls libintl_setlocale() if it is present.

Guido Flohr <gflohr>
Project Member
Mon 30 Mar 2015 07:42:17 AM UTC, comment #5: 

I see your use-case and the current fix[1] is not suitable for it.  However, I can't think of any other practical solution.  Any suggestions?  One idea is to invalidate the cache in dcigettext.c, though it might suffer performance and maintainability as I wrote in the ML post.

[1]  https://lists.gnu.org/archive/html/bug-gettext/2013-03/msg00045.html

Daiki Ueno <ueno>
Project Administrator
Mon 30 Mar 2015 07:22:14 AM UTC, comment #4: 

Yes, see my original bug report where I mentioned that I undefined setlocale().

I did this because the original problem is a test failure in the Perl binding libintl-perl.  That Perl binding does not define setlocale(), it uses the system setlocale(3) instead.

From what I understand, other language bindings must suffer from the same problem, unless they somehow overload setlocale().

Guido Flohr <gflohr>
Project Member
Mon 30 Mar 2015 06:48:06 AM UTC, comment #3: 

Well, the behavior is not surprising because you added #undef setlocale to the new test case.  If I comment out the line to use libintl_setlocale(), it produces the expected result.

Daiki Ueno <ueno>
Project Administrator
Mon 30 Mar 2015 06:29:39 AM UTC, comment #2: 

I can reproduce it both with a vanilla gettext-0.19.4 and the one installed with Mac Ports:

guido@macbook:/tmp/gettext-0.19.4 $ gettext-runtime/libtool --mode=link gcc -o setlocale-cache-bug -I gettext-runtime/intl setlocale-cache-bug.c gettext-runtime/intl/libintl.la
libtool: link: gcc -o .libs/setlocale-cache-bug -I gettext-runtime/intl setlocale-cache-bug.c  gettext-runtime/intl/.libs/libintl.dylib -liconv -lc
guido@macbook:/tmp/gettext-0.19.4 $ ./setlocale-cache-bug
ja_JP.UTF-8
German: 未知のシステムエラー
C/en_US.UTF-8/C/C/C/C
POSIX/C: 未知のシステムエラー
guido@macbook:/tmp/gettext-0.19.4 $ cd /tmp/bug-44645
guido@macbook:/tmp/bug-44645 $ make
cc -I /opt/local/include   -c -o setlocale-cache-bug.o setlocale-cache-bug.c
cc -L /opt/local/lib -lintl -o setlocale-cache-bug setlocale-cache-bug.o
guido@macbook:/tmp/bug-44645 $ ./setlocale-cache-bug
ja_JP.UTF-8
German: 未知のシステムエラー
C/en_US.UTF-8/C/C/C/C
POSIX/C: 未知のシステムエラー
guido@macbook:/tmp/bug-44645 $ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=
guido@macbook:/tmp/bug-44645 $ port installed | grep gettext
Warning: port definitions are more than two weeks old, consider updating them by running 'port selfupdate'.
  gettext @0.19.3_1
  gettext @0.19.4_0 (active)

I have attached the exact setlocale-cache-bug.c that I used on my mac here.

The only sigifnicant difference I see to your setup is the return value of setlocale().  And I am using Mac OS X 10.10.2.

(file #33488)

Guido Flohr <gflohr>
Project Member
Mon 30 Mar 2015 03:57:29 AM UTC, comment #1: 

I can't reproduce it (on OS X 10.8, though the version number is unlikely to be related).  Is it really the same problem?

$ wget ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.4.tar.xz
$ tar xf gettext-0.19.4.tar.xz
$ cd gettext-0.19.4 && ./configure && make
$ libtool --mode=link gcc -o setlocale-cache-bug -I gettext-runtime/intl setlocale-cache-bug.c gettext-runtime/intl/libintl.la
libtool: link: gcc -o .libs/setlocale-cache-bug -I gettext-runtime/intl setlocale-cache-bug.c  gettext-runtime/intl/.libs/libintl.dylib -L/Users/ueno/.local/lib /Users/ueno/.local/lib/libiconv.dylib -lc
$ /setlocale-cache-bug de_DE.UTF-8
German: Unbekannter Systemfehler
ja_JP/ja_JP/ja_JP/ja_JP/ja_JP/C
POSIX/C: Unknown system error

Daiki Ueno <ueno>
Project Administrator
Fri 27 Mar 2015 10:14:44 AM UTC, original submission:  

Tried on Mac OS X Yosemite with gettext-runtime 0.19.4 from Mac Ports.

I still have the same problem as decribed in bug #38162.

Guido Flohr <gflohr>
Project Member

 

Attached Files
file #33488:  bug-44645.tar.gz added by gflohr (711B - application/x-gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Updated the item)
  • -email is unavailable- added by ueno (Posted a comment)
  • -email is unavailable- added by gflohr (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-16 haible StatusNone => Not a Bug
        Assigned toNone => haible
        Open/ClosedOpen => Closed
    2016-11-27 haible CategoryNone => End-user / runtime
    2015-03-30 gflohr Attached File- => Added bug-44645.tar.gz, #33488

    Back to the top


    Powered by Savane 3.6