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

fix: SourceView implement Sync #82

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

underfin
Copy link
Contributor

The *const u8 is !Send, here already using Mutex to make sure the ptr is thread-safe, so add SourceViewLinePtr struct to let it implement Send + Sync.

Copy link
Member

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

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

The reason this is a (*const u8, usize) in the first place is I believe a historic artifact.

In reality it should be &'a str, as it points into the source. One way or another, this can only be done using unsafe code, as you can potentially create self-referential data that way (because pointing to a Cow::Owned makes it self-referential).

I would rather fix this in such a way that we only have a single place for the unsafe code, namely where we create these &'a str slices.

All the other unsafe code, like using raw pointers, the make_str fn, etc should rather be removed.

SourceView pretty much is just a caching, on-demand version of .lines().collect().

@underfin
Copy link
Contributor Author

@Swatinem Thanks for your review, I already fixed it.

Copy link
Member

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

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

I’m surprised this needs changes to the DecodedMap

src/types.rs Outdated Show resolved Hide resolved
src/sourceview.rs Outdated Show resolved Hide resolved
@Swatinem Swatinem merged commit b9901b2 into getsentry:master Mar 12, 2024
4 checks passed
@underfin
Copy link
Contributor Author

@Swatinem Could you publish a new version for it? Thank you a lot.

@Swatinem
Copy link
Member

Done. Though I somehow messed up the commit message when merging, on well.

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.

None yet

2 participants