From: "Torsten Bögershausen" <tboegi@web.de>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>, git@vger.kernel.org
Cc: Jonathan Niedier <jrnieder@gmail.com>,
vnwildman@gmail.com, schwab@linux-m68k.org
Subject: Re: [PATCH v2] gettext.c: only work around the vsnprintf bug on glibc < 2.17
Date: Sun, 01 Dec 2013 00:01:28 +0100 [thread overview]
Message-ID: <529A6E48.4050001@web.de> (raw)
In-Reply-To: <1385812884-23776-1-git-send-email-pclouds@gmail.com>
On 2013-11-30 13.01, Nguyễn Thái Ngọc Duy wrote:
> Bug 6530 [1] causes "git show v0.99.6~1" to fail with error "your
causes or caused (as we have a work around?)
> vsnprintf is broken". The workaround avoids that, but it corrupts
> system error messages in non-C locales.
[snip]
> The bug in glibc has been fixed since 2.17. If git is built with glibc, it can
^^^^^^ (Should we name glibc ?)
[snip]
> - setlocale(LC_MESSAGES, "");
> - init_gettext_charset("git");
> + setlocale(vsnprintf_broken ? LC_MESSAGES : LC_ALL, "");
1) One thing I don't understand: Why do we need to set LC_ALL ?
The old patch didn't do it, or what do I miss ?
See https://wiki.debian.org/Locale :
Using LC_ALL is strongly discouraged as it overrides everything. Please use it only when testing and never set it in a startup file.
2) I stole the code partly from here:
http://sourceware.org/bugzilla/show_bug.cgi?id=6530
----------------------
#include <stdio.h>
#include <locale.h>
#include <gnu/libc-version.h>
#define STR "²éľÂíɱ²¡¶¾£¬ÖܺèµtÄúµÄ360²»×¨Òµ£¡"
int main(void) {
char buf[200];
setlocale(LC_ALL, "");
printf("gnu_glibc_version()=%s\n", gnu_get_libc_version());
printf("ret(snprintf)=%d\n", snprintf(buf, 150, "%.50s", STR));
return 0;
}
----------------------
Then I run it on different machines:
gnu_glibc_version()=2.11.3 /* Ubuntu 10.4, no updates */
gnu_glibc_version()=2.11.3 /* Debian Squeze ?*/
gnu_glibc_version()=2.13 /* Debian Wheezy */
ret(snprintf)=50 /* All the 3 above */
-------------
So could it be that libc is patched in Debian/Ubuntu, and we
can do a runtime check (rather than looking at the version number),
similar to the code above ?
------------
3) The patch didn't break anything here (Debian, Mac OS).
4) Could it be good to have a test case ? Is t0204 good for inspiration ?
5) I can do more testing if needed.
/Torsten
next prev parent reply other threads:[~2013-11-30 23:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-30 1:51 [PATCH] gettext.c: only work around the vsnprintf bug on glibc < 2.17 Nguyễn Thái Ngọc Duy
2013-11-30 9:51 ` Andreas Schwab
2013-11-30 12:01 ` [PATCH v2] " Nguyễn Thái Ngọc Duy
2013-11-30 23:01 ` Torsten Bögershausen [this message]
2013-11-30 23:06 ` Torsten Bögershausen
2013-12-01 1:33 ` Duy Nguyen
2013-12-01 2:45 ` [PATCH v3] gettext.c: detect the vsnprintf bug at runtime Nguyễn Thái Ngọc Duy
2013-12-02 0:31 ` Trần Ngọc Quân
2013-12-02 5:57 ` Duy Nguyen
2013-12-02 7:40 ` Trần Ngọc Quân
2013-12-02 8:49 ` Trần Ngọc Quân
2013-12-02 9:00 ` Duy Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=529A6E48.4050001@web.de \
--to=tboegi@web.de \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=pclouds@gmail.com \
--cc=schwab@linux-m68k.org \
--cc=vnwildman@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).