Skip to content

fix segfault related to #128 #129

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

Merged
merged 1 commit into from
Jun 26, 2025
Merged

fix segfault related to #128 #129

merged 1 commit into from
Jun 26, 2025

Conversation

rob-p
Copy link

@rob-p rob-p commented Jun 26, 2025

This needs some more (independent) validation, but this should fix the (long standing) segfault that previously was solved with the repeated km_init hack.

Essentially, the previous code was handing out multiple references (including a mutable one) to the underlying thread local buffer at the same time. This voilates the rust shared xor mutable rules and, recalling that unsafe doesn't disable the rules and that we are still responsible for upholding them, I believe that opened us up to undefined behavior ultimately resulting in the segfault.

This PR applies an easy fix. It simply moves the acquisition of the mutable pointer to the km object until after the call to mm_map, so that we only acquire the mutable reference after the lifetime of the mm_map call is finished with it. In my testing, this seems to resolve the segfaults that were previously occurring.

@jguhlin jguhlin merged commit 897ee07 into jguhlin:main Jun 26, 2025
10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants