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

Implement enters target for guarding execution from double-mutability #2878

Closed
wants to merge 2 commits into from

Conversation

addisoncrump
Copy link
Collaborator

This will almost guaranteed break QEMU, because it was doing something necessarily unsound (double-mutable access of state). This needs to be resolved before this is merged.

state: &'a mut S,
mgr: &'a mut EM,
input: &'a I,
) -> Self::Guard<'a> {
unsafe {
let data = &raw mut GLOBAL_STATE;
Copy link
Member

Choose a reason for hiding this comment

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

Add a read_volatile check here that current_input_ptr is ptr::null() please

And add the potential race condition to the # Safety comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but I don't think there's a race threat here unless there are multiple executors running simultaneously. If there is, then signal handling is already broken, since this would apply at a thread group level.

Copy link
Member

Choose a reason for hiding this comment

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

Yes if you call this function twice you have a race condition. Ergo, document.
Also, return Err or None if it's already set

Copy link
Member

Choose a reason for hiding this comment

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

I'm not saying it's how we use it, but it's how the doc should be

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah but you can't call this function twice, because you'll hold the guard.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And, if you're not holding the guard, then the guard is dropped and it's already restored the guarded state.

OT: ObserversTuple<I, S>,
/// A simple guard, to be used with [`GenericInProcessExecutorInner`].
#[derive(Debug)]
pub struct InProcessGuard<'a> {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't/coudn't this guy have the type of the generics used? As it is now you can still use it to call the methods with a different type, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You would always be able to call the methods with a different type, but there are other ways that this is restricted (i.e. the harness gets moved out of the executor when it's in use, then restored after). There is no real way to restrict this further, without holding EM/Z in phantom data.

@addisoncrump
Copy link
Collaborator Author

While this would be nice to have, we need to severely revisit executors in general before we could use this effectively. Closing.

@domenukk
Copy link
Member

Why?

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.

3 participants