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

Explicitly free some Rust-side objects #3911

Merged
merged 3 commits into from Nov 28, 2023
Merged

Explicitly free some Rust-side objects #3911

merged 3 commits into from Nov 28, 2023

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Nov 28, 2023

Finalization in Javascript is not guaranteed - sometimes the FinalizationRegistry just forgets to call the finalizers on some objects. This is problematic because it means we leak references on the Rust side, which (as well as causing memory leaks) ultimately leads to us holding open the indexeddb, which then means we can't successfully log in/out.

This isn't meant to be a comprehensive fix, but it does add explicit free calls in a number of places which seem particularly prone to leaking, and empirically it was enough for me to get a Cypress test which logs out and back in working again.


Here's what your changelog entry will look like:

馃悰 Bug Fixes

  • Explicitly free some Rust-side objects (#3911).

@richvdh richvdh requested a review from a team as a code owner November 28, 2023 12:09
@richvdh richvdh added the T-Task Refactoring, enabling or disabling functionality, other engineering tasks label Nov 28, 2023
Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a really awful footgun, if we wanted the malloc life we wouldn't have been TS devs - is there any way around this on the horizon?

@richvdh
Copy link
Member Author

richvdh commented Nov 28, 2023

This seems like a really awful footgun, if we wanted the malloc life we wouldn't have been TS devs - is there any way around this on the horizon?

Suggestions welcome!

@t3chguy
Copy link
Member

t3chguy commented Nov 28, 2023

I know almost nothing about Rust, and absolutely nothing about incorporating Rust in Javascript. Equally though if switching to rust crypto means brittle as hell code I think I'm no longer in favour

@richvdh
Copy link
Member Author

richvdh commented Nov 28, 2023

I know almost nothing about Rust, and absolutely nothing about incorporating Rust in Javascript. Equally though if switching to rust crypto means brittle as hell code I think I'm no longer in favour

with the greatest respect, I feel like "should we adopt the Rust cryptography library in Element Web" is a discussion that is out of the scope of this PR.

@t3chguy
Copy link
Member

t3chguy commented Nov 28, 2023

No arguing that

@richvdh richvdh added this pull request to the merge queue Nov 28, 2023
Merged via the queue into develop with commit a749662 Nov 28, 2023
24 checks passed
@richvdh richvdh deleted the rav/free_rust_stuff branch November 28, 2023 13:59
@t3chguy t3chguy added T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems and removed T-Task Refactoring, enabling or disabling functionality, other engineering tasks labels Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants