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

std::move and std::static_pointer_cast of mock objects cause segmentation faults #46

Open
mstaz opened this issue Nov 24, 2020 · 1 comment

Comments

@mstaz
Copy link
Contributor

mstaz commented Nov 24, 2020

What's the idea behind using get() instead of release() in std::move and static_pointer_cast functions?
It seems like the unique and shared pointers are doubled with that. Both destructors try to free the memory what leads to segmentation faults in some cases. A manual release() on one of the pointers helps here.

Of course it would be helpful to have the mock object still available even after move. Maybe it'd make sense to provide an empty Deleter to the new pointers to let the mock object free the memory.

@mstaz
Copy link
Contributor Author

mstaz commented Nov 24, 2020

It seems that the important thing is that the mock object stays alive as long as all moved pointers. And it even seems that it can be accessed after the pointers are destroyed. But I don't know why this is the case 🤔

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

No branches or pull requests

1 participant