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

Avoid running wasm-opt indefinitely #1191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

quark-zju
Copy link

POSIX says 1:

If a file is removed from or added to the directory after the most recent
call to opendir() or rewinddir(), whether a subsequent call to readdir()
returns an entry for that file is unspecified.

Writing wasm-opt output, renaming in a same directory being readdir()-ed is unspecified, and can cause the readdir() to loop indefinitely on certain filesystems.

Fix it by collecting readdir() result first before making changes to the directory.

Resolves #1190.

Make sure these boxes are checked! 📦✅

  • You have the latest version of rustfmt installed
$ rustup component add rustfmt
  • You ran cargo fmt on the code base before submitting
  • You reference which issue is being closed in the PR text

✨✨ 😄 Thanks so much for contributing to wasm-pack! 😄 ✨✨

POSIX says [1]:

> If a file is removed from or added to the directory after the most recent
> call to opendir() or rewinddir(), whether a subsequent call to readdir()
> returns an entry for that file is unspecified.

Writing `wasm-opt` output, renaming in a same directory being `readdir()`-ed is
unspecified, and can cause the `readdir()` to loop indefinitely on certain
filesystems.

Fix it by collecting `readdir()` result first before making changes to the
directory.

Resolves rustwasm#1190.

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html
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 this pull request may close these issues.

wasm-opt might run unnecessarily repetitively on its own output
1 participant