GUnit icon indicating copy to clipboard operation
GUnit copied to clipboard

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

Open mstaz opened this issue 5 years ago • 1 comments

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 avatar Nov 24 '20 19:11 mstaz

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 🤔

mstaz avatar Nov 24 '20 20:11 mstaz