Fix opening directories failing on Windows when fdFlags contains NONBLOCK#6348
Merged
jameysharp merged 1 commit intobytecodealliance:mainfrom May 8, 2023
Merged
Conversation
Subscribe to Label Actioncc @kubkon DetailsThis issue or pull request has been labeled: "wasi"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
pchickey
approved these changes
May 5, 2023
Contributor
pchickey
left a comment
There was a problem hiding this comment.
Thank you for finding and fixing this bug!
jameysharp
approved these changes
May 8, 2023
Contributor
jameysharp
left a comment
There was a problem hiding this comment.
This fix makes sense, and thank you for the new tests as well!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
We were testing the new wasmtime 8.0.1 on Windows and are getting "Permission denied" errors opening directories, while reading files under those directories work fine.
Test Case
The issue is reproducible using the below rust program (built as lister.wasm in the snippets) that directly calls opendir:
Steps to Reproduce
Build a wasm module using the test case snippet, and invoke it pointing to a directory using wasmtime-8.0.1 on Windows:
The same command works when using 8.0.0:
Versions and Environment
Wasmtime version or commit: wasmtime 8.0.1
Operating system: Windows 10
Architecture: x86_64
Extra details
The bug seems to be related to the changes in #6163. The code is failing here:
https://github.com/bytecodealliance/wasmtime/blob/main/crates/wasi-common/cap-std-sync/src/dir.rs#L93
Which was not previously applied to directories. That results on the directory being reopened which ends up calling Windows ReOpenFile, and that returns a "Access denied".
We have "fixed" the issue by moving the code to be executed only for files, but that may not be the best solution. It would be great of you could give us some tips if that is not the proper solution to improve the patch.