[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#187319: locales: strxfrm of "aa" under bokmal gives valgrind errors



Package: locales
Version: 2.3.1-16
Severity: normal


When calling strxfrm on "aa" under the bokmal locale, it seems that there is
some sort of uninitialized read occurring in glibc. (I was trying to debug
something else in perl, and found I had a valgrind warning). I can get it
down to this test program, which I believe is strictly ANSI conformant:

#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (int argc, char **argv) {
    char *result;
    char buffer[256];

    argv++;
    if (!*argv)
        return 1;

    result = setlocale (LC_ALL, *argv);
    if (!result) {
        fprintf (stderr, "Could not set locale to '%s'\n", *argv);
        exit (1);
    }

    while (*++argv) {
        printf ("result for '%s' is %d\n", *argv,
                strxfrm (buffer, *argv, sizeof(buffer) - 1));
    }
    return 0;
}


when run this this under valgrind I see errors:

$ valgrind ./test_strxfrm bokmal aa
==6124== valgrind-1.0.4, a memory error detector for x86 GNU/Linux.
==6124== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward.
==6124== Estimated CPU clock rate is 1544 MHz
==6124== For more details, rerun with: -v
==6124==
==6124== Use of uninitialised value of size 4
==6124==    at 0x402A3477: strxfrm (in /lib/libc-2.3.1.so)
==6124==    by 0x80484B6: main (in /home/nick/test/test_strxfrm)
==6124==    by 0x4024AA51: __libc_start_main (in /lib/libc-2.3.1.so)
==6124==    by 0x804838D: (within /home/nick/test/test_strxfrm)
==6124==
==6124== Use of uninitialised value of size 4
==6124==    at 0x402A36E0: strxfrm (in /lib/libc-2.3.1.so)
==6124==    by 0x80484B6: main (in /home/nick/test/test_strxfrm)
==6124==    by 0x4024AA51: __libc_start_main (in /lib/libc-2.3.1.so)
==6124==    by 0x804838D: (within /home/nick/test/test_strxfrm)
result for 'aa' is 5
==6124==
==6124== ERROR SUMMARY: 4 errors from 2 contexts (suppressed: 0 from 0)
==6124== malloc/free: in use at exit: 0 bytes in 0 blocks.
==6124== malloc/free: 28 allocs, 28 frees, 1886 bytes allocated.
==6124== For a detailed leak analysis,  rerun with: --leak-check=yes
==6124== For counts of detected errors, rerun with: -v

I'm trusting that valgrind is correct, and that these warnings indicate
a real bug. In my experience valgrind always has been accurate in what it
reports.

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux penfold 2.4.20 #1 Tue Apr 1 00:07:30 BST 2003 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages locales depends on:
ii  debconf                       1.2.34     Debian configuration management sy
ii  libc6 [glibc-2.3.1-16]        2.3.1-16   GNU C Library: Shared libraries an

-- debconf information:
* locales/default_environment_locale: C
* locales/locales_to_be_generated: fa_IR.UTF-8 UTF-8, nl_NL ISO-8859-1, nl_NL.UTF-8 UTF-8, nl_NL.UTF-8@euro UTF-8, nl_NL@euro ISO-8859-15, no_NO ISO-8859-1, no_NO.UTF-8 UTF-8




Reply to: