TOPLLab / WARDuino

📟 A dynamic WebAssembly VM for embedded systems
https://topllab.github.io/WARDuino/
Mozilla Public License 2.0
80 stars 7 forks source link

🚑 Hotfix #251 #252

Closed tolauwae closed 1 month ago

MaartenS11 commented 1 month ago

This fix mostly works but for some reason it causes console spam with some programs. This console spam disappears once a character is sent over serial. If I add a tiny delay this console spam doesn't appear at all. Delay causes a yield but also allows tasks with a priority lower than the current task to take over but this seems like a very strange fix.

    Serial.println("\nFree heap:");
    Serial.println(ESP.getFreeHeap());

    delay(1);

    wac->run_module(m);
tolauwae commented 1 month ago

This fix mostly works but for some reason it causes console spam with some programs.

@MaartenS11 can you give an example program to reproduce the bug?

MaartenS11 commented 1 month ago

This fix mostly works but for some reason it causes console spam with some programs.

@MaartenS11 can you give an example program to reproduce the bug?

I got the console spam when just running blink (from tutorials/wat/main/blink.wat) without the tiny delay.

tolauwae commented 1 month ago

I got the console spam when just running blink (from tutorials/wat/main/blink.wat) without the tiny delay.

The blink example works on my devices. Can you upload the .wasm binary here? And with which command did you generate it?

MaartenS11 commented 1 month ago

The blink example works on my devices. Can you upload the .wasm binary here? And with which command did you generate it?

Hmm strange, I use this (zip of wasm binary) exact wasm file. I use our custom wat2wasm binary to compile it with the options --no-canonicalize-leb128s --disable-bulk-memory --debug-names -v.

Ok, I actually just tried flashing this exact branch instead of one of my custom branches with the same fix and somehow that resolves the issue. It appears my custom changes, in this case reversible primitives somehow makes the console spam happen. Reversible primitives don't really do anything (besides storing two extra pointers when installing the primitives) if the program is just executing normally so I don't really see how that could have an effect.

This seems to be a rather strange, unexplainable issue. Considering that it works perfectly fine on main I would say we should just merge this.