Mir

Merge lp:~afrantzis/mir/fix-1517781-double-close into lp:mir

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alberto Aguirre
Approved revision: no longer in the source branch.
Merged at revision: 3111
Proposed branch: lp:~afrantzis/mir/fix-1517781-double-close
Merge into: lp:mir
Diff against target: 49 lines (+6/-7)
2 files modified
include/test/mir_test_framework/async_server_runner.h (+1/-3)
tests/mir_test_framework/async_server_runner.cpp (+5/-4)
To merge this branch: bzr merge lp:~afrantzis/mir/fix-1517781-double-close
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alberto Aguirre (community) Approve
Alan Griffiths Approve
Review via email: mp+278032@code.launchpad.net

Commit message

tests: Avoid double-closing the mir connection fd

Description of the change

tests: Avoid double-closing the mir connection fd

Besides being obviously wrong, it can lead to very mysterious failures in completely unrelated parts of the code (see bug 1517781).

I wonder if this is the cause of any other mysterious failures we have seen.

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

Makes sense.

But I can still reproduce problems in e.g. NestedServer.display_configuration_reset_when_application_exits

Vis:

Repeating all tests (iteration 429) . . .

Note: Google Test filter = NestedServer.display_configuration_reset_when_application_exits
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from NestedServer
[ RUN ] NestedServer.display_configuration_reset_when_application_exits
/home/alan/display_server/mir3/tests/acceptance-tests/test_nested_mir.cpp:755: Failure
Value of: condition.woken()
  Actual: false
Expected: true
Segmentation fault (core dumped)

So which NestedServer test failures are covered by the linked bug?

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> So which NestedServer test failures are covered by the linked bug?

That's a different bug. This fix covers only the cases listed in the linked bug's description (hangs and exceptions involving bad file descriptors).

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

OK.

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_framework/async_server_runner.h'
2--- include/test/mir_test_framework/async_server_runner.h 2015-07-27 07:24:50 +0000
3+++ include/test/mir_test_framework/async_server_runner.h 2015-11-19 16:26:10 +0000
4@@ -52,7 +52,7 @@
5 auto new_connection() -> std::string;
6
7 /// \return a connection string for a client to connect to the server
8- auto connection(mir::Fd fd) -> std::string;
9+ auto connection(int fd) -> std::string;
10
11 mir::Server server;
12
13@@ -60,8 +60,6 @@
14 std::list<TemporaryEnvironmentValue> env;
15 mir::test::AutoJoinThread server_thread;
16
17- std::list<mir::Fd> connections;
18-
19 std::mutex mutex;
20 std::condition_variable started;
21 bool server_running{false};
22
23=== modified file 'tests/mir_test_framework/async_server_runner.cpp'
24--- tests/mir_test_framework/async_server_runner.cpp 2015-07-27 07:24:50 +0000
25+++ tests/mir_test_framework/async_server_runner.cpp 2015-11-19 16:26:10 +0000
26@@ -110,7 +110,6 @@
27 {
28 server.stop();
29 wait_for_server_exit();
30- connections.clear();
31 }
32
33 void mtf::AsyncServerRunner::wait_for_server_exit()
34@@ -132,10 +131,12 @@
35 return connection(server.open_client_socket());
36 }
37
38-auto mtf::AsyncServerRunner::connection(mir::Fd fd) -> std::string
39+auto mtf::AsyncServerRunner::connection(int fd) -> std::string
40 {
41 char connect_string[64] = {0};
42- connections.push_back(fd);
43- sprintf(connect_string, "fd://%d", fd.operator int());
44+ // We can't have both the server and the client owning the same fd, since
45+ // that will result in a double-close(). We give the client a duplicate which
46+ // the client can safely own (and should close when done).
47+ sprintf(connect_string, "fd://%d", dup(fd));
48 return connect_string;
49 }

Subscribers

People subscribed via source and target branches