Mir

Merge lp:~vanvugt/mir/fix-1295231 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1500
Proposed branch: lp:~vanvugt/mir/fix-1295231
Merge into: lp:mir
Diff against target: 39 lines (+16/-2)
2 files modified
src/client/mir_client_library.cpp (+11/-2)
tests/acceptance-tests/test_protobuf.cpp (+5/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1295231
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
Review via email: mp+212367@code.launchpad.net

Commit message

Fix client memory leak that is causing sporadic CI test failures in and around
TestClientInput/DemoPrivateProtobuf. (LP: #1295231)

The leak was a simple mistake in the client library. It was triggered by
DemoPrivateProtobuf tests being strangely racy (not fixed here). However
valgrind doesn't detect that as a leak until the next multi-process test
completes. So it would fail typically during TestClientInput.

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

8 + // Use a unique_ptr to ensure connection gets deleted even if we have
9 + // thrown an exception (LP: #1295231)
10 + std::unique_ptr<MirConnection> ptr(connection);

This is the wrong place/way to fix the problem.

This code implements a C API and should not be propagating exceptions.

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Alan,

We're not propagating exceptions, for that reason. See the catch() below that.

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

> Alan,
>
> We're not propagating exceptions, for that reason. See the catch() below that.

OK

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

Looks good.

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

How does the latest iteration fix a memory leak?

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

> How does the latest iteration fix a memory leak?

Sorry, that was a think-o.

While the test may expose raciness in the RPC code I don't think the test itself is the problem. AFAICS the race is between the client posting disconnect and the client detecting that the server has disconnected.

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

Rebuilding to see if CI is really happy with this merged.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
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 'src/client/mir_client_library.cpp'
2--- src/client/mir_client_library.cpp 2014-03-06 06:05:17 +0000
3+++ src/client/mir_client_library.cpp 2014-03-24 09:43:22 +0000
4@@ -120,8 +120,17 @@
5 {
6 if (!error_connections.contains(connection))
7 {
8- auto wait_handle = connection->disconnect();
9- wait_handle->wait_for_all();
10+ try
11+ {
12+ auto wait_handle = connection->disconnect();
13+ wait_handle->wait_for_all();
14+ }
15+ catch (std::exception const&)
16+ {
17+ // We're implementing a C API so no exceptions are to be
18+ // propagated. And that's OK because if disconnect() fails,
19+ // we don't care why. We're finished with the connection anyway.
20+ }
21 }
22 else
23 {
24
25=== modified file 'tests/acceptance-tests/test_protobuf.cpp'
26--- tests/acceptance-tests/test_protobuf.cpp 2014-03-06 06:05:17 +0000
27+++ tests/acceptance-tests/test_protobuf.cpp 2014-03-24 09:43:22 +0000
28@@ -209,6 +209,11 @@
29 &result,
30 NewCallback(&callback, &called_back));
31
32+ // FIXME - This test is somehow racy. If I add:
33+ // EXPECT_TRUE(false) << connection;
34+ // then I can get mir_connection_release to generate an exception during
35+ // disconnect() internally, sometimes. Although that exception is caught
36+ // internally by the client library so we don't see it here.
37 mir_connection_release(connection);
38
39 EXPECT_TRUE(called_back);

Subscribers

People subscribed via source and target branches