Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locale-gen segfault #161

Open
0atman opened this issue Nov 3, 2016 · 21 comments
Open

locale-gen segfault #161

0atman opened this issue Nov 3, 2016 · 21 comments

Comments

@0atman
Copy link

0atman commented Nov 3, 2016

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
Copy link
Author

0atman commented Nov 4, 2016

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

@0atman
Copy link
Author

0atman commented Nov 20, 2016

@fsquillace any idea where I should start with this?

@fsquillace
Copy link
Owner

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
Copy link
Owner

[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
Copy link
Owner

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
Copy link
Owner

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

@gzahl
Copy link

gzahl commented Jan 13, 2017

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.

@fsquillace
Copy link
Owner

fsquillace commented Jan 24, 2017

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
Copy link
Owner

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

@fsquillace
Copy link
Owner

related to: proot-me/proot#106

@PkmX
Copy link

PkmX commented Apr 5, 2017

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.

@fsquillace
Copy link
Owner

fsquillace commented Apr 6, 2017

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

@yinflying
Copy link

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....

@oxinabox
Copy link

oxinabox commented May 6, 2017

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

@gzahl
Copy link

gzahl commented May 30, 2017

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?

@arkanoid87
Copy link

arkanoid87 commented May 8, 2018

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

@fabio-porcedda
Copy link

fabio-porcedda commented Dec 28, 2018

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.

@sgtpep
Copy link

sgtpep commented Jan 13, 2019

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 :)

@stardigits
Copy link

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

@DiagonalArg
Copy link

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

@jebrosen
Copy link

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 #161 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests