public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/4416] New: setlocales can fail silentely
@ 2007-04-23 21:59 madcoder at debian dot org
2007-04-24 10:14 ` [Bug libc/4416] " madcoder at debian dot org
0 siblings, 1 reply; 2+ messages in thread
From: madcoder at debian dot org @ 2007-04-23 21:59 UTC (permalink / raw)
To: glibc-bugs
When Virtual Memory is low, the mmap of /usr/lib/locale/locale-archive can fail
(in loadarchive.c, function _nl_load_locale_from_archive).
Then, _nl_find_locale (findlocale.c) tries to recover from that, trying to
guess pathes or sth like that on its own. But it still fails because it can't
find LC_IDENTIFICATION files and setlocale returns something completely broken.
You can emulate that by renaming /usr/lib/locale/locale-archive. A sample
problematic program is:
================================================
#include <stdio.h>
#include <locale.h>
int main(void)
{
const char *s;
s = setlocale(LC_ALL, "en_US.utf-8");
printf("%s\n", s);
return 0;
}
================================================
strace gives:
================================================
brk(0) = 0x601000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x2ac0f56dd000
uname({sys="Linux", node="artemis", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x2ac0f56de000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=57422, ...}) = 0
mmap(NULL, 57422, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2ac0f56e0000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\324\1"..., 832) =
832
fstat(3, {st_mode=S_IFREG|0755, st_size=1359200, ...}) = 0
mmap(NULL, 2416808, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) =
0x2ac0f57de000
mprotect(0x2ac0f5924000, 1044480, PROT_NONE) = 0
mmap(0x2ac0f5a23000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
MAP_DENYWRITE, 3, 0x145000) = 0x2ac0f5a23000
mmap(0x2ac0f5a28000, 16552, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
MAP_ANONYMOUS, -1, 0) = 0x2ac0f5a28000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x2ac0f5a2d000
arch_prctl(ARCH_SET_FS, 0x2ac0f5a2d6f0) = 0
mprotect(0x2ac0f5a23000, 12288, PROT_READ) = 0
munmap(0x2ac0f56e0000, 57422) = 0
brk(0) = 0x601000
brk(0x622000) = 0x622000
open("/usr/lib/locale/locale-archive", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/usr/share/locale/locale.alias", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/usr/lib/locale/en_US.utf-8/LC_IDENTIFICATION", O_RDONLY) = -1 ENOENT (No
such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_IDENTIFICATION", O_RDONLY) = -1 ENOENT (No
such file or directory)
open("/usr/lib/locale/en_US/LC_IDENTIFICATION", O_RDONLY) = -1 ENOENT (No such
file or directory)
open("/usr/lib/locale/en.utf-8/LC_IDENTIFICATION", O_RDONLY) = -1 ENOENT (No
such file or directory)
open("/usr/lib/locale/en.utf8/LC_IDENTIFICATION", O_RDONLY) = -1 ENOENT (No
such file or directory)
open("/usr/lib/locale/en/LC_IDENTIFICATION", O_RDONLY) = -1 ENOENT (No such
file or directory)
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
====================================================
I don't expect setlocale especially to success even with low memory, but at
least it should fail (return NULL) to express the fact that it only loaded C
locale.
--
Summary: setlocales can fail silentely
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: madcoder at debian dot org
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=4416
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug libc/4416] setlocales can fail silentely
2007-04-23 21:59 [Bug libc/4416] New: setlocales can fail silentely madcoder at debian dot org
@ 2007-04-24 10:14 ` madcoder at debian dot org
0 siblings, 0 replies; 2+ messages in thread
From: madcoder at debian dot org @ 2007-04-24 10:14 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From madcoder at debian dot org 2007-04-24 11:14 -------
ahem, I was testing on a 2.3 libc rather than the 2.5 sorry, it seems to work
fine now.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://sourceware.org/bugzilla/show_bug.cgi?id=4416
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-04-24 10:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-23 21:59 [Bug libc/4416] New: setlocales can fail silentely madcoder at debian dot org
2007-04-24 10:14 ` [Bug libc/4416] " madcoder at debian dot org
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 read-only IMAP folder(s) and NNTP newsgroup(s).