Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to generate locales, but locale-gen (localedef?) segfaults.

# sudo dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = "en_US.UTF-8",
        LC_CTYPE = "UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Generating locales...
  en_US.ISO-8859-1... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/sbin/locale-gen: line 243:  3809 Segmentation fault      localedef $no_archive -i $input -c -f $charset $locale_alias $locale
  en_US.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/usr/sbin/locale-gen: line 243:  3836 Segmentation fault      localedef $no_archive -i $input -c -f $charset $locale_alias $locale
Generation complete.

In top I see localedef -i en_US -c -f ISO-8859-1 en_US taking up 8000G of virtual memory, then some huge number without even G suffix and then segfault.

System has 1G memory and 512MB SWAP, but memory is barely used (130MB at peak of generation).

System data:

root@docs:~# uname -a
Linux docs 2.6.32-042stab078.28 #1 SMP Mon Jul 8 10:17:22 MSK 2013 x86_64 x86_64 x86_64 GNU/Linux

root@docs:~# cat /etc/lsb-release

root@docs:~# dpkg-query --show glibc*

root@docs:~# sudo apt-get update && sudo apt-get upgrade
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
share|improve this question

It looks like you have these lines in your /etc/default/locale file:


The LC_CTYPE setting is wrong, since "UTF-8" is not a valid locale name. Also, it makes no sense to set all those variables; I would recommend that you simply remove the LC_ALL and LC_CTYPE lines.

(I saw something similar recently. It would be interesting to know how that LC_CTYPE=UTF-8 statement ended up there in the first place.)

share|improve this answer
Actually I have only those: LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 – Slava N Mar 5 '14 at 16:29
Setting LC_CTYPE=en_US.UTF-8 and then sudo locale-gen en_US.UTF-8, then sudo dpkg-reconfigure locales helped! Thanks! – Slava N Mar 5 '14 at 16:34
Oops, was running commands on wrong machine. Setting LC_CTYPE explicitly didn't help, still segfault :( – Slava N Mar 5 '14 at 16:38
Don't bother with locale-gen and dpkg-reconfigure. Your problem is that LC_CTYPE is incorrectly set somewhere, apparently somewhere else but /etc/default/locale. Maybe some of your config files in $HOME contains the incorrect statement, such as ~/.bashrc or ~/.profile. – Gunnar Hjalmarsson Mar 5 '14 at 20:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.