bytecodealliance / ComponentizeJS

JS -> WebAssembly Component
Apache License 2.0
241 stars 32 forks source link

Panic in `Bindgen::iter_resources` #157

Open maxbrunsfeld opened 1 week ago

maxbrunsfeld commented 1 week ago

I'm seeing a panic when trying to use ComponentizeJS to create a wasm component that implements the Zed editor extension interface, for which the wit can be found here.

Repro

Output

thread '<unnamed>' panicked at crates/spidermonkey-embedding-splicer/src/bindgen.rs:760:51:
no entry found for key
stack backtrace:
wasm://wasm/spidermonkey_embedding_splicer.wasm-011d1aba:1

RuntimeError: unreachable
    at spidermonkey_embedding_splicer.wasm.__rust_start_panic (wasm://wasm/spidermonkey_embedding_splicer.wasm-011d1aba:wasm-function[6229]:0x35bd49)
    at spidermonkey_embedding_splicer.wasm.rust_panic (wasm://wasm/spidermonkey_embedding_splicer.wasm-011d1aba:wasm-function[6221]:0x35b86e)
    at spidermonkey_embedding_splicer.wasm._ZN3std9panicking20rust_panic_with_hook17h50e657195af0239cE (wasm://wasm/spidermonkey_embedding_splicer.wasm-011d1aba:wasm-function[6220]:0x35b624)
    at spidermonkey_embedding_splicer.wasm._ZN3std9panicking19begin_panic_handler28_$u7b$$u7b$closure$u7d$$u7d$17h0187e6969a85aab0E (wasm://wasm/spidermonkey_embedding_splicer.wasm-011d1aba:wasm-function[6208]:0x35aa46)
    at spidermonkey_embedding_splicer.wasm._ZN3std10sys_common9backtrace26__rust_end_short_backtrace17h575fb82445d56667E (wasm://wasm/spidermonkey_embedding_splicer.wasm-011d1aba:wasm-function[6207]:0x35a9ad)
    at spidermonkey_embedding_splicer.wasm.rust_begin_unwind (wasm://wasm/spidermonkey_embedding_splicer.wasm-011d1aba:wasm-function[6215]:0x35b1bc)
    at spidermonkey_embedding_splicer.wasm._ZN4core9panicking9panic_fmt17ha6764f2272b7fb95E (wasm://wasm/spidermonkey_embedding_splicer.wasm-011d1aba:wasm-function[6367]:0x3698f8)
    at spidermonkey_embedding_splicer.wasm._ZN4core6option13expect_failed17h4bbb25fdd9d02fc5E (wasm://wasm/spidermonkey_embedding_splicer.wasm-011d1aba:wasm-function[6421]:0x3715c8)
    at spidermonkey_embedding_splicer.wasm._ZN30spidermonkey_embedding_splicer7bindgen9JsBindgen14iter_resources17hcd80ff6d1cdce189E (wasm://wasm/spidermonkey_embedding_splicer.wasm-011d1aba:wasm-function[51]:0x15eea)
    at spidermonkey_embedding_splicer.wasm._ZN30spidermonkey_embedding_splicer7bindgen9JsBindgen7bindgen17h10a3c146406db85bE (wasm://wasm/spidermonkey_embedding_splicer.wasm-011d1aba:wasm-function[50]:0x1536e)
guybedford commented 1 week ago

Thanks for posting, top-level resource additions were a later addition which are not yet supported here in ComponentizeJS and Jco.

I just did a quick verification of your test case and can confirm that's the issue you're seeing.

I've run out of time for this week, but here's a quick WIP to see how much work it would take - https://github.com/bytecodealliance/ComponentizeJS/pull/158.

It looks like this might be getting something to build pending getting the tests verifying the behaviours.

guybedford commented 15 hours ago

Finally got this one resolved in https://github.com/bytecodealliance/ComponentizeJS/pull/158.

There may still be bugs, please do post back if you hit anything else.