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

Closure mangles ERRNO code names, but they are looked up dynamically by nodefs #14705

Closed
cyyynthia opened this issue Jul 20, 2021 · 0 comments · Fixed by #14722
Closed

Closure mangles ERRNO code names, but they are looked up dynamically by nodefs #14705

cyyynthia opened this issue Jul 20, 2021 · 0 comments · Fixed by #14722

Comments

@cyyynthia
Copy link
Contributor

I ran into weird issues of external C libraries interacting with a filesystem (nodefs) which would behave significantly differently depending on if I was building with --closure 1 or not.

After some troubleshooting, and some time looking at mangled code, I found out that the error handling was attempting to convert the full ERRNO code (as a string) against ERRNO_CODES dynamically, which does work when the code is not mangled, but breaks apart as soon as Closure kicks in and mangles the code names.

This results in operations like stat not behaving as expected (for instance, not returning an error on non-existing files), resulting in undefined behavior as the application behaves according to incorrect information about the state of the filesystem.

Reproduction case

I made a small repository with a minimal reproduction case, with build/run instructions on the readme: https://github.com/cyyynthia/emscripten-fs-bug

Environment information

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 2.0.24 (416685fb964c14cde4be3e8a45ad26d75bac3e33)
clang version 13.0.0 (/startdir/llvm-project 91f147792e815d401ae408989992f3c1530cc18a)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /opt/emscripten-llvm/bin
@cyyynthia cyyynthia changed the title Closure mangles ERRNO code names, but they are looked up dynamically Closure mangles ERRNO code names, but they are looked up dynamically by nodefs Jul 21, 2021
cyyynthia added a commit to cyyynthia/emscripten that referenced this issue Jul 22, 2021
kripken pushed a commit that referenced this issue Jul 26, 2021
As described in #14705, errno codes may be looked up dynamically when
using nodefs, noderawfs and proxyfs, but closure was mangling the properties,
making some fs operations behave unexpectedly resulting in undefined behavior.

This quotes those names so closure leaves them as is.

Closes #14705
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 a pull request may close this issue.

1 participant