tpounds/mockitopp

Mocking objects with virtual bases leads to segfaults

Closed this issue · 2 comments

What steps will reproduce the problem?
1. Create a mock_object<> for a class that inherits virtually from another 
class.
2. Set up expectation on the mock_object<> that a function from the virtual 
base class is called.
3. Call the function on the mock_object<>'s underlying instance

The code in the attached file shows an example.

What is the expected output? What do you see instead?
I expected that this would work the same as if the parent class was inherited 
from non-virtually. Instead a segfault is raised.

What version of the product are you using? On what operating system?
mockitopp built off of trunk at rev140
OS is Scientific Linux 6:
$ uname -a
Linux xxx 2.6.32-279.1.1.el6.x86_64 #1 SMP Tue Jul 10 11:24:23 CDT 2012 x86_64 
x86_64 x86_64 GNU/Linux

Please provide any additional information below.
In the testing context where I found this issue I was using Google's tcmalloc 
and I found that mocking a class with a virtual parent sometimes caused this 
crash, but other times worked exactly as expected. The odd thing was that 
whether or not it crashed was influenced by unrelated code around it, 
specifically the ordering and placement of declarations and memory allocations 
for mock_object<> instances. I'm still trying to distill this down into an 
easily digestible example if that would be useful.

Original issue reported on code.google.com by nwon...@gmail.com on 14 Sep 2012 at 9:49

Attachments:

Original comment by trevor.p...@gmail.com on 29 Sep 2012 at 7:39

  • Changed state: Accepted
This issue was closed by revision r147.

Original comment by trevor.p...@gmail.com on 29 Sep 2012 at 7:41

  • Changed state: Fixed