Skip to content

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

@underfin underfin force-pushed the re-fix-sourceview branch from 57c8e53 to 46b9a02 Compare March 12, 2024 13:11
@Swatinem Swatinem merged commit b9901b2 into getsentry:master Mar 12, 2024
@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.

2 participants