Title: Multiple inheritance in interfaces leads to segmentation faults with GMock · Issue #74 · cpp-testing/GUnit · GitHub
Open Graph Title: Multiple inheritance in interfaces leads to segmentation faults with GMock · Issue #74 · cpp-testing/GUnit
X Title: Multiple inheritance in interfaces leads to segmentation faults with GMock · Issue #74 · cpp-testing/GUnit
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...
Open Graph 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() =...
X 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() =...
Opengraph URL: https://github.com/cpp-testing/GUnit/issues/74
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Multiple inheritance in interfaces leads to segmentation faults with GMock","articleBody":"When mocking an interface that inherits from multiple other interfaces, segmentation fault happens on `EXPECT_CALL` or call itself.\r\nExample:\r\n```\r\nstruct a\r\n{\r\n\tvirtual ~a() = default;\r\n\tvirtual void func_a() = 0;\r\n};\r\nstruct b\r\n{\r\n\tvirtual ~b() = default;\r\n\tvirtual void func_b() = 0;\r\n};\r\nstruct ab : public a, public b\r\n{\r\n\t~ab() override = default;\r\n};\r\n\r\nauto mock = std::make_shared\u003ctesting::StrictGMock\u003cab\u003e\u003e();\r\nstd::shared_ptr\u003cab\u003e obj = object(mock);\r\nEXPECT_CALL(*mock, (func_a)()); // works as expected\r\nobj-\u003efunc_a(); // works as expected\r\nEXPECT_CALL(*mock, (func_b)()); // may already crash\r\nobj-\u003efunc_b(); // latest here crash happens\r\n```\r\n\r\nWhen 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.\r\nTo 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.\r\n\r\nThis may be a duplicate of issue #12, however I'm unsure as the description is not very detailed there.","author":{"url":"https://github.com/mstaz","@type":"Person","name":"mstaz"},"datePublished":"2022-04-06T13:49:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/74/GUnit/issues/74"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6f05aabd-e9ec-80a5-d5d3-6902760b704f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C506:F5764:1CFCD80:289D3D3:696F5DCC |
| html-safe-nonce | cdcb12b59f46300fefc6d5a6fee55cf19ca5a81248dd2fc16d243b418a1f4ef7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTA2OkY1NzY0OjFDRkNEODA6Mjg5RDNEMzo2OTZGNURDQyIsInZpc2l0b3JfaWQiOiI2MjYxNjc2MzQ3ODA1ODgzODUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 671bddd6477d83ca2a4d0ee8383c34f098686403912bc1d2cb1e3f0b7a53edd9 |
| hovercard-subject-tag | issue:1194647348 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cpp-testing/GUnit/74/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bf064fff30fc32c09d173232ec4fabbc92709e60ec5883c9fea64e17836e2425/cpp-testing/GUnit/issues/74 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bf064fff30fc32c09d173232ec4fabbc92709e60ec5883c9fea64e17836e2425/cpp-testing/GUnit/issues/74 |
| og:image:alt | 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() =... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mstaz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 774d0922d2c4577043d2dab90427344eb4c6ce1d5579acb1dd504cff1a7e46f8 |
| turbo-cache-control | no-preview |
| go-import | github.com/cpp-testing/GUnit git https://github.com/cpp-testing/GUnit.git |
| octolytics-dimension-user_id | 24781083 |
| octolytics-dimension-user_login | cpp-testing |
| octolytics-dimension-repository_id | 77401922 |
| octolytics-dimension-repository_nwo | cpp-testing/GUnit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 77401922 |
| octolytics-dimension-repository_network_root_nwo | cpp-testing/GUnit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 650acea592f12d1bd8931d44546c209e0b06ed6e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width