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

Rawlink safety #19

Open
iemelyanov opened this issue Mar 23, 2023 · 4 comments
Open

Rawlink safety #19

iemelyanov opened this issue Mar 23, 2023 · 4 comments

Comments

@iemelyanov
Copy link

Hi

It looks like Rawlink allows access to one point of memory through mutable and immutable references, which might break Rust aliasing rules. Mb resolve and resolve_mut must be marked as unsafe or even more suitable to use Option<NonNull> instead RawLink?

@BurntSushi
Copy link
Owner

Can you show an example misuse? Ideally a program that Miri fails on

@iemelyanov
Copy link
Author

iemelyanov commented Mar 23, 2023

Sorry, maybe I'm not a correctly named issue. I do not see a problem with using Rawlink. But I try to understand if is it acceptable or idiomatic in terms of Rust for internal API to use carefully something like Rawlink instead for example NonNull?

@BurntSushi
Copy link
Owner

I would advise you to look at the commit history of the code you're looking at. I wrote it nearly a decade ago. And there is nobody using it. There has been no on-going development either. I don't think you should be drawing any conclusions about idioms from such code.

If the question is just "use NonNull or not," then I think there are reasons to use it and not use it. You'll need to make your own judgment about it.

I only quickly looked at the Rawlink code, and my eye does indeed say it looks suspicious. But I don't have the time or inclination to do a careful review and fix it right now. But PRs are welcome.

@iemelyanov
Copy link
Author

Thank you for your answer.

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

No branches or pull requests

2 participants