Segfault When Running Jenkins Tests... Sometimes
(This is a merge of http://go/wvgerrit/71330) The Service Certificate unit tests actually relied on the ability to call Properties::Init() multiple times to clear previous mutable state. Unfortunately, they didn't check the return code that could have told them their mutable state wasn't being cleared and instead proceeded to use a pointer which — depending on compiler — could be totally valid and allow the test to pass or could be invalid and cause a segfault. You can read the bug for a fuller explanation of the mechanics. The fix is twofold. First, the tests will now assert out if insertion into the property set map fails, preventing segfaults. Second, a helper has been added to Properties that allows tests interested in re-initializing Properties to do so. The default behavior for most tests remains the same: Properties can only be initialized once and subsequent calls to Properties::Init() are ignored. This patch also fixed a few formatting issues I noticed. Bug: 123099779 Test: Jenkins Unit Tests w/ GCC Test: CE CDM Unit Tests w/ GCC & Clang Change-Id: Ifd29f3ddf5cff934933cf47b92ecd12ab0a4a938
This commit is contained in:
@@ -85,6 +85,21 @@ class Properties {
|
||||
CdmClientPropertySet* property_set);
|
||||
static bool RemoveSessionPropertySet(const CdmSessionId& session_id);
|
||||
|
||||
protected:
|
||||
// This function always runs the code in |Init()| (and subsequently
|
||||
// |InitOnce()|) even if Properties have already been initialized. This is
|
||||
// needed by certain tests that are dependent on controlling the mutable state
|
||||
// of Properties. Should not be used in general, as most tests rely on
|
||||
// Properties' normal guarantee about |Init()| being safe to call multiple
|
||||
// times without destroying mutable state.
|
||||
static void ForceReinit() {
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(init_mutex_);
|
||||
is_initialized_ = false;
|
||||
}
|
||||
Init();
|
||||
}
|
||||
|
||||
private:
|
||||
static CdmClientPropertySet* GetCdmClientPropertySet(
|
||||
const CdmSessionId& session_id);
|
||||
@@ -111,7 +126,6 @@ class Properties {
|
||||
FRIEND_TEST(CdmLicenseTest, PrepareKeyRequestValidation);
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Called at least once before any properties are used.
|
||||
static void InitOnce();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user