-
Notifications
You must be signed in to change notification settings - Fork 401
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm-opt might run unnecessarily repetitively on its own output #1190
Comments
quark-zju
added a commit
to quark-zju/wasm-pack
that referenced
this issue
Nov 11, 2022
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
3 tasks
+1 - this happens to me as well on EdenFS. |
Is this why our Netlify pipeline spends like 15-20 minutes on the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
馃悰 Bug description
On certain filesystems
wasm-pack
might repetitively callwasm-opt
with previous output fromwasm-opt
as new input ofwasm-opt
and it's unspecified when the loop ends.馃 Expected Behavior
wasm-opt
runs exactly once per input file.馃憻 Steps to reproduce
This was discovered on EdenFS. But EdenFS can be tricky to build or config externally.
The problem seems obvious, though. In this loop, the directory is being
readdir()
-ed and written to at the same time. It's unspecified whether the newly written files will appear in the next iteration ofreaddir()
or not. If it does appear, thenwasm-opt
runs again on its input. I have a fix at quark-zju@37650af.See also https://stackoverflow.com/questions/39015527/is-it-safe-to-rename-files-while-using-readdir
馃實 Your environment
Include the relevant details of your environment.
wasm-pack version: 0.10.3
rustc version: 1.65.0
The text was updated successfully, but these errors were encountered: