gdb and valgrind generate error messages when enabling Russian locale

Question:

Hello!

For a long time I did not pay attention to messages in valgrind about errors related to localization. The main thing is that there are no leaks. But then I decided to figure it out. If you put С locale, then everything is fine. But as soon as I point out any other, Valgrind swears. gdb swears too. Simplified the example to a few lines.

Compilers GCC 4.7, clang (3.3), ALTLinux system.

Here is what gdb writes:

Missing separate debuginfo for /lib64/ld-linux-x86-64.so.2
Try to install the hash file /usr/lib/debug/.build-id/4b/17cdb72cc20e7c8b2eb2056ab9eeae5eacb0d3.debug
Missing separate debuginfo for /lib64/libc.so.6
Try to install the hash file /usr/lib/debug/.build-id/78/2b2756c3af2791386a8c4f3414b4dad6572dde.debug

Here is what valgrind writes (snippet):
== 3695 == Use of uninitialised value of size 8
== 3695 == at 0x4EB7B38: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E5DF5D: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E5E3C9: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E56D21: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4EDD807: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4EDD948: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4ED3438: wcsrtombs (in /lib64/libc-2.17.so)
== 3695 == by 0x4E7E59B: vfprintf (in /lib64/libc-2.17.so)
== 3695 == by 0x4E83FA8: printf (in /lib64/libc-2.17.so)
== 3695 == by 0x4005C9: main (test.c: 11)
== 3695 ==
== 3695 == Conditional jump or move depends on uninitialised value (s)
== 3695 == at 0x4EB6762: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E5DF5D: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E5E429: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E56D21: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4EDD807: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4EDD969: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4ED3438: wcsrtombs (in /lib64/libc-2.17.so)
== 3695 == by 0x4E7E59B: vfprintf (in /lib64/libc-2.17.so)
== 3695 == by 0x4E83FA8: printf (in /lib64/libc-2.17.so)
== 3695 == by 0x4005C9: main (test.c: 11)
== 3695 ==
== 3695 == Use of uninitialised value of size 8
== 3695 == at 0x4EB7B34: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E5DF5D: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E5E429: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E56D21: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4EDD807: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4EDD969: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4ED3438: wcsrtombs (in /lib64/libc-2.17.so)
== 3695 == by 0x4E7E59B: vfprintf (in /lib64/libc-2.17.so)
== 3695 == by 0x4E83FA8: printf (in /lib64/libc-2.17.so)
== 3695 == by 0x4005C9: main (test.c: 11)
== 3695 ==
== 3695 == Use of uninitialised value of size 8
== 3695 == at 0x4EB7B38: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E5DF5D: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E5E429: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4E56D21: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4EDD807: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4EDD969: ??? (in /lib64/libc-2.17.so)
== 3695 == by 0x4ED3438: wcsrtombs (in /lib64/libc-2.17.so)
== 3695 == by 0x4E7E59B: vfprintf (in /lib64/libc-2.17.so)
== 3695 == by 0x4E83FA8: printf (in /lib64/libc-2.17.so)
== 3695 == by 0x4005C9: main (test.c: 11)
== 3695 ==
Hello!
== 3695 ==
== 3695 == HEAP SUMMARY:
== 3695 == in use at exit: 0 bytes in 0 blocks
== 3695 == total heap usage: 197 allocs, 197 frees, 10,382 bytes allocated
== 3695 ==
== 3695 == All heap blocks were freed – no leaks are possible
== 3695 ==
== 3695 == For counts of detected and suppressed errors, rerun with: -v
== 3695 == Use –track-origins = yes to see where uninitialised values ​​come from
== 3695 == ERROR SUMMARY: 630 errors from 42 contexts (suppressed: 2 from 2)

The code:

#include <stdio.h>
#include <locale.h>
#include <wchar.h>
#include <wctype.h>

int main()
{
    //setlocale(LC_ALL, NULL);
    //setlocale(LC_ALL, "POSIX"); // ошибки исчезают, но русский текст не печатает
    setlocale(LC_ALL, "");
    wchar_t a[] = L"Hello";
    printf("%S!\n", a);
    return 0;
}

Compilation: gcc -g -Wall -Wextra -std=с11 test.c -o test .

In which direction to proceed next:

  1. Write wrappers for system functions?
  2. Install something for debugging?
  3. Switch to a newer version of the compiler and a different OS?
  4. To forget about everything and write the code further?
  5. Something else?

Honestly, I don’t want to switch from altlinux to another OS, just like abandoning gcc (although 4.7 does not fully support the c11 standard).

Answer:

Installed xubuntu. Everything works fine on gcc 6.3, plus all the features of c11!

Scroll to Top
AllEscort