Stream: git-wasmtime

Topic: wasmtime / issue #4351 Wasmtime: disable unwind_info unle...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 29 2022 at 04:12):

github-actions[bot] commented on issue #4351:

Subscribe to Label Action

cc @peterhuene

<details>
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 <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (Jun 29 2022 at 04:12):

github-actions[bot] commented on issue #4351:

Label Messager: wasmtime:config

It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:

[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html


<details>

To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.

To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.

Learn more.

</details>

view this post on Zulip Wasmtime GitHub notifications bot (Jun 29 2022 at 15:27):

alexcrichton commented on issue #4351:

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.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 29 2022 at 15:31):

alexcrichton commented on issue #4351:

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.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 29 2022 at 15:55):

Stebalien commented on issue #4351:

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.

There's a test:

https://github.com/bytecodealliance/wasmtime/blob/2034c8aa453d7114ef8acbe201bd4acec9117974/tests/all/traps.rs#L73-L97

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.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 29 2022 at 15:59):

Stebalien commented on issue #4351:

Also, I'm a bit confused how this is coming up, this example program works for me:

It does work, however:

  1. In 0.38, unwind info won't be disabled unless you also disable reference types. If you disable reference types as well, that won't work.
  2. In 0.39 (dev), that will "work" simply because unwind info won't be disabled no matter what you do.

The test I added should catch this.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 29 2022 at 16:03):

alexcrichton commented on issue #4351:

Ah ok that makes sense, thanks for clarifying. I had forgotten that the changes to Config and idempotency which would affect this were only on 0.39.0 and not 0.38.0.

Otherwise though I think that the unwind_info flag still needs verification as you mentioned along the lines of safepoints. If wasm_backtrace or wasm_reference_types are enabled then unwind_info must be true, but otherwise the value of the flag does not matter.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 29 2022 at 17:39):

Stebalien commented on issue #4351:

Otherwise though I think that the unwind_info flag still needs verification as you mentioned along the lines of safepoints.

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 https://github.com/bytecodealliance/wasmtime/blob/61312a9bf4b6a5d0922f77901f9b3f025de324ef/crates/wasmtime/src/config.rs#L1410

view this post on Zulip Wasmtime GitHub notifications bot (Jun 29 2022 at 21:41):

alexcrichton commented on issue #4351:

This is needed for memory safety I believe. Without a check it's possible to load a wasm module which doesn't have .eh_frame and we're then unable to produce backtraces or backtraces crash at runtime if backtraces are required. The specific problem is compiling a module without .eh_frame as a precompiled artifact and then loading it into an engine that tries to do backtraces.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 29 2022 at 23:39):

Stebalien commented on issue #4351:

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?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 30 2022 at 15:27):

Stebalien commented on issue #4351:

@alexcrichton and @pchickey, thanks for guiding me through this!


Last updated: Dec 23 2024 at 12:05 UTC