Skip to content

Certain ascii characters crash WASM when received from server fn #2377

Closed
@jollygreenlaser

Description

@jollygreenlaser

EDIT: Current fix is to revert to nightly-2024-02-14: rustup default nightly-2024-02-14, may need to rustup target add wasm32-unknown-unknown again and if using cranelift, rustup component add rustc-codegen-cranelift-preview --toolchain nightly-2024-02-14. If using one, eg as done by default with cargo-leptos, update the rust-toolchain.toml file as well.


Describe the bug

Latest nightly breaks receiving certain characters from a server function, showing a dmalloc error. For me, it was en dash () and likely includes others. Unclear what caused this to suddenly break or what the true origin is.

This happens either upon navigating to the page with the server function call or during hydration when refreshing on that page.

This is very annoying for anything that has to display user entered data, eg profile bios.

Luckily the current workaround is pretty simple, just use this util all over the place:

pub fn clean_ascii(v: &String) -> String {
    v.chars()
        .filter(|c| *c <= '~')
        .collect::<String>()
}

This started happening after upgrading my nightly from late January. Due to testing a separate bug I've been able to repro this bug on 0.6.5, 0.6.6 and the tip of main version I'm on. I have a deployed 0.6.5, late January nightly version without this issue.

It feels very likely that the issue is in a dependency rather than Leptos proper. However, I've not been able to track this down at all despite a lot of effort and I'm guessing others will start to hit it too.

Leptos Dependencies

$ rustup -V
rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.78.0-nightly (fc3800f65 2024-02-26)`
[patch.crates-io]
leptos = { git = "https://github.com/leptos-rs/leptos.git", rev = "6d6019b956c81b2ec86e3aab7dd0e93db54dca3e" }
leptos_meta = { git = "https://github.com/leptos-rs/leptos.git", rev = "6d6019b956c81b2ec86e3aab7dd0e93db54dca3e" }
leptos_router = { git = "https://github.com/leptos-rs/leptos.git", rev = "6d6019b956c81b2ec86e3aab7dd0e93db54dca3e" }
leptos_axum = { git = "https://github.com/leptos-rs/leptos.git", rev = "6d6019b956c81b2ec86e3aab7dd0e93db54dca3e" }

https://github.com/leptos-rs/leptos/tree/6d6019b956c81b2ec86e3aab7dd0e93db54dca3e

Screenshot:

Screenshot 2024-02-27 at 10 21 12 PM

Text:

panicked at /rust/deps/dlmalloc-0.2.5/src/dlmalloc.rs:1182:13:
assertion failed: psize <= size + max_overhead

Stack:

Error
    at imports.wbg.__wbg_new_abda76e883ba8a5f (http://172.91.146.59:3000/pkg/local.js:530:13)
    at clepticle.wasm.console_error_panic_hook::hook::h8eb889a93dddf01a (http://172.91.146.59:3000/pkg/local.wasm:wasm-function[3411]:0x103d005)
    at clepticle.wasm.core::ops::function::Fn::call::hdb33dbd3bd9e95b1 (http://172.91.146.59:3000/pkg/local.wasm:wasm-function[15663]:0x130db10)
    at clepticle.wasm.std::panicking::rust_panic_with_hook::h8e9923a1fd637d6a (http://172.91.146.59:3000/pkg/local.wasm:wasm-function[8913]:0x123fd15)
    at clepticle.wasm.std::panicking::begin_panic_handler::{{closure}}::h6dea320ce1182e58 (http://172.91.146.59:3000/pkg/local.wasm:wasm-function[10394]:0x1285d4a)
    at clepticle.wasm.std::sys_common::backtrace::__rust_end_short_backtrace::ha27827269adf0111 (http://172.91.146.59:3000/pkg/local.wasm:wasm-function[21114]:0x134bc43)
    at clepticle.wasm.rust_begin_unwind (http://172.91.146.59:3000/pkg/local.wasm:wasm-function[16307]:0x1317b8b)
    at clepticle.wasm.core::panicking::panic_fmt::h97853b40b106d930 (http://172.91.146.59:3000/pkg/local.wasm:wasm-function[17276]:0x1324e73)
    at clepticle.wasm.core::panicking::panic::h11ea08863e3a8cec (http://172.91.146.59:3000/pkg/local.wasm:wasm-function[15642]:0x130d5b0)
    at clepticle.wasm.__rdl_dealloc (http://172.91.146.59:3000/pkg/local.wasm:wasm-function[13151]:0x12dd02e)
Uncaught (in promise) RuntimeError: unreachable
    at clepticle.wasm.__rust_start_panic (local.wasm:0x134c4c4)
    at clepticle.wasm.rust_panic (local.wasm:0x134abb1)
    at clepticle.wasm.std::panicking::rust_panic_with_hook::h8e9923a1fd637d6a (local.wasm:0x123fd42)
    at clepticle.wasm.std::panicking::begin_panic_handler::{{closure}}::h6dea320ce1182e58 (local.wasm:0x1285d4a)
    at clepticle.wasm.std::sys_common::backtrace::__rust_end_short_backtrace::ha27827269adf0111 (local.wasm:0x134bc43)
    at clepticle.wasm.rust_begin_unwind (local.wasm:0x1317b8b)
    at clepticle.wasm.core::panicking::panic_fmt::h97853b40b106d930 (local.wasm:0x1324e73)
    at clepticle.wasm.core::panicking::panic::h11ea08863e3a8cec (local.wasm:0x130d5b0)
    at clepticle.wasm.__rdl_dealloc (local.wasm:0x12dd02e)
    at clepticle.wasm.__rust_dealloc (local.wasm:0x134a953)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions