Stream: jco

Topic: How to debug a Error: the `componentize.wizer` function trap


view this post on Zulip kiwibe (Sep 23 2024 at 17:12):

Hey :wave: ,
I'm currently experimenting with jco and I'm trying to import some lib into my js file, which is then bundled with esbuild --format esm all is working fine for "simple" lib. But then when trying more complex one I'm sometimes hit by this problem. Right now I have this one to be precise

Caused by:
    0: error while executing at wasm backtrace:
           0: 0x78705a - <unknown>!<wasm function 9672>
           1: 0x35239f - <unknown>!<wasm function 522>
           2: 0xab1cb - <unknown>!<wasm function 79>
           3: 0x3424ec - <unknown>!<wasm function 498>
           4: 0x66ac8b - <unknown>!<wasm function 4035>
           5: 0x625361 - <unknown>!<wasm function 3385>
           6: 0x42288c - <unknown>!<wasm function 940>
           7: 0x4225d9 - <unknown>!<wasm function 940>
           8: 0x2d00c5 - <unknown>!<wasm function 358>
           9: 0x1fc7d2 - <unknown>!<wasm function 186>
          10: 0x50cf05 - <unknown>!<wasm function 1721>
          11: 0x338556 - <unknown>!<wasm function 485>
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    1: Error: attempted to call an unknown imported function: 'wasi:random/random@0.2.0' 'get-random-u64'

Most of the time is just something not available in wasm which don't work but there the problem is different. So I'd just like to know a bit more on how to read the backtrace to checkout where in the bundle there is a problem so I can try and fix it.

Thanks in advance.

view this post on Zulip kiwibe (Sep 23 2024 at 17:13):

(I've already enabled the
const DEBUG_BINDINGS = true;)

view this post on Zulip Victor Adossi (Sep 25 2024 at 06:01):

Hey @kiwibe it seems like that last message is the one that matters, but it's weird because that function (get-randomu64) is indeed in wasi:random@0.2.0. What version of jco are you using?

A minimal reproduction repo would certainly be helpful, if you can share some more code!

view this post on Zulip kiwibe (Sep 25 2024 at 07:21):

Hey @Victor Adossi I'll try to pull up a repro repo asap, but quick question on the side while I do this how could I know which line in my current JS could cause this error ?

view this post on Zulip Victor Adossi (Sep 25 2024 at 09:46):

So it could actually be any part of your code (or deps) that uses JS randomness functionality (i.e. Math.random()) provided by the preview2 shim for NodeJS.

By default IIRC WASI random should be enabled by default, so you shouldn't have to do anything special for it.

JavaScript toolchain for working with WebAssembly Components - bytecodealliance/jco

view this post on Zulip kiwibe (Sep 25 2024 at 09:49):

Oh perfect thanks I see now where it's calling this I shall be able to put an example, as soon I'm off work I'll try to do it and share it with you thanks !

view this post on Zulip Victor Adossi (Sep 25 2024 at 09:50):

Yeah I'm going to try and see if I can reproduce with a little repo too!

view this post on Zulip Victor Adossi (Sep 25 2024 at 10:30):

Hey @kiwibe I'm not sure it'll help, but just to make sure Math.random was working properly with currently released stuff I made a small example (jco already has a great test suite so I didn't need to but just to have a self contained example you can compare to):

https://github.com/vados-cosmonic/jco-math-random-example

Example of using jco with Math.random. Contribute to vados-cosmonic/jco-math-random-example development by creating an account on GitHub.

view this post on Zulip kiwibe (Oct 03 2024 at 12:55):

Hey sorry about my lag, i'm gonna give you a good reproduction soon but just to give you a bit more info the problem is originating form this line https://github.com/davidbau/seedrandom/blob/released/seedrandom.js#L219-L226

seeded random number generator for Javascript. Contribute to davidbau/seedrandom development by creating an account on GitHub.

view this post on Zulip Victor Adossi (Oct 03 2024 at 13:26):

Thanks for looking into this -- interesting, I wouldn't expect Math.random() to fail, but if the bug is there it should be really easy to reproduce.

As far as trying to get a small repro together, consider using one of the projects in this PR here -- they'll be in examples soon enough!

This commit adds examples to the jco, some of which are/will be referenced from the component-model book (https://component-model.bytecodealliance.org/).

view this post on Zulip kiwibe (Oct 04 2024 at 09:42):

Thanks a lot for being that responsive, I shall finally have more time to dig into that, this w-e but work is taking too much of my time right now.


Last updated: Oct 23 2024 at 20:03 UTC