-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
When mocking an interface that inherits from multiple other interfaces, segmentation fault happens on EXPECT_CALL
or call itself.
Example:
struct a
{
virtual ~a() = default;
virtual void func_a() = 0;
};
struct b
{
virtual ~b() = default;
virtual void func_b() = 0;
};
struct ab : public a, public b
{
~ab() override = default;
};
auto mock = std::make_shared<testing::StrictGMock<ab>>();
std::shared_ptr<ab> obj = object(mock);
EXPECT_CALL(*mock, (func_a)()); // works as expected
obj->func_a(); // works as expected
EXPECT_CALL(*mock, (func_b)()); // may already crash
obj->func_b(); // latest here crash happens
When mocking or calling a function on the second interface a crash happens. I played around a little bit and observed crashes on EXPECT_CALL
as well as on function call itself.
To me it seems that offset calculation for vtable doesn't work reliable for such cases. However unfortunately I couldn't find the exact reason for the issue. It may also depend on the used compiler. I observed the issue with clang-13.
This may be a duplicate of issue #12, however I'm unsure as the description is not very detailed there.
Metadata
Metadata
Assignees
Labels
No labels