wasmerio/wasmer

`fd_advise` behavior diverges from other runtimes with large offset + len

yagehu opened this issue · 1 comments

Describe the bug

fd_advise should not fail with inval even if given a very large offset and len combination.

I caused this in #4555 trying to rectify a behavior divergence with other runtimes. I over spec'd the test.

Steps to reproduce

Directly call fd_advise with a valid fd but very large (> INT64_MAX) offset and len.

Expected behavior

fd_advise should return 0.

Actual behavior

fd_advise returns inval (28).

Additional context

Mini PR incoming.

It's a little more complicated than I realized. Since most runtimes use posix_fadvise, and its behavior is such that a negative offset is OK while a negative len is not OK, the behavior divergence cannot be simply fixed by allowing all values. This seems to be a case of the permissiveness of WASI allows implementations to leak underlying details. IMO there's no obvious correct behavior here.