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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash passing strings between components #104

Closed
arades79 opened this issue Jan 8, 2022 · 2 comments
Closed

Crash passing strings between components #104

arades79 opened this issue Jan 8, 2022 · 2 comments

Comments

@arades79
Copy link

arades79 commented Jan 8, 2022

Problem

While passing a string (from html input element) up to a parent node, the program sometimes crashes trying to mutate a cell that's currently being mutated.

Diagnosis Steps

It's unclear to me exactly why the crash is occuring, the following revealed nothing useful:

  • Running under debug mode (thread generating crash is all assembly)
  • Running with "RUST_BACKTRACE=full" (never links back to any code in main.rs, crashing thread is spawned from tokio)
    Full backtrace

I will concede that the code generating this crash is prototype-grade. However, all compiler and clippy lints pass (except non_snake_case due to dioxus style).

My speculation is that this has to do with my "onsend" propery not using the correct bounds, or requiring some wrapper, but I don't have a solution yet.

Here's the full project .zip

Platform information

Rust Target: x86_64-unknown-linux-gnu
Rust Version: 1.57.0 (rustup installed)
Linux Version: 5.14.21-2-MANJARO

I haven't tried on any other platforms.

@jkelleyrtp
Copy link
Member

jkelleyrtp commented Jan 9, 2022

Thank you for the incredibly detailed code and report!

I think this might be already fixed - we were getting the drop order backwards when releasing components with borrowed properties. The patch went into #67.

Try running cargo update to push update your Dioxus version to v0.1.7.

In v0.1.7 all fields prefixed with "on" in components are automatically wrapped in the EventHandler syntax.

However, to make sure the bug doesn't exist I tested your code with a field that doesn't use EventHandler (by renaming the field to _on) and using __cx.bump().alloc on the callback. In v0.1.6 I can replicate your bug but in v0.1.7 I cannot. Can you try upgrading and see if it's fixed?

We might need to yank v0.1.6 since getting drop order wrong is not good.

@arades79
Copy link
Author

arades79 commented Jan 9, 2022

Yep, I can confirm 0.1.7 doesn't crash, I needed to change the Props to use an EventHandler<'a, String> instead of a &'a Fn(String), but that seems like it is the correct way to handle that anyway, and the lints lead me directly to it!

Good job with the patch!

Edit: I also tried to get it working just holding a plain Fn(String) in the props, and that also seems to work! That's what I tried originally, but something about the rsx! macro (or maybe the #[derive(Props)] macro?) was forcing me to store as a reference. Now that coercion doesn't seem to be there so I can just own the closure in the props, which means it definitely won't cause any dangling references

@arades79 arades79 closed this as completed Jan 9, 2022
jkelleyrtp added a commit that referenced this issue Jun 28, 2023
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

2 participants