dfinity / ic-wasm

A collection of libraries and tools for transforming Wasm canisters running on the Internet Computer
Apache License 2.0
34 stars 5 forks source link

Add check to prevent size increase in embedded actors from corrupting data section #43

Closed kentosugama closed 1 year ago

kentosugama commented 1 year ago

When optimizations increase the size of the embedded actor classes and they are written back into the data section, the data section is corrupted.

This PR adds a check to only write back actors whose wasm size did not increase during optimization.

kentosugama commented 1 year ago

If the id changes, I'm assuming every reference to it in the code needs to reflect the change as well?

For what it's worth, there seems to be a way to delete and add data segments through walrus (https://docs.rs/walrus/latest/walrus/struct.ModuleData.html).

Also, Luc was the one who ran into this bug (and I believe Claudio had warned me about it in the past)