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

  • 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

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 10
  • Comments: 59 (8 by maintainers)

Most upvoted comments

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.

I’ve been working hard at fixing this. Supporting CLONE_VM correctly has required some significant refactoring. Please hold on a little longer.

Good news – we’ve got this fixed in an internal build now, and I’m successfully running Ubuntu 17.10 on my machine.

Sorry this didn’t make 17025 – I’ll post an update once this makes it into an insider build.

Windows Insider Build 17046 has improved CLONE_VFORK and CLONE_VM support.

No 😦. We’ve had some unfortunate delays getting WSL fixes into the insider builds lately. We’ll get that unblocked as soon as we can.

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;
}

These errors are all expected pre-build 17046. If you see these errors on 17046 or newer, please let us know.

The behavior is not yet fully compatible. There are still some flags including CLONE_NEWUSER and CLONE_SIGHAND that do not work, and some supported flag combinations that either are not 100% compatible or haven’t yet been verified to be. Some of these we are already looking at and others will be prioritized, as per usual, when interesting scenarios emerge involving them.

For those of you not on the Insider channel, I made a workaround script. If you want to update to Ubuntu 17.10, that should do the trick, but be warned it could have unintended side effects in scenarios I haven’t tested, and could cause problems when you do eventually receive the fix from Microsoft.

This bug is annoying, i have to recompile glibc every time i upgrade it. It wastes me a lot of time.

@oblitum - You can vote for that here.

@therealkenc I can’t say for others but my motivation is enough to have my working Arch now rather than Ubuntu 😉

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

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

Since you’ve got 2.26, I suspect you’ll find fish, m4, clang, and all the rest cited in this thread above (plus whatever undiscovered gems) will still fail.

absolutely. holding bash only fixes the do-release-upgrade erroring out on zesty → artful.

glad to see a fix is inbound tho.

@ardhitama here too. “solved” it temporarily by holding offending packages before do-release-upgrade:

sudo apt-mark hold bash
sudo apt-mark hold ebtables

Extra tidbits, it also affects me after upgrading to Ubuntu 17.10 when doing the first apt upgrade. With following error:

Preparing to unpack .../bash_4.4-5ubuntu1_amd64.deb ...
preinst: ../sysdeps/unix/sysv/linux/spawni.c:368: __spawnix: Assertion `ec >= 0' failed.
dpkg: error processing archive /var/cache/apt/archives/bash_4.4-5ubuntu1_amd64.deb (--unpack):

@tuxzz You can make a backup of /usr/lib/locale/locale-archive, when glibc upgrades, restore it.

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.