WSL icon indicating copy to clipboard operation
WSL copied to clipboard

localedef: ../sysdeps/unix/sysv/linux/spawni.c:360: __spawnix: Assertion `ec >= 0' failed.

Open JackieKu opened this issue 9 years ago • 59 comments

  • A brief description When running locale-gen it always failed with the following assertion failure:

localedef: ../sysdeps/unix/sysv/linux/spawni.c:360: __spawnix: Assertion `ec >= 0' failed.

This is because by default charmaps (/usr/share/i18n/charmaps) are gzipped and localedef invokes posix_spawn in order to decompress those files.

  • Expected results No errors when running locale-gen with gzipped charmap files.

  • Actual results (with terminal output if applicable) localedef: ../sysdeps/unix/sysv/linux/spawni.c:360: __spawnix: Assertion ec >= 0' failed.`

  • Your Windows build number 15063

  • Steps / All commands required to reproduce the error from a brand new installation

  1. Edit the locale list at /etc/locale.gen.
  2. Run `locale-gen' as root.
  • Strace of the failing command None. This bug is easy to be reproduced and the line numbers are available.

  • Required packages and commands to install glibc 2.25

JackieKu avatar Apr 11 '17 09:04 JackieKu

It's only "easy to reproduce" if you are on 16.10. I went back to Xenial unfortunately, but wasn't hitting it at the time I looked in early March (see #1660 - message). Link a gist of sudo strace -ff locale-gen and someone can take a look.

therealkenc avatar Apr 11 '17 10:04 therealkenc

The same error shows up when attempting to run Fish Shell on an alternative OS. Perhaps it's related somehow?

https://github.com/alwsl/alwsl/issues/37

ghost avatar Apr 13 '17 19:04 ghost

Almost certainly the same problem. Arch uses newer glibc etc. See for example #1578. Still no strace....

therealkenc avatar Apr 13 '17 19:04 therealkenc

While this is not for locale-gen... I got a very similar error for Ninja (and m4 while trying to compile a working strace), I am currently working on getting a friend to compile me a hopefully working version of strace on a real Linux system. (I'm using ALWSL, where strace is broken in a different way... bleeding edge is exciting!)

skyem123 avatar Apr 13 '17 19:04 skyem123

Hopefully this helps... https://github.com/Microsoft/BashOnWindows/issues/1306#issuecomment-294010706

skyem123 avatar Apr 13 '17 20:04 skyem123

For those who land here and don't know a lot about linux, unpacking the relevant file (e.g. gunzip --keep /usr/share/i18n/charmaps/UTF-8.gz) avoids the problem and locale-gen runs.

Christoph-Wagner avatar Apr 14 '17 18:04 Christoph-Wagner

Okay let's do this one. The crux is the following from man clone(2):

       CLONE_VFORK (since Linux 2.2)
              If CLONE_VFORK is set, the execution of the calling process is
              suspended until the child releases its virtual memory
              resources via a call to execve(2) or _exit(2) (as with
              vfork(2)).

On WSL the caller isn't being suspended. Actual fail in glibc is here, which got introduced Sept 28th with this commit. Test case below, which is a variation on #1005. It can be run on Xenial. Get the 'Oops' path on WSL but not Real Linux. No strace because the syscalls all succeed; unlike #1005 it is behavioral.

/* clone-test.c */
#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
#include <signal.h>

#define STACK_SIZE 16364

struct posix_spawn_args
{
  char *hello;
  int err;
};

static int spawni_child(void *arguments) 
{
  struct posix_spawn_args *args = arguments;

  printf("child arg: %s -- sleeping\n", args->hello);
  sleep(1);
  args->err = 0;
  _exit(0);
  return 0;
}

int main(int argc, char *argv[]) 
{
  struct posix_spawn_args args;
  void** child_stack;
  pid_t new_pid;
  int ec;

  args.hello = "hello";
  args.err = -1;
  
  child_stack = (void **)malloc(STACK_SIZE);
  
  // clone is supposed to suspend calling thread 
  // until the child calls execve or _exit
  new_pid = clone(spawni_child, 
      child_stack + STACK_SIZE, 
      CLONE_VM|CLONE_VFORK|SIGCHLD, 
      &args);

  if (new_pid > 0) {
    printf("we should get here only after child called _exit()\n");
    if (args.err < 0) {
      printf("Oops -- args.err should be 0 because it was set in the child\n");
    }
    waitpid(new_pid, NULL, 0);
    printf("child finished doing it's thing\n");
  } else if (new_pid == -1) {
    printf("this path was fixed in #1005\n");
  }

  printf("exiting main\n");
  return 0;
}

therealkenc avatar Apr 14 '17 20:04 therealkenc

I unpacked the relevant file, ran locale-gen, but still got this error when installing gtkd from the AUR (on WSL). Is there another locale I need to set beyond en_US.UTF-8?

bronze51 avatar Apr 15 '17 02:04 bronze51

The same thing also happens when I use clang, from what I can tell.

skyem123 avatar Apr 16 '17 13:04 skyem123

I ran into the same problem trying yocto project build in Ubuntu 16.04 in WSL: `automake (GNU automake) 1.15 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv2+: GNU GPL version 2 or later http://gnu.org/licenses/gpl-2.0.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Written by Tom Tromey [email protected] and Alexandre Duret-Lutz [email protected]. AUTOV is 1 autoreconf: Entering directory .' autoreconf: configure.ac: not using Gettext autoreconf: running: aclocal --system-acdir=/home/derekyu/poky/build/tmp/work/x86_64-linux/libtool-native/2.4.6-r0/recip e-sysroot-native/usr/share/aclocal/ -I /home/derekyu/poky/build/tmp/work/x86_64-linux/libtool-native/2.4.6-r0/libtool-2. 4.6/m4/ -I /home/derekyu/poky/build/tmp/work/x86_64-linux/libtool-native/2.4.6-r0/libtool-2.4.6/tests/ --force -I m4 m4: ../sysdeps/unix/sysv/linux/spawni.c:360: __spawnix: Assertion ec >= 0' failed. m4: internal error detected; please report this bug to [email protected]: Aborted autom4te: m4 failed with exit status: 2 aclocal: error: echo failed with exit status: 2`

Is there any get around in this issue?

derekyu56 avatar Apr 23 '17 02:04 derekyu56

@derekyu56 - That's somewhat curious, if you are on 16.04 (Xenial). What does m4 --version report? Also ldd --version. You should see m4 1.4.17 and glibc 2.23. The problem reported here shouldn't happen until glibc 2.24 or 2.25 (I never took the time to figure which, since it's academic either way).

[edit] I didn't pick up on 'yocto build'. If yocto ships m4 make sure get that binary's version, not the one from Ubuntu Xenial. And if the yocto m4 binary is statically linked, then pretty much all bets are off. The work-around would be to use Xenial's m4 with Xenial's 2.23 glibc.

therealkenc avatar Apr 23 '17 02:04 therealkenc

Here are the version information:

m4 (GNU M4) 1.4.17 ldd (Ubuntu GLIBC 2.23-0ubuntu7) 2.23

I don't think Yocto shipped with m4.

derekyu56 avatar Apr 23 '17 15:04 derekyu56

Sorry, I was wrong. Yocto did shipped with m4 and it is version 1.4.18. I will see if I can replace it with the one from Xenial.

derekyu56 avatar Apr 23 '17 15:04 derekyu56

You can also try to find an older version of Yocto that uses glibc 2.23. [m4 isn't really the problem here.] In other words rather than "replace it with the one from Xenial", find a Yocto that is better aligned with the toolchain that ships with Xenial. Either way good luck.

therealkenc avatar Apr 23 '17 15:04 therealkenc

Unfortunately, older version has different problems and I was not able to use that either. Thanks for the suggestion. I guess I will have to wait until this issue is resolved.

derekyu56 avatar Apr 23 '17 17:04 derekyu56

@Christoph-Wagner That exactly helps! THX dude.

vc12345679 avatar Apr 26 '17 13:04 vc12345679

What is needed to get this actually fixed? The workarounds are fine for each use-case, but it those aren't permanent solutions. I'm running into this issue when using NixOS, which uses m4. My guess is that eventually LTS distros will also run into these issues.

bobvanderlinden avatar Aug 17 '17 09:08 bobvanderlinden

@bobvanderlinden I've followed this on ArchLinux https://wiki.archlinux.org/index.php/Install_on_WSL, it contains links for fixed packages, and it works, I just installed them. Not sure it's easy to port it to your plataform.

oblitum avatar Aug 17 '17 15:08 oblitum

I keep putting off doing a wsl-glibc PPA for Ubuntu with the cherry pick I mentioned in April. This blocks Yakkety/Ardvark as well as the rolling update distros like Arch&Gentoo. That said, Ubuntu 18 won't go LTS for a long time. It is a pain for people running static binaries like Yocto though, and there isn't much you can do there except rebuild against a working glibc.

therealkenc avatar Aug 18 '17 02:08 therealkenc

@therealkenc cherry picking or reverting just like the AUR wsl-glibc package does?

oblitum avatar Aug 18 '17 02:08 oblitum