microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.29k stars 814 forks source link

Kernel isn't configured for semaphores #2013

Closed moosejackson closed 7 years ago

moosejackson commented 7 years ago

Semaphores are still not working in build 15063.11. Running ipcs in bash:

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status

Kernel not configured for semaphores

Kernel not configured for message queues

According to https://wpdev.uservoice.com semaphores should be working.

moosejackson commented 7 years ago

The problem was, that I had to update Ubuntu to 16.04 using

do-release-upgrade

Now it seems, that semaphors could work

fpqc commented 7 years ago

Semaphores, I think, still don't work in the fakeroot program, which still needs to be recompiled with the tcp flag on an arch userspace.

I was able to generate an strace of it failing here while using makepkg:

https://ptpb.pw/0psK

(I had to use an old version of strace because the latest version fails on an unimplemented ptrace option)

It seems like it's failing when it runs faked, so I straced running that directly:

https://ptpb.pw/jyuQ

therealkenc commented 7 years ago

1016

fpqc commented 7 years ago

@therealkenc support is now there partially, that's why postgres works I thought

stehufntdev commented 7 years ago

The Creator's update has support for SysV semaphores and shared memory. Closing this out as fixed in the creator's update, but please let us know if you hit any issues.

fpqc commented 7 years ago

@stehufntdev my strace is from CU. The problem should happen in all versions of fakeroot compiled with the default sysvipc mechanism rather than tcp.

therealkenc commented 7 years ago

@fpqc - If you post a strace -ff faked [however you do it] 2> faked.strace I'll take a look. The one you posted doesn't have any fails to explain the write(2, "fakeroot, while creating message"..., 68 message. Actually it doesn't even contain a clone() or exec(), which could be an ptrace() thing if you already ran it with -ff. I have seen this before, see for example #1306 (message); although the guy never followed up on Adam's question regarding strace -ff.

So you likely have a mulimode failure here. It is not clear where that "Function not implemented...This may be due to a lack of SYSV IPC support" error is coming from. It could be SysV IPC. It could be a bad guess on faked's part. If you are still splashing around in Arch-land, best thing to do is sit tight until #555 and #1878 (message) to flip to fixedinsiderbuilds. #1878 hasn't even made it to bug yet.

therealkenc commented 7 years ago

FWIW, the problem with faked does look like plain old unimplemented surface. The bonus is that the syscall fail does not turn up in strace. I have seen this before when I did #1530. For some reason I think we might have lost ENOSYS traces along the way. Anyway, test case below. This is on 16184, stock WSL 16.04.2 userspace. This has nothing to do with Arch or the rest.

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/msg.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>

int main(int argc, const char * argv[])
{
  char buf[1024];
  int msg_get, msg_key = 42;
  msg_get = msgget(msg_key,IPC_CREAT|0600);
  if (msg_get == -1) {
    strerror_r(errno, buf, sizeof(buf));
    printf("msgget: %s\n", buf);
  }
  return 0;
}

strace:

...usual stuff
munmap(0x7fdc1a8ac000, 147083)          = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
brk(NULL)                               = 0x203e000
brk(0x205f000)                          = 0x205f000
write(1, "msgget: Function not implemented"..., 33) = 33
exit_group(0)                           = ?
+++ exited with 0 +++
fpqc commented 7 years ago

yeah, I tried it on Ubuntu too, thought I mentioned that

stehufntdev commented 7 years ago

@fpqc, can you please share out your repro? Locally when I run ipcs, I get different output from what you posted above:

root@stehuf-test:/# ipcs

------ Message Queues -------- key msqid owner perms used-bytes messages

------ Shared Memory Segments -------- key shmid owner perms bytes nattch status

------ Semaphore Arrays -------- key semid owner perms nsems

fpqc commented 7 years ago

@stehufntdev I didn't run ipcs, I ran fakeroot/faked. @moosejackson ran ipcs.

stehufntdev commented 7 years ago

Sorry for the mix-up there, when I run fakeroot locally I get the failure below which is due to missing msgqueue support not semaphones (i.e. MSGGET, MSGCTL, ...). Are you seeing a different failure?

root@stehuf-test:/# fakeroot fakeroot, while creating message channels: Function not implemented This may be due to a lack of SYSV IPC support. fakeroot: error while starting the `faked' daemon. kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

benhillis commented 7 years ago

System V semaphores and shared memory were implemented during Creators Update but message queues were not.

fpqc commented 7 years ago

Ah, there we go. Mystery solved.

moosejackson commented 7 years ago

When I've tried to run fakeroot, I got the same message as @stehufntdev mentioned. I had some problems with using semaphores in WSL(not sure where was exactly the problem), so I've installed Fedora to virtual machine and did all I needed there. I had to use semaphores and shared memory for my school project (synchronization of processes) and it is already done :)