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

Don't derive Copy for FFI structs/unions that contain pointers #1048

Open
sdroege opened this issue Feb 4, 2021 · 1 comment
Open

Don't derive Copy for FFI structs/unions that contain pointers #1048

sdroege opened this issue Feb 4, 2021 · 1 comment
Labels

Comments

@sdroege
Copy link
Member

sdroege commented Feb 4, 2021

In #415 we started deriving Copy for all FFI structs and unions. This can easily lead to double frees and related problems because it can be non-obvious from the code that a value is actually copied instead of being moved.

https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/310 is an example of that.

We should probably stop deriving Copy for such structs/unions with pointers. Clone is still fine as that has to happen explicitly.

@EPashkin @GuillaumeGomez @bilelmoussaoui Opinions?

@GuillaumeGomez
Copy link
Member

I strongly agree.

sdroege added a commit to sdroege/gir that referenced this issue Feb 4, 2021
Clone is still derived to as explicitly cloning the structs is less of a
problem, but implicitly copying them can easily cause double frees.

Fixes gtk-rs#1048
sdroege added a commit to sdroege/gir that referenced this issue Feb 4, 2021
Clone is still derived to as explicitly cloning the structs is less of a
problem, but implicitly copying them can easily cause double frees.

Fixes gtk-rs#1048
sdroege added a commit to sdroege/gir that referenced this issue Feb 4, 2021
Clone is still derived to as explicitly cloning the structs is less of a
problem, but implicitly copying them can easily cause double frees.

Fixes gtk-rs#1048
sdroege added a commit to sdroege/gir that referenced this issue Feb 4, 2021
Clone is still derived to as explicitly cloning the structs is less of a
problem, but implicitly copying them can easily cause double frees.

Fixes gtk-rs#1048
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants