You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Wasmer runtime panics with metering middleware #183
This issue may be a consequence of how fp-bindgen is design vs. a real bug, but I figured may as well report it here.
Wasmer's metering middleware allows you to assign a point cost to different wasm operators, specify an initial point balance for an instance, and then error when the balance is exhausted. This functionality is useful for blockchains or other environments that want to limit resources spent during the execution of some exported function.
I was playing around with the functionality and noticed that instead of erroring when an instance's metering points are exhausted, fp-bindgen just panics.
When you run the primitives test, you'll notice a panic from EXC_BAD_INSTRUCTION (code=1, subcode=0xd4a00000) that happens in the exported init function (specifically at function.call()?:
Thanks, this is a very well-written request! Indeed, middlewares are not currently supported, but based off this report, I think we can create an improvement to support them. Just from the looks of it, it seems it would require two things on our part:
Expose an API in the generated runtime so that callers can specify their middlewares without the need for forking
More resilient error handling on our part, so that middleware errors don't cause crashes inside the bindings
I cannot promise when we'll get to this, but it seems to be a worthwhile improvement. If you want to work on this yourself, we would welcome a PR for this 👍
Hey @arendjr, thanks for the reply. I did do some digging but never got to the bottom of the issue. I think it's related to my usage of async functions over the bridge.
I ended up building a bridge based on the architecture in https://github.com/CosmWasm/cosmwasm. I was able to get metering working there and gave me a bit more flexibility overall. I will definitely keep an eye on this project though. Thank you for the help!
Activity
arendjr commentedon Feb 20, 2023
Thanks, this is a very well-written request! Indeed, middlewares are not currently supported, but based off this report, I think we can create an improvement to support them. Just from the looks of it, it seems it would require two things on our part:
I cannot promise when we'll get to this, but it seems to be a worthwhile improvement. If you want to work on this yourself, we would welcome a PR for this 👍
sanderpick commentedon Mar 18, 2023
Hey @arendjr, thanks for the reply. I did do some digging but never got to the bottom of the issue. I think it's related to my usage of async functions over the bridge.
I ended up building a bridge based on the architecture in https://github.com/CosmWasm/cosmwasm. I was able to get metering working there and gave me a bit more flexibility overall. I will definitely keep an eye on this project though. Thank you for the help!