Stream: git-wasmtime

Topic: wasmtime / issue #6239 wasmtime fails to poll host /dev/r...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 19 2023 at 00:01):

TerrorJack opened issue #6239:

Test Case

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>

int main(int argc, char *argv[]) {
  int fd = open("/dev/random", O_RDONLY);
  fd_set readfds, writefds, errorfds;
  FD_ZERO(&readfds);
  FD_SET(fd, &readfds);
  FD_ZERO(&writefds);
  FD_ZERO(&errorfds);
  if (select(fd + 1, &readfds, &writefds, &errorfds, NULL) == -1) {
    perror(strerror(errno));
    exit(errno);
  }
}

Steps to Reproduce

Use wasi-sdk to compile the example above and run it:

$ clang random.c -o random.wasm
$ wasmtime run --mapdir /::/ -- random.wasm
Invalid argument: Invalid argument

If the same program is compiled by host gcc, it runs fine. Also, it works with nodejs/uvwasi.

Versions and Environment

Wasmtime version or commit: wasmtime-cli 7.0.0

Operating system: Ubuntu 22.10

Architecture: x86_64

view this post on Zulip Wasmtime GitHub notifications bot (Apr 19 2023 at 00:01):

TerrorJack labeled issue #6239:

Test Case

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>

int main(int argc, char *argv[]) {
  int fd = open("/dev/random", O_RDONLY);
  fd_set readfds, writefds, errorfds;
  FD_ZERO(&readfds);
  FD_SET(fd, &readfds);
  FD_ZERO(&writefds);
  FD_ZERO(&errorfds);
  if (select(fd + 1, &readfds, &writefds, &errorfds, NULL) == -1) {
    perror(strerror(errno));
    exit(errno);
  }
}

Steps to Reproduce

Use wasi-sdk to compile the example above and run it:

$ clang random.c -o random.wasm
$ wasmtime run --mapdir /::/ -- random.wasm
Invalid argument: Invalid argument

If the same program is compiled by host gcc, it runs fine. Also, it works with nodejs/uvwasi.

Versions and Environment

Wasmtime version or commit: wasmtime-cli 7.0.0

Operating system: Ubuntu 22.10

Architecture: x86_64

view this post on Zulip Wasmtime GitHub notifications bot (Apr 19 2023 at 18:32):

TerrorJack commented on issue #6239:

Likewise for /dev/null. Reading from it should always return an EOF instead of failing with "invalid argument".

view this post on Zulip Wasmtime GitHub notifications bot (Apr 20 2023 at 23:06):

sunfishcode commented on issue #6239:

This is a bug in system-interface. I'm working on a fix.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2023 at 01:13):

sunfishcode closed issue #6239:

Test Case

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>

int main(int argc, char *argv[]) {
  int fd = open("/dev/random", O_RDONLY);
  fd_set readfds, writefds, errorfds;
  FD_ZERO(&readfds);
  FD_SET(fd, &readfds);
  FD_ZERO(&writefds);
  FD_ZERO(&errorfds);
  if (select(fd + 1, &readfds, &writefds, &errorfds, NULL) == -1) {
    perror(strerror(errno));
    exit(errno);
  }
}

Steps to Reproduce

Use wasi-sdk to compile the example above and run it:

$ clang random.c -o random.wasm
$ wasmtime run --mapdir /::/ -- random.wasm
Invalid argument: Invalid argument

If the same program is compiled by host gcc, it runs fine. Also, it works with nodejs/uvwasi.

Versions and Environment

Wasmtime version or commit: wasmtime-cli 7.0.0

Operating system: Ubuntu 22.10

Architecture: x86_64


Last updated: Dec 23 2024 at 12:05 UTC