Skip to content
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

Fix failing assertion in compose encoding #1293

Conversation

fibonacci1729
Copy link
Contributor

This assertion was expanded while addressing the final feedback in the PR to Implement Resources in Compose.

Currently, with the expanded assertion, when composing a component that exports wasi:http/incoming-handler with another that imports it, the assertion fails with:

thread 'main' panicked at 'assertion failed: prev.is_none() ||\n (matches!(id, ComponentAnyTypeId :: Resource(_)) && prev == Some(value))

And specifically the condition that fails prev == Some(value) where, in this particular instance, prev=Some(5) != value=6.

I'm not entirely sure of the "why" here but have confirmed that reverting to the old assertion seems to "correct" this.

Signed-off-by: Brian H <brian.hardock@fermyon.com>
@fibonacci1729
Copy link
Contributor Author

cc @alexcrichton @dicej

@alexcrichton
Copy link
Member

Hm interesting! Before merging I think I'd like to dig in a bit more here to see if I can't bottom this out a bit more. Do you have a reproduction I could poke around at to trigger this?

@fibonacci1729
Copy link
Contributor Author

@alexcrichton Testing with: https://github.com/fermyon/http-auth-middleware/

Using: cargo-component-component 0.4.0 (821c329 2023-10-27 wasi:2da78ca)

To reproduce:

cargo component build --manifest-path github-oauth/Cargo.toml --release
cd example && ./build.sh

alexcrichton added a commit to alexcrichton/wasm-tools that referenced this pull request Nov 16, 2023
This commit goes back to some comments I had on bytecodealliance#1261 where an assertion
was loosened there. My requested modifications ended up spawning bytecodealliance#1293
so I've taken another look at this assertion to try to determine what's
going on. I've managed to re-tighten the assertion while fixing the
situation coming up in bytecodealliance#1293 as well.

The fix in this PR is to restructure the `_ty` method to iterate over
the alias chain once and only define the type at the very end which
should fix this for resources. I'm still having a difficult time fully
explaining everything involved here but this feels like a more
appropriate structure for the code at this time anyway.
@alexcrichton
Copy link
Member

Ok thanks! I came up with #1297 which ends up tightening the assertion here though some slight restructuring of the code. I've tested that the example you gave gets composed with that change as well. I suspect there may still be an issue lurking but I don't know of any off the top of my head at this time

@fibonacci1729
Copy link
Contributor Author

Closing in favor of #1297

alexcrichton added a commit that referenced this pull request Nov 16, 2023
This commit goes back to some comments I had on #1261 where an assertion
was loosened there. My requested modifications ended up spawning #1293
so I've taken another look at this assertion to try to determine what's
going on. I've managed to re-tighten the assertion while fixing the
situation coming up in #1293 as well.

The fix in this PR is to restructure the `_ty` method to iterate over
the alias chain once and only define the type at the very end which
should fix this for resources. I'm still having a difficult time fully
explaining everything involved here but this feels like a more
appropriate structure for the code at this time anyway.
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.

2 participants