-
Notifications
You must be signed in to change notification settings - Fork 253
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
Added a separate method that reads a string of unlimited length for use in the custom name section #1650
Added a separate method that reads a string of unlimited length for use in the custom name section #1650
Conversation
Thanks for the PR! The purpose of these limits is to align with browser engines, although if this file works in browsers then something isn't aligned. Would you be up for investigating this? For example have the limits changed in browsers? Or are browsers basically completely ignoring the name section? One other fix would be to add a separate method that reads a string of unlimited length and use that for the name section instead. |
Heh, I came here because I have already researched this issue as much as I needed/could, from this topic getsentry/symbolic#848, nevertheless, I will try to expand on the topic. If I understand correctly, the purpose of custom sections (including the name section) [LINK] is to extend the wasm file with things that are not needed for it to work properly (we can skip all custom sections). And it seems that this is what is happening, because the wasm file with a large name section works in the browser, but does not work in wasm-tools/wasmparser → I tested it in google-chrome. Additionally, the name section in google-chrome is parsed because wasm crash stack trace contain demangled symbols (this wouldn't be possible otherwise, but I checked it anyway, removing the name section and leave .debug sections, there are no symbols in the stacktrace) → this behavior is consistent with the wasm documentation. As I wrote earlier, from a documentation point of view, the wasm file is correct: the documentation does not mention a section limit or a function count limit → so I think the parsing-implementation should be changed.
And 'function names' subsection contain Reads a string of unlimited length will potentially temporarily use a large amount of RAM, and will change this limit in places other than 'function names' → Actually, my solution also has a second disadvantage 😞 📍. A local workaround I can do is to modify the name section before uploading it to sentry:
This PR is just a cheap attempt to handle my large files (although you can see I'm not alone with this). But having realized that it also side affects 📍, I think that it is not acceptable in this form. |
Apologies if I caused a bit of confusion, but let me try to be more specific. The wasmparser crate has hardcoded limits which you're modifying here. These hardcoded limits are shared in browsers (that's Firefox, Chrome/Safari should be similar). Changing these limits are generally not that consequential here in wasmparser but we try to keep them in sync with others so all engines behave similarly when validating modules. The specific limit you're running into here is the limit on the length of a string. This limit is baked in here and everything reading The main different appears to be that in Firefox it's using This is where my suggestion for "read a string of unlimited length" comes in. For example this check in wasmparser is not required for correctness or safety, it's just there to conform to what browsers are doing. That doesn't match what browsers are doing for the name section, however, so I think it's reasonable to have a method which is use by the name section which is "read a string but don't require it to be less than this statically known size". |
This reverts commit 2f36947.
@alexcrichton I think I understand what you mean, thank you for your patience and detailed explanation! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Adding some follow-up documentation to bytecodealliance#1650
Adding some follow-up documentation to #1650
Hi, I have a problem with symbol names being too long in the name section, which causes the length of string_name to exceed 100_000, causing an error to be return (if I understand it correctly).
It is generated by emscripten from C++ code, the unfortunate combination of several large templates (std stuff * nlohmann::json * rxcpp * ...) in single functions.
This causes a problem when trying to upload the debug.wasm file to sentry, see: getsentry/symbolic#848
Unfortunately, I don't know the best way to deal with this.
For now, I would like to propose a slight increase in the limit in this library, but I think that in the future it would be better to refactor the way the name section is parsed.
https://webassembly.github.io/spec/core/appendix/custom.html