Skip to content

Don’t panic when http handle function returns before invoking set#10256

Closed
primoly wants to merge 23 commits intobytecodealliance:mainfrom
primoly:ret-b4-set
Closed

Don’t panic when http handle function returns before invoking set#10256
primoly wants to merge 23 commits intobytecodealliance:mainfrom
primoly:ret-b4-set

Conversation

@primoly
Copy link
Copy Markdown
Contributor

@primoly primoly commented Feb 20, 2025

wasmtime serve currently presumes that a failure to call response-outparam::set inside handle means the component trapped. But it can also happen by returning before invoking set. This PR accommodates for that.

@primoly primoly requested a review from a team as a code owner February 20, 2025 18:03
@primoly primoly requested review from pchickey and removed request for a team February 20, 2025 18:03
pchickey and others added 2 commits February 20, 2025 19:34
…ce#10261)

fixes bytecodealliance#10257

Github now has a builtin choice for a blank issue, so it does not
require a template anymore.
…liance#10247)

* Winch: Add SIMD float arithmetic support for x64 with AVX

* Add ensure_has_avx to v128_neg method
@alexcrichton
Copy link
Copy Markdown
Member

Thanks! Could you add a test for this as well?

frank-emrich and others added 6 commits February 20, 2025 23:15
* Bump MSRV to 1.83.0

This commit updates the minimum supported Rust version for Wasmtime and
Cranelift to 1.83.0. This is coupled with Rust's release today of
1.85.0. Additionally the nightly version used in testing was updated to
today's nightly too.

prtest:full

* Update path_rename test to work on Windows

Looks like the Rust standard library and Windows now has enough support
to act the same across all platforms.

* Fix compile warning

* Looks like windows has new error codes now too

* This error is still different
* ci: generate a list of generated files

This fix is necessary for Windows users who may be using absolute-path
target directories: the previous solution, separating the paths by `:`,
runs into issues with Windows absolute paths (e.g., `C:\...`). This
change is similar to bytecodealliance#10266 but should avoid any further OS
compatibility issues during a hypothetical cross-compilation.

prtest:full

* fix: debug string
@primoly
Copy link
Copy Markdown
Contributor Author

primoly commented Feb 21, 2025

I’ve added tests, but they are useless, as they pass even without the changes of this PR. cli_serve_return_before_set is supposed to fail on the old branch. For some reason, when I execute my build of wasmtime it recovers from the panic, but when I use the downloaded prebuilt Wasmtime the program closes.

Here a component that returns before calling set. Invoke with wasmtime serve proxy.wat and then connect to it, for example with curl http://localhost:8080.

proxy.wat

(component
  (type (;0;)
    (instance
      (export (;0;) "incoming-request" (type (sub resource)))
      (export (;1;) "response-outparam" (type (sub resource)))
    )
  )
  (import "wasi:http/types@0.2.0" (instance (;0;) (type 0)))
  (core module (;0;)
    (type (;0;) (func (param i32 i32)))
    (export "cm32p2|wasi:http/incoming-handler@0.2|handle" (func $handle))
    (func $handle (;0;) (type 0) (param i32 i32)
      return
    )
  )
  (core instance (;0;) (instantiate 0))
  (alias export 0 "incoming-request" (type (;1;)))
  (type (;2;) (own 1))
  (alias export 0 "response-outparam" (type (;3;)))
  (type (;4;) (own 3))
  (type (;5;) (func (param "request" 2) (param "response-out" 4)))
  (alias core export 0 "cm32p2|wasi:http/incoming-handler@0.2|handle" (core func (;0;)))
  (func (;0;) (type 5) (canon lift (core func 0)))
  (alias export 0 "incoming-request" (type (;6;)))
  (alias export 0 "response-outparam" (type (;7;)))
  (component (;0;)
    (import "import-type-incoming-request" (type (;0;) (sub resource)))
    (import "import-type-response-outparam" (type (;1;) (sub resource)))
    (import "import-type-incoming-request0" (type (;2;) (eq 0)))
    (type (;3;) (own 2))
    (import "import-type-response-outparam0" (type (;4;) (eq 1)))
    (type (;5;) (own 4))
    (type (;6;) (func (param "request" 3) (param "response-out" 5)))
    (import "import-func-handle" (func (;0;) (type 6)))
    (export (;7;) "incoming-request" (type 0))
    (export (;8;) "response-outparam" (type 1))
    (type (;9;) (own 7))
    (type (;10;) (own 8))
    (type (;11;) (func (param "request" 9) (param "response-out" 10)))
    (export (;1;) "handle" (func 0) (func (type 11)))
  )
  (instance (;1;) (instantiate 0
      (with "import-func-handle" (func 0))
      (with "import-type-incoming-request" (type 6))
      (with "import-type-response-outparam" (type 7))
      (with "import-type-incoming-request0" (type 1))
      (with "import-type-response-outparam0" (type 3))
    )
  )
  (export (;2;) "wasi:http/incoming-handler@0.2.0" (instance 1))
)

@alexcrichton
Copy link
Copy Markdown
Member

I think the difference between binaries is panic=abort as the wasmtime executable has that set in CI which is probably what causes an abort.

For the test here could the output of finish() be inspected to ensure that "panicked" doesn't show up? Or basically assert that it has the expected output? (ideally empty or just a warning or similar)

abrown and others added 2 commits February 22, 2025 01:54
…ytecodealliance#10260)

* x64: Use priority overlap in new instruction lowerings

Use overlapping priorities when the only difference is in the type being
matched on, and otherwise use priorities to disambiguate the arms of
`GprMemImm` and the various possibilities of extraction.

* x64: ensure 8-bit sign extensions have higher priorities

In cases where an 8-bit immediate is used, x64 can emit a shorter
encoding and rely on the CPU to sign extend it. Several Cranelift tests
rely on this (as they should--this improves code size). The previous
commit breaks the previous priorities; this change restores them,
ensuring we use the smallest encoding when possible.

* x64: remove old emission replaced by new assembler

We expect the new assembler rules to prevent us from reaching the old
emission rules. This change removes the old rules completely.

* x64: re-prioritize based review, add line breaks

* review: remove `is_mem` extractor for now

---------

Co-authored-by: Alex Crichton <alex@alexcrichton.com>
primoly and others added 2 commits February 22, 2025 17:30
…ytecodealliance#10201)

* winch(aarch64): Correct treatment for stores and other trapping ops

This commit is one more in the series of executing spec tests for
aarch64.

It's mostly a small follow-up to bytecodealliance#10146,
in which I omitted contextualizing the memory flags for stores as well
as ensuring that the SP is aligned when emitting other trapping
instructions like `checked_uadd`.

* Add note around why SP alignment is needed in `checked_uadd`
@alexcrichton alexcrichton added this pull request to the merge queue Feb 24, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 24, 2025
alexcrichton and others added 6 commits February 24, 2025 18:53
For the error from `handle_request` use `e.context(...)` instead of
stringifying `e` into a message. Additionally when logging a guest error
use `:?` instead of `:#?` to give a more standard `anyhow` rendering of
the error.
* Upgrade Windows builder to `windows-2025`

This is an attempt to address bytecodealliance#10289 and unblock the upgrade of Wasmtime
in the wasmtime-go bindings. Honestly I'm lost in the number of MinGW
bugs we're dodging at this point. Regardless though this is something
that will need to be done at some point anyway and theoretically
shouldn't cause any other regressions, so I figured I might as well go
ahead and do this and hopefully fix some MinGW issues while I'm at it.

* Try a new way of getting windows cpu information

prtest:full

* Another attempt
@alexcrichton
Copy link
Copy Markdown
Member

@primoly would you like some help in debugging the CI failure?

@primoly primoly requested review from a team as code owners March 12, 2025 17:13
@primoly primoly requested review from fitzgen and removed request for a team March 12, 2025 17:13
@primoly
Copy link
Copy Markdown
Contributor Author

primoly commented Mar 12, 2025

I think I just broke the PR. I’ll open a new one.

I don’t understand how Git works, sorry ._.

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 this pull request may close these issues.

9 participants