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

Assert the LSB is 0 when converting Vec into Bytes #342

Merged
merged 1 commit into from
Dec 12, 2019

Conversation

seanmonstar
Copy link
Member

Adding on to #341

cc @sfackler

@sfackler
Copy link
Contributor

It's totally valid for an allocator to produce those pointers, though. A fix that wouldn't require a rethink of the whole implementation could be to just immediately promote odd-pointer buffers to KIND_ARC.

@seanmonstar
Copy link
Member Author

Yea they could, that's why I put the assert in here at least for now, so an app with a custom allocator gets a panic instead of memory unsafety.

@carllerche
Copy link
Member

How would you convert an odd pointer back to a real one if you don't know what the LSB means?

@sfackler
Copy link
Contributor

If you don't know what the LSB means, you can't. The idea in my comment above was to ensure that you do know what it means by avoiding the KIND_VEC case entirely if the Vec pointer is odd.

@seanmonstar
Copy link
Member Author

My current feeling is to merge this assertion, and perhaps fix if/when some allocator actually starts handing out odd pointers. Seem fine?

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

3 participants