Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fd_advise always succeeds #3322

Closed
yagehu opened this issue Apr 17, 2024 · 0 comments · Fixed by #3323
Closed

fd_advise always succeeds #3322

yagehu opened this issue Apr 17, 2024 · 0 comments · Fixed by #3323

Comments

@yagehu
Copy link
Contributor

yagehu commented Apr 17, 2024

Subject of the issue

Calling fd_advise always succeeds, even with very large offset, length, or a combination of them.

Test case

(module
  (type (;0;) (func))
  (type (;1;) (func (param i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i32)))
  (type (;2;) (func (param i32)))
  (type (;4;) (func (param i32 i64 i64 i32) (result i32)))
  (import "wasi_snapshot_preview1" "path_open" (func $path_open (type 1)))
  (import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (type 2)))
  (import "wasi_snapshot_preview1" "fd_advise" (func $fd_advise (type 3)))
  (func $_start (type 0)
    (local $err i32)

    (local.set $err
      (call $path_open
        (i32.const 3)
        (i32.const 0)
        (i32.const 1024)
        (i32.const 1)
        (i32.const 0)
        (i64.const 262143)
        (i64.const 262143)
        (i32.const 0)
        (i32.const 512)
      )
    )
    (local.get $err)
    (if
      (then (call $proc_exit (i32.const 1)))
    )

    (local.set $err
      (call $fd_advise
        (i32.load (i32.const 512))
        (i64.const 16942241767661461241)
        (i64.const 9765931924571875679)
        (i32.const 0)
      )
    )
    (local.get $err)
    (if
      (then (call $proc_exit (local.get $err)))
    )

    (call $proc_exit (i32.const 0))
  )
  (memory 2)
  (export "memory" (memory 0))
  (export "_start" (func $_start))
  (data (i32.const 1024) "a\00")
)

Your environment

64-bit x86 Fedora Linux

WAMR is latest HEAD.

Steps to reproduce

Use wat2wasm to encode the above WAT code and run it with iwasm mounting some directory:

$ wat2wasm advise.wat -o advise.wasm
$ iwasm --dir=. advise.wasm
$ echo $?

Expected behavior

It should print some non-zero error code, say 28.

Actual behavior

It prints 0.

Extra Info

I will raise a PR that fixes this.

yagehu added a commit to yagehu/wasm-micro-runtime that referenced this issue Apr 17, 2024
`posix_fadvise()` returns 0 on success and the errno on error.  This
commit fixes the handling of the return value such that it does not
always succeeds.

fixes bytecodealliance#3322
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this issue May 1, 2024
`posix_fadvise()` returns 0 on success and the errno on error.  This
commit fixes the handling of the return value such that it does not
always succeeds.

Fixes bytecodealliance#3322.
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this issue May 2, 2024
`posix_fadvise()` returns 0 on success and the errno on error.  This
commit fixes the handling of the return value such that it does not
always succeeds.

Fixes bytecodealliance#3322.

Signed-off-by: victoryang00 <victoryang00@ucsc.edu>
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this issue May 27, 2024
`posix_fadvise()` returns 0 on success and the errno on error.  This
commit fixes the handling of the return value such that it does not
always succeeds.

Fixes bytecodealliance#3322.
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this issue May 27, 2024
`posix_fadvise()` returns 0 on success and the errno on error.  This
commit fixes the handling of the return value such that it does not
always succeeds.

Fixes bytecodealliance#3322.

Signed-off-by: victoryang00 <victoryang00@ucsc.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant