Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a signals-based-traps Cargo compile-time feature #9614

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

alexcrichton
Copy link
Member

This PR adds a new signals-based-traps Cargo compile-time feature which mirrors the Config::signals_based_traps runtime configuration. Disabling this Cargo feature enables reducing Wasmtime's platform requirements to remove the need for virtual memory and trap handlers for example. That means that the underlying platform requirements are just setjmp/longjmp and a single pointer of thread-local storage. This should make it significantly easier to port Wasmtime to platforms that may not have virtual memory in the future.

I'll note that one of the main purposes of this PR isn't quite realized just yet which is to run Pulley on embedded systems. Pulley isn't finished, however, so this is more setting the stage for that to be possible in the future than enabling it right this red-hot-second.

@github-actions github-actions bot added wasi Issues pertaining to WASI wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:config Issues related to the configuration of Wasmtime labels Nov 16, 2024
Copy link

Label Messager: wasmtime:config

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

  • If you added a new Config method, you wrote extensive documentation for
    it.

    Our documentation should be of the following form:

    Short, simple summary sentence.
    
    More details. These details can be multiple paragraphs. There should be
    information about not just the method, but its parameters and results as
    well.
    
    Is this method fallible? If so, when can it return an error?
    
    Can this method panic? If so, when does it panic?
    
    # Example
    
    Optional example here.
    
  • If you added a new Config method, or modified an existing one, you
    ensured that this configuration is exercised by the fuzz targets.

    For example, if you expose a new strategy for allocating the next instance
    slot inside the pooling allocator, you should ensure that at least one of our
    fuzz targets exercises that new strategy.

    Often, all that is required of you is to ensure that there is a knob for this
    configuration option in wasmtime_fuzzing::Config (or one
    of its nested structs).

    Rarely, this may require authoring a new fuzz target to specifically test this
    configuration. See our docs on fuzzing for more details.

  • If you are enabling a configuration option by default, make sure that it
    has been fuzzed for at least two weeks before turning it on by default.


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

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

Learn more.

@github-actions github-actions bot added the fuzzing Issues related to our fuzzing infrastructure label Nov 16, 2024
Copy link

Subscribe to Label Action

cc @fitzgen

This issue or pull request has been labeled: "fuzzing", "wasi", "wasmtime:api", "wasmtime:config"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: fuzzing

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@alexcrichton alexcrichton marked this pull request as ready for review November 18, 2024 17:11
@alexcrichton alexcrichton requested review from a team as code owners November 18, 2024 17:11
@alexcrichton alexcrichton requested review from pchickey and removed request for a team November 18, 2024 17:11
@alexcrichton alexcrichton reopened this Nov 18, 2024
Copy link
Contributor

@pchickey pchickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty cool!

This commit adds a new on-by-default Cargo feature to the `wasmtime`
crate named `signals-based-traps`. This is modeled after the
`Config::signals_based_traps` configuration at runtime and can be used
to statically disable the use of signal handlers in Wasmtime. This
notably reduces the number of platform dependencies that Wasmtime has
and provides a mode of avoiding relying on signals altogether.

This introduces a new `MallocMemory` which is a linear memory backed by
the system allocator. This new type of memory is enabled when virtual
memory guards are disabled and signals-based-traps are disabled. This
means that this new type of memory will be candidate for fuzzing for
example.

prtest:full
* Remove no-longer-needed `Arc`
* Document it may be backed by `Vec<u8>`
@alexcrichton
Copy link
Member Author

I've pushed some extra refactoring of MmapVec as well to handle the internals a bit better given today's requirements.

@alexcrichton alexcrichton added this pull request to the merge queue Nov 19, 2024
Merged via the queue into bytecodealliance:main with commit d3132c9 Nov 19, 2024
128 checks passed
@alexcrichton alexcrichton deleted the traps-cargo-feature branch November 19, 2024 19:44
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
fuzzing Issues related to our fuzzing infrastructure wasi Issues pertaining to WASI wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:config Issues related to the configuration of Wasmtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants