Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic in dlmalloc after upgrading to Rust 1.78.0 #1389

Open
jtroo opened this issue May 7, 2024 · 4 comments
Open

Panic in dlmalloc after upgrading to Rust 1.78.0 #1389

jtroo opened this issue May 7, 2024 · 4 comments

Comments

@jtroo
Copy link

jtroo commented May 7, 2024

馃悰 Bug description

After upgrading to Rust toolchain 1.78.0, I started getting this error in my GitHub pages project when compiling to wasm:

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

Compiling with the exact same code, this does not happen with 1.77.1.

馃 Expected Behavior

No panic

馃憻 Steps to reproduce

Code compiled to wasm:

Command used to build:

wasm-pack build --target web

The .wasm output is being served in https://github.com/jtroo/jtroo.github.io, which can easily be served locally, e.g.

PS G:\repos\jtroo.github.io> python -m http.server 9000

馃實 Your environment

Include the relevant details of your environment.
wasm-pack version: 0.12.1
rustc version: 1.78.0 / 1.77.1

@jtroo
Copy link
Author

jtroo commented May 7, 2024

Happy to help debug/investigate further with some pointers for where to look to generate more info

@FredrikNoren
Copy link

We're seeing it here too, but doesn't seem to help to downgrade to rust 1.77.1.
The bug appeared a few days ago. Is it one of the dependencies to wasm-pack that has changed?

@SFBdragon
Copy link

SFBdragon commented May 8, 2024

Just want to link some details here too:

alexcrichton/dlmalloc-rs#41 (comment)

alexcrichton/dlmalloc-rs#41 (comment)

In summary, after 1.78 enabled debug assertions in dlmalloc, allocating and deallocating with a different size (this is UB) is caught instead of "silently working" (because of how dlmalloc works, specifically, other allocators will often crash as they actually rely on the safety contract).

@elpiel
Copy link

elpiel commented May 9, 2024

This issue seems to be resolved in latest main and 0.2.92 version, will paste my comment on the issue I opened in dlmalloc: alexcrichton/dlmalloc-rs#41

For anyone landing on this issue, it seems that in the latest revision on main this issue has been fixed.
In the changelog on wasm-bindgen I see this bugfix related to UB in String deallocation, since we were using an older version of wasm-bindgen (because last time we tried to upgrade it was breaking our app again :D )

Fixed UB when freeing strings received from JS if not using the default allocator. rustwasm/wasm-bindgen#3808

https://github.com/rustwasm/wasm-bindgen/blob/0.2.92/CHANGELOG.md#fixed-1

OR

Take alignment into consideration during (de/re)allocation. rustwasm/wasm-bindgen#3463

https://github.com/rustwasm/wasm-bindgen/blob/0.2.92/CHANGELOG.md#0287

rustwasm/wasm-bindgen#3463

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants