Homec4science

Remove multiple inheritance from "unintesting call" mock classes.

Authored by Victor Costan <costan@gmail.com> on Apr 10 2018, 06:57.

Description

Remove multiple inheritance from "unintesting call" mock classes.

Internal CL 156157936, which was published in commit
fe402c27790ff1cc9a7e17c5d0aea4ebe7fd8a71, introduced undefined behavior
by casting a base class (internal::{Naggy,Nice,Strict}Base<MockClass>,
using the curiously recurring template pattern) pointer to a derived
class ({Naggy,Nice,Strict}Mock<MockClass>), in the base class'
constructor. At that point, the object isn't guaranteed to have taken on
the shape of the derived class, and casting is undefined behavior.

The undefined behavior was caught by Chrome's CFI build bot [1], and
prevents rolling googletest past that commit / CL.

This commit simplifies the {Naggy,Nice,Strict}Mock class hierarchy in
a way that removes the undefined behavior.

[1] https://www.chromium.org/developers/testing/control-flow-integrity

Details

Committed
Victor Costan <costan@gmail.com>Apr 12 2018, 09:48
Pushed
trottetDec 4 2019, 13:52
Parents
R9484:fdb57f85710c: Merge pull request #1561 from gennadiycivil/master
Branches
Unknown
Tags
Unknown

Event Timeline

Victor Costan <costan@gmail.com> committed R9484:1324e2d706d7: Remove multiple inheritance from "unintesting call" mock classes. (authored by Victor Costan <costan@gmail.com>).Apr 12 2018, 09:48