junest icon indicating copy to clipboard operation
junest copied to clipboard

locale-gen segfault

Open 0atman opened this issue 8 years ago • 21 comments

On a fresh install of ubuntu 16.04, and a fresh install of junest, I seem to be in locale hell:

root# chromium

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_GB:en",
	LC_ALL = (unset),
	LANG = "en_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
[6911:6911:1103/165119:FATAL:namespace_sandbox.cc(141)] Check failed: clone_flags & CLONE_NEWUSER. 
Aborted (core dumped)

root# locale-gen

Generating locales...
  en_GB.UTF-8.../usr/bin/locale-gen: line 41:  6928 Segmentation fault      (core dumped) localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias $locale

Help!

0atman avatar Nov 03 '16 16:11 0atman

I've given up on using chrome due to the suid root problem, however, the locale problem affects all apps.

0atman avatar Nov 04 '16 10:11 0atman

@fsquillace any idea where I should start with this?

0atman avatar Nov 20 '16 18:11 0atman

Hey @0atman

It seems to be related to the recent update in glibc (2.24).

If I attempt to use chroot (which is used for building the JuNest image) I get another issue:

[feel@arch junest-git]$ sudo chroot ~/.junest locale-gen
character map file `UTF-8' not found: No such file or directory
default character map file `ANSI_X3.4-1968' not found: No such file or directory

It may be possible that there is a missing file in junest. Using strace command on locale-gen and localedef did not help so far. I need to investigate more but it seems a hard problem.

fsquillace avatar Dec 13 '16 09:12 fsquillace

[root@myarch junest]# pacman -Qo locale-gen
/usr/bin/locale-gen is owned by glibc 2.23-4
[root@myarch junest]# locale-gen
Generating locales...
  en_US.UTF-8... done
Generation complete.
[root@myarch junest]# pacman -Sy glibc
:: Synchronizing package databases...
 core                                                           122.6 KiB   238K/s 00:01 [###################################################] 100%
 extra                                                         1747.9 KiB  2042K/s 00:01 [###################################################] 100%
 community                                                        3.7 MiB  2.25M/s 00:02 [###################################################] 100%
resolving dependencies...
looking for conflicting packages...

Packages (2) linux-api-headers-4.7-1  glibc-2.24-2

Total Download Size:    8.92 MiB
Total Installed Size:  39.39 MiB
Net Upgrade Size:       0.22 MiB

:: Proceed with installation? [Y/n]
:: Retrieving packages...
 linux-api-headers-4.7-1-x86_64                                 810.7 KiB   830K/s 00:01 [###################################################] 100%
 glibc-2.24-2-x86_64                                              8.1 MiB  2.11M/s 00:04 [###################################################] 100%
(2/2) checking keys in keyring                                                           [###################################################] 100%
(2/2) checking package integrity                                                         [###################################################] 100%
(2/2) loading package files                                                              [###################################################] 100%
(2/2) checking for file conflicts                                                        [###################################################] 100%
(2/2) checking available disk space                                                      [###################################################] 100%
:: Processing package changes...
(1/2) upgrading linux-api-headers                                                        [###################################################] 100%
(2/2) upgrading glibc                                                                    [###################################################] 100%
warning: /etc/locale.gen installed as /etc/locale.gen.pacnew
Generating locales...
  en_US.UTF-8...
gzip: stdout: Broken pipe
/usr/bin/locale-gen: line 41:  5974 Segmentation fault      (core dumped) localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias $loc
ale
:: Running post-transaction hooks...
(1/1) Updating the info directory file...

fsquillace avatar Dec 13 '16 23:12 fsquillace

I noticed that you should be able to fix it by running junest with --root:

[22:07:34 139 feel@myarch {dev} junest $]> JUNEST_HOME=~/.junest-origin sudo junest -r locale-gen
feel@myarch --> root@myarch - Password for feel:
Generating locales...
  en_US.UTF-8... done
Generation complete.

Although is not the definitive solution it might be a mitigation for your problem.

fsquillace avatar Dec 13 '16 23:12 fsquillace

Yet another enormous mystery is that running proot via gdb the locale-gen command works fine.

Via GDB:

PROOT_NO_SECCOMP=1 gdb --args ~/.junest/opt/proot/proot-x86_64 -S ~/.junest/ /usr/bin/locale-gen
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/feel/.junest/opt/proot/proot-x86_64...(no debugging symbols found)...done.
(gdb) r
Starting program: /home/feel/.junest/opt/proot/proot-x86_64 -S /home/feel/.junest/ /usr/bin/locale-gen

Generating locales...
  en_US.UTF-8... done
Generation complete.

Without GDB:

PROOT_NO_SECCOMP=1 ~/.junest/opt/proot/proot-x86_64 -S ~/.junest/ /usr/bin/locale-gen
Generating locales...
  en_US.UTF-8.../usr/bin/locale-gen: line 41: 16961 Segmentation fault      (core dumped) localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias $locale

fsquillace avatar Dec 29 '16 14:12 fsquillace

I am also affected by this bug. Therefore i cannot use any GUI applications, because the text is unreadable. If i can help to debug this, let me know. I also cannot use your workaround, since i am not root on the machine.

gzahl avatar Jan 13 '17 09:01 gzahl

It seems that the issue is inside proot program. Unfortunately, this program is no longer supported, so I need time to investigate in the proot code in order to troubleshoot such issue.

The only thing I got so far is that the segfault happen when calling a function in libc (sysmalloc). Maybe proot is not able to deal with certain syscall but I am not sure at all. The code dump is the following:

>> coredumpctl info 5126
           PID: 5126 (localedef)
           UID: 1000 (feel)
           GID: 100 (users)
        Signal: 11 (SEGV)
     Timestamp: Mon 2017-01-23 01:00:47 GMT (22h ago)
  Command Line: localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
    Executable: /tmp/prooted-4980-Jr8Ap0
 Control Group: /user.slice/user-1000.slice/session-c1.scope
          Unit: session-c1.scope
         Slice: user-1000.slice
       Session: c1
     Owner UID: 1000 (feel)
       Boot ID: b523b7201bca4eaeb144b2ea4322a7ed
    Machine ID: 70f7e403d8ed41dbbcfe37166c625701
      Hostname: myarch
       Storage: /var/lib/systemd/coredump/core.localedef.1000.b523b7201bca4eaeb144b2ea4322a7ed.5126.1485133247000000000000.lz4
       Message: Process 5126 (localedef) of user 1000 dumped core.

                Stack trace of thread 5126:
                #0  0x00007f1f925ee87c sysmalloc (/home/feel/.junest-new/usr/lib/libc-2.24.so)
                #1  0x00007f1f925ef30d _int_malloc (/home/feel/.junest-new/usr/lib/libc-2.24.so)
                #2  0x00007f1f925f0c74 __GI___libc_malloc (/home/feel/.junest-new/usr/lib/libc-2.24.so)
                #3  0x0000000000437519 xmalloc (/home/feel/.junest-new/usr/bin/localedef)
                #4  0x000000000042d9be get_symname (/home/feel/.junest-new/usr/bin/localedef)
                #5  0x0000000000429825 parse_charmap (/home/feel/.junest-new/usr/bin/localedef)
                #6  0x000000000042bb1a charmap_read (/home/feel/.junest-new/usr/bin/localedef)
                #7  0x0000000000403350 main (/home/feel/.junest-new/usr/bin/localedef)
                #8  0x00007f1f92596291 __libc_start_main (/home/feel/.junest-new/usr/lib/libc-2.24.so)
                #9  0x00000000004038ca _start (/home/feel/.junest-new/usr/bin/localedef)

To make things more complicated when running proot via gdb, the locale-gen/localedef works just fine. It seems there is a failure when requiring more memory from the system. This, for some reason, is longer true once proot runs inside gdb.

fsquillace avatar Jan 24 '17 00:01 fsquillace

in sysmalloc libc calls mmap syscall it might be there where proot fails.

fsquillace avatar Jan 24 '17 00:01 fsquillace

related to: https://github.com/proot-me/PRoot/issues/106

fsquillace avatar Jan 30 '17 22:01 fsquillace

As a temporary workaround you can invoke host's localedef to compile locale definition files:

I18NPATH=$HOME/.junest/usr/share/i18n localedef -i en_US -c -f UTF-8 -A $HOME/.junest/usr/share/locale/locale.alias --prefix=$HOME/.junest en_US.UTF-8

This should at least allow programs that requires them (e.g. tmux) to work.

PkmX avatar Apr 05 '17 02:04 PkmX

Thanks @PkmX; that seems really to be a good workaround as it generate the locale-archive file.

>> ll ${JUNEST_HOME}/usr/lib/locale/locale-archive 
ls: cannot access '/home/feel/.junest/usr/lib/locale/locale-archive': No such file or directory
>> I18NPATH=${JUNEST_HOME}/usr/share/i18n ${JUNEST_HOME}/usr/bin/localedef -i en_US -c -f UTF-8 -A ${JUNEST_HOME}/usr/share/locale/locale.alias --prefix=${JUNEST_HOME} en_US.UTF-8
>> ll ${JUNEST_HOME}/usr/lib/locale/locale-archive 
-rw-r--r-- 1 feel users 1.6M Apr  6 20:39 /home/feel/.junest/usr/lib/locale/locale-archive

fsquillace avatar Apr 06 '17 19:04 fsquillace

Good! this help me much ! and the error message when run "locale" from locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_.... to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory to only locale: Cannot set LC_ALL to default locale: No such file or directory And the display of characters become normal....

yinflying avatar Apr 07 '17 03:04 yinflying

PkmX's workaround just segfaults for me as soon as I run it

oxinabox avatar May 06 '17 04:05 oxinabox

The workaround did work for me. @oxinabox did you run it from your host system and modified the paths, if the junest env is not installed to ~/.junest?

gzahl avatar May 30 '17 10:05 gzahl

Problem is back/still present, but PkmX workaround is working. Any news?

arkanoid87 avatar May 08 '18 03:05 arkanoid87

Unfortunately the work around doesn't work for me. I'm using CentOS 7.5 as host.

$ I18NPATH=$HOME/.junest/usr/share/i18n localedef -i en_US -c -f UTF-8 -A $HOME/.junest/usr/share/locale/locale.alias --prefix=$HOME/.junest en_US.UTF-8

$ junest -f

[...]# locale locale: Cannot set LC_ALL to default locale: No such file or directory LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=

[...]# locale -a C en_US.utf8 POSIX

[...]# emacs

(process:31973): Gtk-WARNING **: 15:16:04.693: Locale not supported by C library. Using the fallback 'C' locale.

fabio-porcedda avatar Dec 28 '18 15:12 fabio-porcedda

I've faced the same issue trying just to use proot with Arch Linux on x86_64, so I'm not actually using JuNest.

I run strace localedef and found out that it tries to read the file /usr/share/i18n/charmaps/UTF-8 first, than if it's not preset, it continues with /usr/share/i18n/charmaps/UTF-8.gz which comes with glibc, that it fails reading it. So I just ungzipped it and localedef started working without segfaults for me: gunzip -k /usr/share/i18n/charmaps/UTF-8.gz :)

sgtpep avatar Jan 13 '19 12:01 sgtpep

Thanks a lot @sgtpep !!! Same with me, I'm not using junest, but ubuntu proot. The solutions is just run gunzip -k /usr/share/i18n/charmaps/UTF-8.gz

stardigits avatar Apr 03 '19 10:04 stardigits

I also reported this problem. The gunzip approach did not work for me, but @PkmX 's work-around did.

DiagonalArg avatar Jul 13 '19 03:07 DiagonalArg

I believe I ran into a related/similar issue. In my case, the underlying problem was that locale-gen was trying to run gzip to extract UTF-8.gz, but gzip wasn't initially installed. I saw no no SIGSEGV either way, but installing gzip solved the error messages I was getting (the same ones as in https://github.com/fsquillace/junest/issues/161#issuecomment-266692846).

jebrosen avatar Jun 26 '20 18:06 jebrosen