Stream: git-wasmtime

Topic: wasmtime / issue #7583 `fd_tell` not working when file is...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 25 2023 at 23:46):

yagehu added the bug label to Issue #7583.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 25 2023 at 23:46):

yagehu opened issue #7583:

Test Case

Compile the below C code with wasi-sdk.

#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>

int main() {
    int f = open("tmp/a", O_CREAT | O_WRONLY | O_APPEND);
    if (f == -1) perror("open");

    int offset = lseek(f, 0, SEEK_CUR);
    printf("offset before write %d\n", offset);

    int written = write(f, "abc", 4);
    printf("written %d bytes\n", written);

    offset = lseek(f, 0, SEEK_CUR);
    printf("offset after write %d\n", offset);
}

Steps to Reproduce

  1. Compile the C code with wasi-sdk to a WASM file say: a.wasm
  2. Run the code mounting an empty directory: wasmtime run --dir tmp a.wasm

Expected Results

fd_tell should report the actual fd offset equal to bytes written.

offset before write 0
written 4 bytes
offset after write 4

Actual Results

fd_tell always reports 0.

offset before write 0
written 4 bytes
offset after write 0

Versions and Environment

Wasmtime v15.0.0

Operating system: Fedora 39

Architecture: amd64

Extra Info

view this post on Zulip Wasmtime GitHub notifications bot (Nov 27 2023 at 15:42):

alexcrichton commented on issue #7583:

cc @pchickey I think this is a bug with -Spreview2. If -Spreview2=n is specified I believe this achieves the desired behavior.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 27 2023 at 17:49):

pchickey closed issue #7583:

Test Case

Compile the below C code with wasi-sdk.

#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>

int main() {
    int f = open("tmp/a", O_CREAT | O_WRONLY | O_APPEND);
    if (f == -1) perror("open");

    int offset = lseek(f, 0, SEEK_CUR);
    printf("offset before write %d\n", offset);

    int written = write(f, "abc", 4);
    printf("written %d bytes\n", written);

    offset = lseek(f, 0, SEEK_CUR);
    printf("offset after write %d\n", offset);
}

Steps to Reproduce

  1. Compile the C code with wasi-sdk to a WASM file say: a.wasm
  2. Run the code mounting an empty directory: wasmtime run --dir tmp a.wasm

Expected Results

fd_tell should report the actual fd offset equal to bytes written.

offset before write 0
written 4 bytes
offset after write 4

Actual Results

fd_tell always reports 0.

offset before write 0
written 4 bytes
offset after write 0

Versions and Environment

Wasmtime v15.0.0

Operating system: Fedora 39

Architecture: amd64

Extra Info


Last updated: Dec 23 2024 at 12:05 UTC