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

Make executor state available to the harness V2 #1900

Merged
merged 22 commits into from
Mar 5, 2024

Conversation

rmalmain
Copy link
Collaborator

@rmalmain rmalmain commented Mar 1, 2024

Alternative to #1847, without changing Executor.

@rmalmain
Copy link
Collaborator Author

rmalmain commented Mar 1, 2024

With this implementation, GenericInProcessExecutor stores (in addition to its internal state) the state of the parent structure (like QemuExecutor inner state). It's quite unnatural, but it works out well.
Is it a reasonable thing to do?

@tokatoka
Copy link
Member

tokatoka commented Mar 1, 2024

GenericInProcessExecutor stores (in addition to its internal state) the state of the parent structure (like QemuExecutor inner state).

which part does this? i only see QemuExecutorWithState calling executor_state

// Crash and timeout hah
hooks: (InProcessHooks, HT),
phantom: PhantomData<(S, *const H)>,
inner: GenericInProcessExecutorInner<HT, OT, S>,
Copy link
Member

Choose a reason for hiding this comment

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

what was the reason that you have to make this inner?
i think i heard once but forgot

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's to avoid code duplication between GenericInProcessExecutor and GenericInProcessExecutorWithState.

Copy link
Member

Choose a reason for hiding this comment

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

ok

@rmalmain
Copy link
Collaborator Author

rmalmain commented Mar 1, 2024

GenericInProcessExecutor stores (in addition to its internal state) the state of the parent structure (like QemuExecutor inner state).

which part does this? i only see QemuExecutorWithState calling executor_state

GenericInProcessExecutorWithState does, sorry I didn't make it clear.
It's basically GenericInProcessExecutor, with the state of the parent structure (here QemuExecutorWithState) embedded inside.

/// The inmem executor simply calls a target function, then returns afterwards.
/// The harness can access the internal state of the executor.
#[allow(dead_code)]
pub struct GenericInProcessExecutorWithState<H, HB, HT, OT, S, ES>
Copy link
Member

Choose a reason for hiding this comment

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

I think you should name this so that it ends in State.
Because you already have executor's state. so it's confusing to determine if this state or executor

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I defnitely need to rename those guys. For now it's just for the PoC

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe something like MutableInProcessExecutor?

Copy link
Member

Choose a reason for hiding this comment

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

GenericInProcessWithStateExecutor?

Copy link
Collaborator Author

@rmalmain rmalmain Mar 1, 2024

Choose a reason for hiding this comment

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

Definitely better than my original proposition. Not sure if embedding WithState in the struct name is a good naming tho, since it collides with the name of the different states.

Copy link
Member

Choose a reason for hiding this comment

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

StateAwareInProcessExecutgor?

Copy link
Member

Choose a reason for hiding this comment

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

Stateful?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good to me

harness_fn: HB,
/// The state used as argument of the harness
pub executor_state: ES,
/// Inner state of the executor
Copy link
Member

Choose a reason for hiding this comment

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

so it's not state it's more
Inner executor with state 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.

I was thinking of putting it in inner, to merge the different states in the same struct.
It would also let me remove this ugly pub.

@tokatoka
Copy link
Member

tokatoka commented Mar 1, 2024

It's basically GenericInProcessExecutor, with the state of the parent structure (here QemuExecutorWithState) embedded inside.

Ok. Will it feel less odd if you rename QemuExecutorState to QemuInternalState?

@rmalmain
Copy link
Collaborator Author

rmalmain commented Mar 1, 2024

It's basically GenericInProcessExecutor, with the state of the parent structure (here QemuExecutorWithState) embedded inside.

Ok. Will it feel less odd if you rename QemuExecutorState to QemuInternalState?

Not sure, since it suggests it represents the state of QEMU itself, which is not the case

@tokatoka
Copy link
Member

tokatoka commented Mar 1, 2024

But your QemuExecutorState has just first_exec as its only owned member. but whether the execution is first or not is not qemu-specific state right?

How about naming it to BasicExecutorState

@rmalmain
Copy link
Collaborator Author

rmalmain commented Mar 5, 2024

I applied the renaming propositions.
Is there any other remark for this PR?

@rmalmain rmalmain merged commit 55a300d into main Mar 5, 2024
26 checks passed
@rmalmain rmalmain deleted the in_process_handler_executor_v2 branch March 5, 2024 18:28
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