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

Decrement refcount before calling free in to_next_sibling #173

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

milianw
Copy link
Contributor

@milianw milianw commented Oct 31, 2024

Fixes an assertion in debug builds which I accidentally introduced when attending the review comments for 1 in 2 - instead of only removing the increment, I also removed the decrement which was wrong - std::mem::forget only allows us to remove the increment, but the decrement is still needed before free since we are in a place of code that is by definition only run when the rc value is set to 1. See also can_take_ptr.

I did not spot this earlier since I ran the integration test on a release build, where the assertion was disabled. It's sad that the rowan repo itself doesn't have any big test coverage in this repo itself, but rather relies on external repos for testing purposes...

Fixes: #172

Fixes an assertion in debug builds which I accidentally
introduced when attending the review comments for [1]
in [2] - instead of only removing the increment, I also
removed the decrement which was wrong - `std::mem::forget`
only allows us to remove the increment, but the decrement
is still needed before free since we are in a place of
code that is by definition only run when the rc value is set to 1.
See also `can_take_ptr`.

I did not spot this earlier since I ran the integration test
on a release build, where the assertion was disabled. It's sad
that the rowan repo itself doesn't have any big test coverage
in this repo itself, but rather relies on external repos for
testing purposes...

[1]: rust-analyzer#171 (comment)
[2]: https://github.com/rust-analyzer/rowan/compare/60a632ad984ab451e32058169193511154c675a9..ab5463e2749330be6846886c21e98c83caca8598

Fixes: rust-analyzer#172
@Veykril Veykril merged commit c4cb18a into rust-analyzer:master Oct 31, 2024
1 check passed
@milianw milianw deleted the fix-to_next_sibling-rc branch November 18, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

assertion left == right failed
2 participants