dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

wasm_bindgen Closure breaks hot-patching

Open FuZzledd opened this issue 1 year ago • 0 comments

Problem

When a Closure from wasm_bindgen is used, hot-patching results in Closure::wrap running into a __wbindgen_describe, which gives a Uncaught RuntimeError: indirect call to null

Steps To Reproduce

Steps to reproduce the behavior:

  • Add the following component
#[component]
pub fn Main() -> Element {
    let closure = wasm_bindgen::closure::Closure::<dyn FnMut(web_sys::MouseEvent)>::new(
        move |event: web_sys::MouseEvent| {},/
    );

    rsx! {}
}
  • Make a change to trigger a hot-patch

Screenshots

Image
Full error

Uncaught RuntimeError: indirect call to null
test.js line 6874 > WebAssembly.instantiate:29073:1
    __wbindgen_describe http://127.0.0.1:8080/wasm/test.js line 6874 > WebAssembly.instantiate:29073
    _ZN12wasm_bindgen8describe6inform17h1bb4f2090cfdaab1E http://127.0.0.1:8080/wasm/test.js line 6874 > WebAssembly.instantiate:27171
    _ZN12wasm_bindgen4__rt8wbg_cast17breaks_if_inlined17h3a354278318b38cdE http://127.0.0.1:8080/wasm/test.js line 6874 > WebAssembly.instantiate:21552
    _ZN12wasm_bindgen4__rt8wbg_cast17h1ee356bf016bf8ecE http://127.0.0.1:8080/wasm/test.js line 6874 > WebAssembly.instantiate:20565
    _ZN12wasm_bindgen7closure16Closure$LT$T$GT$4wrap17hf3bba4aa0b877248E http://127.0.0.1:8080/wasm/test.js line 6874 > WebAssembly.instantiate:25999
    _ZN12wasm_bindgen7closure16Closure$LT$T$GT$3new17head2f052b8e22f73E http://127.0.0.1:8080/wasm/test.js line 6874 > WebAssembly.instantiate:25706
    _ZN4test4Main17h520b4368a981544dE http://127.0.0.1:8080/wasm/test.js line 6874 > WebAssembly.instantiate:11255
    Fn0Marker$GT$$GT$11call_as_ptr17h86ba41e9852c67a0E http://127.0.0.1:8080/wasm/test_bg.wasm:4177884
    _ZN9subsecond22HotFn$LT$A$C$M$C$F$GT$8try_call17h4dafbd6857b2d131E http://127.0.0.1:8080/wasm/test_bg.wasm:3129639
    _ZN9subsecond22HotFn$LT$A$C$M$C$F$GT$4call17h28c85c1a7e5ffed1E http://127.0.0.1:8080/wasm/test_bg.wasm:4068382
    EmptyMarker$GT$$GT$7rebuild17hf4dbf25ac2e813d5E http://127.0.0.1:8080/wasm/test_bg.wasm:5903137
    AnyProps$GT$6render28_$u7b$$u7b$closure$u7d$$u7d$17ha67064978535f355E http://127.0.0.1:8080/wasm/test_bg.wasm:5862225
    _ZN4core3ops8function6FnOnce9call_once17h85dc25479ad40701E http://127.0.0.1:8080/wasm/test_bg.wasm:6046261
    FnOnce$LT$$LP$$RP$$GT$$GT$9call_once17h12eda38d4a839addE http://127.0.0.1:8080/wasm/test_bg.wasm:6151107
    _ZN3std9panicking12catch_unwind7do_call17h50306a9f64414bf9E http://127.0.0.1:8080/wasm/test_bg.wasm:4844877
    _ZN3std5panic12catch_unwind17h2414f0cf65084511E http://127.0.0.1:8080/wasm/test_bg.wasm:4176943
    AnyProps$GT$6render17h31fda2cb4fe17098E http://127.0.0.1:8080/wasm/test_bg.wasm:5632982
    VirtualDom$GT$9run_scope28_$u7b$$u7b$closure$u7d$$u7d$28_$u7b$$u7b$closure$u7d$$u7d$28_$u7b$$u7b$closure$u7d$$u7d$17h13d9976208914be5E http://127.0.0.1:8080/wasm/test_bg.wasm:2498499
    _ZN11dioxus_core16reactive_context15ReactiveContext6run_in17h8d1ef0e34b9df72aE http://127.0.0.1:8080/wasm/test_bg.wasm:5789872
    _ZN11dioxus_core16reactive_context15ReactiveContext16reset_and_run_in17h3d9faece7ca40b0aE http://127.0.0.1:8080/wasm/test_bg.wasm:6017703
    VirtualDom$GT$9run_scope28_$u7b$$u7b$closure$u7d$$u7d$28_$u7b$$u7b$closure$u7d$$u7d$17h032ae0b277144482E http://127.0.0.1:8080/wasm/test_bg.wasm:5277485
    _ZN7tracing4span4Span8in_scope17h7fcc17bc7b5984dbE http://127.0.0.1:8080/wasm/test_bg.wasm:4902261
    VirtualDom$GT$9run_scope28_$u7b$$u7b$closure$u7d$$u7d$17h530a9464561f9ebbE http://127.0.0.1:8080/wasm/test_bg.wasm:1286633
    _ZN11dioxus_core7runtime7Runtime19with_scope_on_stack17h6568e5e26cb0e0feE http://127.0.0.1:8080/wasm/test_bg.wasm:5632483
    VirtualDom$GT$9run_scope17h7b318ea2abd92681E http://127.0.0.1:8080/wasm/test_bg.wasm:1321609
    VirtualDom$GT$18run_and_diff_scope17ha657de6df9d64ee5E http://127.0.0.1:8080/wasm/test_bg.wasm:4781505
    _ZN11dioxus_core11virtual_dom10VirtualDom16render_immediate28_$u7b$$u7b$closure$u7d$$u7d$17he7e33bb7ff81733eE http://127.0.0.1:8080/wasm/test_bg.wasm:6286248
    _ZN11dioxus_core7runtime7Runtime15while_rendering17heac1d640a3a603fdE http://127.0.0.1:8080/wasm/test_bg.wasm:5673130
    _ZN11dioxus_core11virtual_dom10VirtualDom16render_immediate17h16b6e663ce73390aE http://127.0.0.1:8080/wasm/test_bg.wasm:1270720
    _ZN10dioxus_web3run28_$u7b$$u7b$closure$u7d$$u7d$17h7d35ab5338c21781E http://127.0.0.1:8080/wasm/test_bg.wasm:651329
    _ZN10dioxus_web6launch18launch_virtual_dom28_$u7b$$u7b$closure$u7d$$u7d$17haa8a2a5d88789dbcE http://127.0.0.1:8080/wasm/test_bg.wasm:2820716
    _ZN20wasm_bindgen_futures4task12singlethread5Inner8is_ready17h084745aff23c5e1aE http://127.0.0.1:8080/wasm/test_bg.wasm:4823947
    _ZN20wasm_bindgen_futures4task12singlethread4Task3run17h474529d6e5fd9cd9E http://127.0.0.1:8080/wasm/test_bg.wasm:3283867
    _ZN20wasm_bindgen_futures5queue10QueueState7run_all17he47934e5463895bdE http://127.0.0.1:8080/wasm/test_bg.wasm:3172694
    _ZN20wasm_bindgen_futures5queue5Queue3new28_$u7b$$u7b$closure$u7d$$u7d$17hea3250374638ecd6E http://127.0.0.1:8080/wasm/test_bg.wasm:5709309
    _ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E http://127.0.0.1:8080/wasm/test_bg.wasm:5026226
    test.wasm._ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E externref shim http://127.0.0.1:8080/wasm/test_bg.wasm:6312509
    _ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E http://127.0.0.1:8080/wasm/test.js:431
    real http://127.0.0.1:8080/wasm/test.js:412
    (Async: VoidFunction)
    __wbg_queueMicrotask_9d76cacb20c84d58 http://127.0.0.1:8080/wasm/test.js:10478
    logError http://127.0.0.1:8080/wasm/test.js:13
    __wbg_queueMicrotask_9d76cacb20c84d58 http://127.0.0.1:8080/wasm/test.js:10477
    test.wasm._ZN20wasm_bindgen_futures5queue14queueMicrotask37__wbg_queueMicrotask_9d76cacb20c84d5817hb9a7072492d8baa0E externref shim http://127.0.0.1:8080/wasm/test_bg.wasm:6364800
    _ZN20wasm_bindgen_futures5queue14queueMicrotask17h302f411334fc8e42E http://127.0.0.1:8080/wasm/test_bg.wasm:5745855
    _ZN20wasm_bindgen_futures5queue5Queue13schedule_task17h7f6bcce687580f1aE http://127.0.0.1:8080/wasm/test_bg.wasm:4104995
    _ZN20wasm_bindgen_futures5queue5Queue9push_task17he59592a5c9e4c391E http://127.0.0.1:8080/wasm/test_bg.wasm:6025510
    _ZN20wasm_bindgen_futures4task12singlethread4Task10force_wake28_$u7b$$u7b$closure$u7d$$u7d$17h9c56fa9b15ffdb7fE http://127.0.0.1:8080/wasm/test_bg.wasm:6025464
    _ZN20wasm_bindgen_futures5queue5Queue4with17h25066676fe8626dbE http://127.0.0.1:8080/wasm/test_bg.wasm:6106823
    _ZN20wasm_bindgen_futures4task12singlethread4Task10force_wake17h61087aad7205d14fE http://127.0.0.1:8080/wasm/test_bg.wasm:6203175
    _ZN20wasm_bindgen_futures4task12singlethread4Task4wake17hd60a326e8cd8186fE http://127.0.0.1:8080/wasm/test_bg.wasm:5400877
    _ZN20wasm_bindgen_futures4task12singlethread4Task14into_raw_waker8raw_wake17ha0559c2485d5830cE http://127.0.0.1:8080/wasm/test_bg.wasm:5955364
    _ZN4core4task4wake5Waker4wake17h2c44dab15c514cbfE http://127.0.0.1:8080/wasm/test_bg.wasm:5488383
    _ZN12futures_core4task10__internal12atomic_waker11AtomicWaker4wake17h25953fc7be280aa7E http://127.0.0.1:8080/wasm/test_bg.wasm:5028621
    _ZN15futures_channel4mpsc29UnboundedSenderInner$LT$T$GT$21queue_push_and_signal17hb487eaa28a681262E http://127.0.0.1:8080/wasm/test_bg.wasm:5922475
    _ZN15futures_channel4mpsc24UnboundedSender$LT$T$GT$10do_send_nb17h38b6693d7a06c3bcE http://127.0.0.1:8080/wasm/test_bg.wasm:4015425
    _ZN15futures_channel4mpsc24UnboundedSender$LT$T$GT$14unbounded_send17hb9e2b73ddc44ec23E http://127.0.0.1:8080/wasm/test_bg.wasm:6092135
    _ZN11dioxus_core11virtual_dom10VirtualDom26register_subsecond_handler28_$u7b$$u7b$closure$u7d$$u7d$17h733a47e1b9fb8a45E http://127.0.0.1:8080/wasm/test_bg.wasm:5923478
    _ZN9subsecond12commit_patch28_$u7b$$u7b$closure$u7d$$u7d$17hbbf33733100cf9d6E http://127.0.0.1:8080/wasm/test_bg.wasm:5735231
    Iterator$GT$8for_each17h1179819e25d1af96E http://127.0.0.1:8080/wasm/test_bg.wasm:5141034
    _ZN9subsecond12commit_patch17h7028f27a984e875bE http://127.0.0.1:8080/wasm/test_bg.wasm:3066447
    _ZN9subsecond11apply_patch28_$u7b$$u7b$closure$u7d$$u7d$17h6c369c39f475d356E http://127.0.0.1:8080/wasm/test_bg.wasm:603422
    _ZN20wasm_bindgen_futures4task12singlethread5Inner8is_ready17h084745aff23c5e1aE http://127.0.0.1:8080/wasm/test_bg.wasm:4823947
    _ZN20wasm_bindgen_futures4task12singlethread4Task3run17h474529d6e5fd9cd9E http://127.0.0.1:8080/wasm/test_bg.wasm:3283867
    _ZN20wasm_bindgen_futures5queue10QueueState7run_all17he47934e5463895bdE http://127.0.0.1:8080/wasm/test_bg.wasm:3172694
    _ZN20wasm_bindgen_futures5queue5Queue3new28_$u7b$$u7b$closure$u7d$$u7d$17hea3250374638ecd6E http://127.0.0.1:8080/wasm/test_bg.wasm:5709309
    _ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E http://127.0.0.1:8080/wasm/test_bg.wasm:5026226
    test.wasm._ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E externref shim http://127.0.0.1:8080/wasm/test_bg.wasm:6312509
    _ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E http://127.0.0.1:8080/wasm/test.js:431
    real http://127.0.0.1:8080/wasm/test.js:412
    (Async: VoidFunction)
    __wbg_queueMicrotask_9d76cacb20c84d58 http://127.0.0.1:8080/wasm/test.js:10478
    logError http://127.0.0.1:8080/wasm/test.js:13
    __wbg_queueMicrotask_9d76cacb20c84d58 http://127.0.0.1:8080/wasm/test.js:10477
    test.wasm._ZN20wasm_bindgen_futures5queue14queueMicrotask37__wbg_queueMicrotask_9d76cacb20c84d5817hb9a7072492d8baa0E externref shim http://127.0.0.1:8080/wasm/test_bg.wasm:6364800
    _ZN20wasm_bindgen_futures5queue14queueMicrotask17h302f411334fc8e42E http://127.0.0.1:8080/wasm/test_bg.wasm:5745855
    _ZN20wasm_bindgen_futures5queue5Queue13schedule_task17h7f6bcce687580f1aE http://127.0.0.1:8080/wasm/test_bg.wasm:4104995
    _ZN20wasm_bindgen_futures5queue5Queue9push_task17he59592a5c9e4c391E http://127.0.0.1:8080/wasm/test_bg.wasm:6025510
    _ZN20wasm_bindgen_futures4task12singlethread4Task10force_wake28_$u7b$$u7b$closure$u7d$$u7d$17h9c56fa9b15ffdb7fE http://127.0.0.1:8080/wasm/test_bg.wasm:6025464
    _ZN20wasm_bindgen_futures5queue5Queue4with17h25066676fe8626dbE http://127.0.0.1:8080/wasm/test_bg.wasm:6106823
    _ZN20wasm_bindgen_futures4task12singlethread4Task10force_wake17h61087aad7205d14fE http://127.0.0.1:8080/wasm/test_bg.wasm:6203175
    _ZN20wasm_bindgen_futures4task12singlethread4Task4wake17hd60a326e8cd8186fE http://127.0.0.1:8080/wasm/test_bg.wasm:5400877
    _ZN20wasm_bindgen_futures4task12singlethread4Task14into_raw_waker8raw_wake17ha0559c2485d5830cE http://127.0.0.1:8080/wasm/test_bg.wasm:5955364
    _ZN4core4task4wake5Waker4wake17hc3add65cdcf2d289E http://127.0.0.1:8080/wasm/test_bg.wasm:5482093
    Promise$GT$$GT$4from6finish17h0157498f5d946b78E http://127.0.0.1:8080/wasm/test_bg.wasm:3333415
    Promise$GT$$GT$4from28_$u7b$$u7b$closure$u7d$$u7d$17h08b20f736370e648E http://127.0.0.1:8080/wasm/test_bg.wasm:5791924
    _ZN4core3ops8function6FnOnce9call_once17he5d8093138741e7bE http://127.0.0.1:8080/wasm/test_bg.wasm:5709106
    FnMut$LT$$LP$A$C$$RP$$GT$$u2b$Output$u20$$u3d$$u20$R$C$A$C$R$GT$$u20$for$u20$T$GT$11into_fn_mut28_$u7b$$u7b$closure$u7d$$u7d$17hc1857cc2ff524cc4E http://127.0.0.1:8080/wasm/test_bg.wasm:5688093
    _ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E http://127.0.0.1:8080/wasm/test_bg.wasm:5026226
    test.wasm._ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E externref shim http://127.0.0.1:8080/wasm/test_bg.wasm:6312509
    _ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E http://127.0.0.1:8080/wasm/test.js:431
    real http://127.0.0.1:8080/wasm/test.js:412
    (Async: promise callback)
    __wbg_then_70d05cf780a18d77 http://127.0.0.1:8080/wasm/test.js:14070
    logError http://127.0.0.1:8080/wasm/test.js:13
    __wbg_then_70d05cf780a18d77 http://127.0.0.1:8080/wasm/test.js:14069
    test.wasm._ZN6js_sys7Promise5then227__wbg_then_70d05cf780a18d7717h0bb588164403932eE externref shim http://127.0.0.1:8080/wasm/test_bg.wasm:6246605
    _ZN6js_sys7Promise5then217h31bd1982c3f073f3E http://127.0.0.1:8080/wasm/test_bg.wasm:4493294
    Promise$GT$$GT$4from17h14fb7bed01f0beefE http://127.0.0.1:8080/wasm/test_bg.wasm:3048574
    _ZN9subsecond11apply_patch28_$u7b$$u7b$closure$u7d$$u7d$17h6c369c39f475d356E http://127.0.0.1:8080/wasm/test_bg.wasm:601817
    _ZN20wasm_bindgen_futures4task12singlethread5Inner8is_ready17h084745aff23c5e1aE http://127.0.0.1:8080/wasm/test_bg.wasm:4823947
    _ZN20wasm_bindgen_futures4task12singlethread4Task3run17h474529d6e5fd9cd9E http://127.0.0.1:8080/wasm/test_bg.wasm:3283867
    _ZN20wasm_bindgen_futures5queue10QueueState7run_all17he47934e5463895bdE http://127.0.0.1:8080/wasm/test_bg.wasm:3172694
    _ZN20wasm_bindgen_futures5queue5Queue3new28_$u7b$$u7b$closure$u7d$$u7d$17hea3250374638ecd6E http://127.0.0.1:8080/wasm/test_bg.wasm:5709309
    _ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E http://127.0.0.1:8080/wasm/test_bg.wasm:5026226
    test.wasm._ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E externref shim http://127.0.0.1:8080/wasm/test_bg.wasm:6312509
    _ZN12wasm_bindgen7convert8closures1_6invoke17hd7085240bd403ba7E http://127.0.0.1:8080/wasm/test.js:431
    real http://127.0.0.1:8080/wasm/test.js:412
    (Async: VoidFunction)
    __wbg_queueMicrotask_9d76cacb20c84d58 http://127.0.0.1:8080/wasm/test.js:10478
    logError http://127.0.0.1:8080/wasm/test.js:13
    __wbg_queueMicrotask_9d76cacb20c84d58 http://127.0.0.1:8080/wasm/test.js:10477
    test.wasm._ZN20wasm_bindgen_futures5queue14queueMicrotask37__wbg_queueMicrotask_9d76cacb20c84d5817hb9a7072492d8baa0E externref shim http://127.0.0.1:8080/wasm/test_bg.wasm:6364800
    _ZN20wasm_bindgen_futures5queue14queueMicrotask17h302f411334fc8e42E http://127.0.0.1:8080/wasm/test_bg.wasm:5745855
    _ZN20wasm_bindgen_futures5queue5Queue13schedule_task17h7f6bcce687580f1aE http://127.0.0.1:8080/wasm/test_bg.wasm:4104995
    _ZN20wasm_bindgen_futures5queue5Queue9push_task17he59592a5c9e4c391E http://127.0.0.1:8080/wasm/test_bg.wasm:6025510
    _ZN20wasm_bindgen_futures4task12singlethread4Task10force_wake28_$u7b$$u7b$closure$u7d$$u7d$17h9c56fa9b15ffdb7fE http://127.0.0.1:8080/wasm/test_bg.wasm:6025464
    _ZN20wasm_bindgen_futures5queue5Queue4with17h25066676fe8626dbE http://127.0.0.1:8080/wasm/test_bg.wasm:6106823
    _ZN20wasm_bindgen_futures4task12singlethread4Task10force_wake17h61087aad7205d14fE http://127.0.0.1:8080/wasm/test_bg.wasm:6203175
    _ZN20wasm_bindgen_futures4task12singlethread4Task4wake17hd60a326e8cd8186fE http://127.0.0.1:8080/wasm/test_bg.wasm:5400877
    _ZN20wasm_bindgen_futures4task12singlethread4Task14into_raw_waker8raw_wake17ha0559c2485d5830cE http://127.0.0.1:8080/wasm/test_bg.wasm:5955364
    _ZN4core4task4wake5Waker4wake17hc3add65cdcf2d289E http://127.0.0.1:8080/wasm/test_bg.wasm:5482093
    Promise$GT$$GT$4from6finish17h0157498f5d946b78E http://127.0.0.1:8080/wasm/test_bg.wasm:3333415
    Promise$GT$$GT$4from28_$u7b$$u7b$closure$u7d$$u7d$17h08b20f736370e648E http://127.0.0.1:8080/wasm/test_bg.wasm:5791924

Environment:

  • Dioxus version: 0.7.1
  • Rust version: rustc 1.92.0-nightly (dc2c3564d 2025-09-29)
  • OS info: CachyOS Linux
  • App platform: web

Questionnaire

I've looked into this a bit myself (and asked on Discord). AFAIK, this very thing should be prevented in the patching process by blacklisting and deleting wasm_bindgen symbols (i.e. here), and I'm not very sure on how to proceed further and debug this.

FuZzledd avatar Nov 22 '25 21:11 FuZzledd