-
Notifications
You must be signed in to change notification settings - Fork 1
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
runtime/type-registry: add new type-registry
library for the type confusion APIs
#493
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple points.
One is that I don't think there's a reason to have a PtrAddr
struct or rust *const ()
here: usize
is guaranteed to be the right size, and we never dereference. Then sorting/etc. behavior for usize does the right thing with no need to impl various traits.
The other is that I don't think we in general want to panic here, because we'll be unwinding through other languages (and we want to stop execution as soon as possible given that we've observed an inconsistency that could indicate memory corruption). Maybe we should abort directly, or choose whether to abort vs. panicking with a #[cfg(test)]
or such to allow using the Rust test harness. I'm not sure if panic = abort
would work here or be easy to apply.
Do you mean something like:
I don't think that's reasonable to do in the presence of concurrent calls to the library, because we don't know the user's expectations of the library itself w/r/t locking. It could be that the user requires two calls to enter the library before either will return. |
Okay, I can do it this way I think. Strict provenance is also stabilized now, which makes it simpler to do this fully correctly/clearly with
What about using |
Yeah, you're probably right about this. Let me think about it a bit more, but you're probably right; I didn't think through all the possible cases. |
As far as I understand, provenance doesn't come into play here if we never cast back from the pointer/addr to a reference. Will we need to do so later for some reason?
I was concerned that |
a86cd53
to
1d69f70
Compare
1d69f70
to
34a4883
Compare
…onfusion APIs This is written in Rust like `memory-map` is, so I made the `CMakeLists.txt` very similar. Since the library may be called concurrently, it uses a hash map which is non-trivial in C, and we already have Rust libraries like `memory-map`, Rust seemed like a good choice here.
34a4883
to
bf0d83d
Compare
It just makes it clearer the exact provenance semantics of what we're doing, and to not accidentally expose provenance (which we don't ever need to do).
👍 I also included |
I kept the newtype |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This is written in Rust like
memory-map
is, so I made theCMakeLists.txt
very similar. Since the library may be called concurrently, it uses a hash map which is non-trivial in C, and we already have Rust libraries likememory-map
, Rust seemed like a good choice here.There are a few other things I think we want to do here, such as ensuring a type doesn't change across the duration of the function call (not just the beginning); this would be done with a read lock. Also, we probably want to store the compartment number along with the type ID. But I'll do these in follow-up PRs once we get the initial parts working.