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
=== modified file 'include/test/mir_test_framework/async_server_runner.h'
--- include/test/mir_test_framework/async_server_runner.h 2015-07-27 07:24:50 +0000
+++ include/test/mir_test_framework/async_server_runner.h 2015-11-19 16:26:10 +0000
@@ -52,7 +52,7 @@
52 auto new_connection() -> std::string;52 auto new_connection() -> std::string;
5353
54 /// \return a connection string for a client to connect to the server54 /// \return a connection string for a client to connect to the server
55 auto connection(mir::Fd fd) -> std::string;55 auto connection(int fd) -> std::string;
5656
57 mir::Server server;57 mir::Server server;
5858
@@ -60,8 +60,6 @@
60 std::list<TemporaryEnvironmentValue> env;60 std::list<TemporaryEnvironmentValue> env;
61 mir::test::AutoJoinThread server_thread;61 mir::test::AutoJoinThread server_thread;
6262
63 std::list<mir::Fd> connections;
64
65 std::mutex mutex;63 std::mutex mutex;
66 std::condition_variable started;64 std::condition_variable started;
67 bool server_running{false};65 bool server_running{false};
6866
=== modified file 'tests/mir_test_framework/async_server_runner.cpp'
--- tests/mir_test_framework/async_server_runner.cpp 2015-07-27 07:24:50 +0000
+++ tests/mir_test_framework/async_server_runner.cpp 2015-11-19 16:26:10 +0000
@@ -110,7 +110,6 @@
110{110{
111 server.stop();111 server.stop();
112 wait_for_server_exit();112 wait_for_server_exit();
113 connections.clear();
114}113}
115114
116void mtf::AsyncServerRunner::wait_for_server_exit()115void mtf::AsyncServerRunner::wait_for_server_exit()
@@ -132,10 +131,12 @@
132 return connection(server.open_client_socket());131 return connection(server.open_client_socket());
133}132}
134133
135auto mtf::AsyncServerRunner::connection(mir::Fd fd) -> std::string134auto mtf::AsyncServerRunner::connection(int fd) -> std::string
136{135{
137 char connect_string[64] = {0};136 char connect_string[64] = {0};
138 connections.push_back(fd);137 // We can't have both the server and the client owning the same fd, since
139 sprintf(connect_string, "fd://%d", fd.operator int());138 // that will result in a double-close(). We give the client a duplicate which
139 // the client can safely own (and should close when done).
140 sprintf(connect_string, "fd://%d", dup(fd));
140 return connect_string;141 return connect_string;
141}142}

Subscribers

People subscribed via source and target branches