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

Allow value parameters to be passed by copy instead of consuming #766

Merged
merged 2 commits into from
Feb 27, 2022

Conversation

adetaylor
Copy link
Collaborator

Part of #379.

Prior to this point, a value parameter of a C++ function
consumed a UniquePtr<T>.

With this change, a value parameter is now of type
  impl ValueParam<T>
which can be either a UniquePtr<T> (avoiding any compatibility
break) or a &T or various other things.
These are failing on Windows only for unknown reasons and will
be investigated in #819.
@adetaylor adetaylor changed the title Pass by copy Allow value parameters to be passed by copy instead of consuming Feb 27, 2022
@adetaylor adetaylor merged commit 21a9a59 into main Feb 27, 2022
if this.param.needs_stack_space() {
this.space = Some(MaybeUninit::uninit());
this.param
.populate_stack_space(Pin::new_unchecked(this.space.as_mut().unwrap()));
Copy link
Contributor

Choose a reason for hiding this comment

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

What prevents this Rust object (which is the storage for a C++ object) from being memcpyed to a different address? Some of the tests fail for me after this PR, I think because of this.

With some additional prints, it looks like the drop for ValueParamHandler is definitely being called with a different address.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, thanks, I will revert or fix this tomorrow.

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 suspicious of my pinning logic here and that's why I had raised #833 on myself! I plan to disable this code in #852 for now, and then reinstate it as I do #847 or #821, either of which will require this ValueParam code to be rejigged a bit.

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.

2 participants