Skip to content

Crashes in wasm with wgpu #19

@stefnotch

Description

@stefnotch

I wanted to use ArcShift in a wasm wgpu project, but quickly ran into

panicked at /rust/deps/dlmalloc-0.2.9/src/dlmalloc.rs:1200:9:
assertion failed: psize >= size + min_overhead

After some trial and error, I managed to get this code sample to reliable reproduce the crash. I do apologize for not proving a nice and easy reproduction project.

// Add a dependency on wgpu
// Compile to wasm32-unknown-unknown and run in the browser
struct Cute {
    pub texture: Option<wgpu::Texture>,
}


let foo = arcshift::ArcShift::new(Cute { texture: None });
log::info!("{:?}", foo.shared_non_reloading_get().texture.is_some());
std::mem::drop(foo);
web.js:865 panicked at /rust/deps/dlmalloc-0.2.9/src/dlmalloc.rs:1200:9:
assertion failed: psize >= size + min_overhead

Stack:

Error
    at http://localhost:5173/math3render/pkg/web.js?t=1754000352017:1383:21
    at logError (http://localhost:5173/math3render/pkg/web.js?t=1754000352017:5:18)
    at imports.wbg.__wbg_new_8a6f238a6ece86ea (http://localhost:5173/math3render/pkg/web.js?t=1754000352017:1382:66)
    at web.wasm.__wbg_new_8a6f238a6ece86ea externref shim (http://localhost:5173/math3render/pkg/web_bg.wasm:wasm-function[20266]:0x59bd5e)
    at web.wasm.console_error_panic_hook::Error::new::hada06d99acebcd14 (http://localhost:5173/math3render/pkg/web_bg.wasm:wasm-function[12174]:0x537454)
    at web.wasm.console_error_panic_hook::hook_impl::h5b4d8e6b4dee1256 (http://localhost:5173/math3render/pkg/web_bg.wasm:wasm-function[3529]:0x38f8c6)
    at web.wasm.console_error_panic_hook::hook::h11056c8a1349b2bb (http://localhost:5173/math3render/pkg/web_bg.wasm:wasm-function[22902]:0x5a5133)
    at web.wasm.core::ops::function::Fn::call::hfd229e704bdb1977 (http://localhost:5173/math3render/pkg/web_bg.wasm:wasm-function[14908]:0x56dc3d)
    at web.wasm.std::panicking::rust_panic_with_hook::h64448a2d0bc088de (http://localhost:5173/math3render/pkg/web_bg.wasm:wasm-function[7239]:0x48a9f7)
    at web.wasm.std::panicking::begin_panic_handler::{{closure}}::h637c06d29d466f9d (http://localhost:5173/math3render/pkg/web_bg.wasm:wasm-function[9191]:0x4dc41d)


(anonymous) | @ | web.js:865
-- | -- | --
  | logError | @ | web.js:5
  | imports.wbg.__wbg_error_7534b8e9a36f1ab4 | @ | web.js:859
  | $console_error_panic_hook::error::hb7cc8af0ddc3367f | @ | web_bg.wasm:0x532a08
  | $console_error_panic_hook::hook_impl::h5b4d8e6b4dee1256 | @ | web_bg.wasm:0x38f9c6
  | $console_error_panic_hook::hook::h11056c8a1349b2bb | @ | web_bg.wasm:0x5a5133
  | $core::ops::function::Fn::call::hfd229e704bdb1977 | @ | web_bg.wasm:0x56dc3d
  | $std::panicking::rust_panic_with_hook::h64448a2d0bc088de | @ | web_bg.wasm:0x48a9f7
  | $std::panicking::begin_panic_handler::{{closure}}::h637c06d29d466f9d | @ | web_bg.wasm:0x4dc41d
  | $std::sys::backtrace::__rust_end_short_backtrace::hd60e70d6c2b2c845 | @ | web_bg.wasm:0x5a8648
  | $__rustc[507298ddafb0ef2f]::rust_begin_unwind | @ | web_bg.wasm:0x57deaa
  | $core::panicking::panic_fmt::h8f223baba8ef14da | @ | web_bg.wasm:0x57ded7
  | $core::panicking::panic::h8d9c1055bcc34005 | @ | web_bg.wasm:0x56c8cb
  | $__rustc[507298ddafb0ef2f]::__rdl_dealloc | @ | web_bg.wasm:0x540ebe
  | $__rustc[507298ddafb0ef2f]::__rust_dealloc | @ | web_bg.wasm:0x59ea8a
  | $alloc::alloc::dealloc::h1a5c1d5233729119 | @ | web_bg.wasm:0x55a2d1
  | $arcshift::do_dealloc::h0082ef400e00c4ce | @ | web_bg.wasm:0x53eb71
  | $arcshift::raw_deallocate_node::hd711ee20e52934ff | @ | web_bg.wasm:0x59759f
  | $arcshift::do_drop_weak::hf561d418be432e4d | @ | web_bg.wasm:0x2e91bf
  | $arcshift::do_drop_strong::hc9245ac6e682b1dd | @ | web_bg.wasm:0x4c80c8
  | $<arcshift::ArcShift<T> as core::ops::drop::Drop>::drop::he5fb60df941af2ea | @ | web_bg.wasm:0x42933d
  | $core::ptr::drop_in_place<arcshift::ArcShift<render::application::Cute>>::haf7b5fdeacffd6d4 | @ | web_bg.wasm:0x5a5010
  | $core::mem::drop::h0ad95fbe9193aa67 | @ | web_bg.wasm:0x560a73
  | $render::application::Application::new::{{closure}}::h872c4e74b51e3e1c | @ | web_bg.wasm:0x10cc7c
  | $web::application::WasmApplication::new::{{closure}}::{{closure}}::h9730dde117ff43f4 | @ | web_bg.wasm:0x1a4929
  | $wasm_bindgen_futures::task::singlethread::Task::run::h6ba2fa0cbd9c092e | @ | web_bg.wasm:0x33f153
  | $wasm_bindgen_futures::queue::QueueState::run_all::h217e77ff646e6738 | @ | web_bg.wasm:0x31863d
  | $wasm_bindgen_futures::queue::Queue::new::{{closure}}::h297f57fb2721f99d | @ | web_bg.wasm:0x5442d7
  | $<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h1d43746d7c6b87d9 | @ | web_bg.wasm:0x504bfa
  | $closure1251 externref shim | @ | web_bg.wasm:0x599779
  | __wbg_adapter_62 | @ | web.js:320
  | real

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions