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
1=== modified file 'include/test/mir_test_doubles/mock_drm.h'
2--- include/test/mir_test_doubles/mock_drm.h 2013-06-25 06:27:05 +0000
3+++ include/test/mir_test_doubles/mock_drm.h 2013-07-04 07:58:28 +0000
4@@ -128,7 +128,6 @@
5 MOCK_METHOD1(drmGetBusid, char* (int fd));
6
7 FakeDRMResources fake_drm;
8- char* busid;
9 };
10
11 }
12
13=== modified file 'tests/mir_test_doubles/mock_drm.cpp'
14--- tests/mir_test_doubles/mock_drm.cpp 2013-06-26 07:30:18 +0000
15+++ tests/mir_test_doubles/mock_drm.cpp 2013-07-04 07:58:28 +0000
16@@ -241,8 +241,7 @@
17 .WillByDefault(Return(0));
18
19 ON_CALL(*this, drmGetBusid(_))
20- .WillByDefault(DoAll(InvokeWithoutArgs([this]() {this->busid = static_cast<char*>(malloc(10));}),
21- ReturnPointee(&this->busid)));
22+ .WillByDefault(WithoutArgs(Invoke([]{ return static_cast<char*>(malloc(10)); })));
23 }
24
25 mgg::MockDRM::~MockDRM() noexcept

Subscribers

People subscribed via source and target branches