You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On certain filesystems wasm-pack might repetitively call wasm-opt with previous output from wasm-opt as new input of wasm-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 of readdir() or not. If it does appear, then wasm-opt runs again on its input. I have a fix at quark-zju@37650af.
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.
Resolvesrustwasm#1190.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html
🐛 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: