-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Wasmtime: disable unwind_info unless needed #4351
Wasmtime: disable unwind_info unless needed #4351
Conversation
fixes bytecodealliance#4350 Otherwise wasm modules will be built with unwind info, even if backtraces are disabled. This can get expensive in deeply recursive modules.
92d9bff
to
4f609f7
Compare
crates/wasmtime/src/engine.rs
Outdated
@@ -381,6 +380,7 @@ impl Engine { | |||
| "enable_verifier" | |||
| "regalloc_checker" | |||
| "is_pic" | |||
| "unwind_info" |
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.
Note: this is inconsistent with "enable_safepoints", which checks that we don't ahve the reference_types
feature enabled. But so is "enable_simd", so I'm not sure which way to go.
Subscribe to Label Actioncc @peterhuene
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:config"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Label Messager: wasmtime:configIt looks like you are changing Wasmtime's configuration options. Make sure to
To modify this label's message, edit the To add new label messages or remove existing label messages, edit the |
Would you be up for adding a test which disables backtraces? I thought we had something along those lines but it sounds like your configuration is different which our current test suite isn't covering. |
Also, I'm a bit confused how this is coming up, this example program works for me: use anyhow::Result;
use wasmtime::*;
fn main() -> Result<()> {
let mut config = Config::new();
config.wasm_backtrace(false);
let engine = Engine::new(&config).unwrap();
let m1 = Module::new(&engine, "(module (func unreachable))")?;
let bytes = m1.serialize()?;
let m2 = unsafe { Module::deserialize(&engine, &bytes)? };
let mut store = Store::new(&engine, ());
Instance::new(&mut store, &m1, &[])?;
Instance::new(&mut store, &m2, &[])?;
Ok(())
} so I'm also curious what configuration you're using to trigger the error coming out. |
There's a test: Lines 73 to 97 in 2034c8a
But it doesn't test that unwind info isn't generated. I've just added a targeted one to make sure it's disabled at the compiler level, but there may be a better way. |
It does work, however:
The test I added should catch this. |
Ah ok that makes sense, thanks for clarifying. I had forgotten that the changes to Otherwise though I think that the |
I was pointing out an inconsistency. It looks like that function is primarily for validating that the config matches the current system, not for validating that the config matches the flags. That function isn't currently checking, e.g., enable_simd, enable_float, enable_verifier, etc. either. The enable_safepoints check is actually the exception. The config is checked against the compiler flags in wasmtime/crates/wasmtime/src/config.rs Line 1410 in 61312a9
|
This is needed for memory safety I believe. Without a check it's possible to load a wasm module which doesn't have |
Ah, because this is checking the compiled module. Got it, thanks. That also explains why we don't care about enable_simd, enable_float, etc. (although the fact that the engine will happily deserialize a module that doesn't quite match the engine's config is non-obvious). I've pushed a fix, but I think there's still technically a bug. We're checking that we have unwind_info if the flag is present, but we're not making sure the flag is actually present. I'm not sure if we really care, but I figured I'd mention it. Meta: would you like me to squash? |
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.
Currently we're guaranteed that every module will have all the options listed, but yeah as you've noticed this isn't the best system and we'd like to improve it. For now this should be good enough but it's definitely not great that each individual option tries to have an ad-hoc level of compatibility when we'd probably get the same mileage with just asserting everything is the same.
@alexcrichton and @pchickey, thanks for guiding me through this! |
Disable the "unwind_info" cranelift feature unless backtraces (or reference types) are enabled. Maintaining unwind info in deeply recursive modules can get expensive.
fixes #4350