Mir

Merge lp:~afrantzis/mir/fix-mock-drmgetbusid-race into lp:~mir-team/mir/trunk

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 808
Proposed branch: lp:~afrantzis/mir/fix-mock-drmgetbusid-race
Merge into: lp:~mir-team/mir/trunk
Diff against target: 25 lines (+1/-3)
2 files modified
include/test/mir_test_doubles/mock_drm.h (+0/-1)
tests/mir_test_doubles/mock_drm.cpp (+1/-2)
To merge this branch: bzr merge lp:~afrantzis/mir/fix-mock-drmgetbusid-race
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Review via email: mp+172964@code.launchpad.net

Commit message

tests: Fix race condition in MockDRM leading to memory errors

Previously, because we allocated and returned memory in two step, using
a unique storage point to hold the allocated memory, there was the
potential for memory errors (e.g. double frees) in multithreaded tests
(like drm_close_not_called_concurrently_on_ipc_package_destruction).

Description of the change

tests: Fix race condition in MockDRM leading to memory errors

Previously, because we allocated and returned memory in two step, using
a unique storage point to hold the allocated memory, there was the
potential for memory errors (e.g. double frees) in multithreaded tests
(like drm_close_not_called_concurrently_on_ipc_package_destruction).

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

It isn't obvious why, but this appears to fix https://bugs.launchpad.net/mir/+bug/1197408

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/test/mir_test_doubles/mock_drm.h'
--- include/test/mir_test_doubles/mock_drm.h 2013-06-25 06:27:05 +0000
+++ include/test/mir_test_doubles/mock_drm.h 2013-07-04 07:58:28 +0000
@@ -128,7 +128,6 @@
128 MOCK_METHOD1(drmGetBusid, char* (int fd));128 MOCK_METHOD1(drmGetBusid, char* (int fd));
129129
130 FakeDRMResources fake_drm;130 FakeDRMResources fake_drm;
131 char* busid;
132};131};
133132
134}133}
135134
=== modified file 'tests/mir_test_doubles/mock_drm.cpp'
--- tests/mir_test_doubles/mock_drm.cpp 2013-06-26 07:30:18 +0000
+++ tests/mir_test_doubles/mock_drm.cpp 2013-07-04 07:58:28 +0000
@@ -241,8 +241,7 @@
241 .WillByDefault(Return(0));241 .WillByDefault(Return(0));
242242
243 ON_CALL(*this, drmGetBusid(_))243 ON_CALL(*this, drmGetBusid(_))
244 .WillByDefault(DoAll(InvokeWithoutArgs([this]() {this->busid = static_cast<char*>(malloc(10));}),244 .WillByDefault(WithoutArgs(Invoke([]{ return static_cast<char*>(malloc(10)); })));
245 ReturnPointee(&this->busid)));
246}245}
247246
248mgg::MockDRM::~MockDRM() noexcept247mgg::MockDRM::~MockDRM() noexcept

Subscribers

People subscribed via source and target branches