Mir

Merge lp:~mir-team/mir/remove-global-constructor-socket into lp:mir

Proposed by Brandon Schaefer
Status: Rejected
Rejected by: Brandon Schaefer
Proposed branch: lp:~mir-team/mir/remove-global-constructor-socket
Merge into: lp:mir
Diff against target: 93 lines (+12/-14)
5 files modified
src/client/mir_connection_api.cpp (+1/-1)
src/common/env/default_configuration.cpp (+3/-10)
src/common/symbols.map (+4/-1)
src/include/common/mir/default_configuration.h (+3/-1)
src/platform/options/default_configuration.cpp (+1/-1)
To merge this branch: bzr merge lp:~mir-team/mir/remove-global-constructor-socket
Reviewer Review Type Date Requested Status
Alan Griffiths Needs Fixing
PS Jenkins bot (community) continuous-integration Needs Fixing
Andreas Pokorny (community) Approve
Review via email: mp+272952@code.launchpad.net

Commit message

Remove the global default_server_socket and replace it with a function. It causes issues when you dlopen/dlclose on mir common during tests. Issues invalid reading of the strings.

Description of the change

Remove the global default_server_socket and replace it with a function. It causes issues when you dlopen/dlclose on mir common during tests. Issues invalid reading of the strings.

Example issue:
https://jenkins.qa.ubuntu.com/job/mir-wily-amd64-ci/1206/console

To post a comment you must log in.
2979. By Brandon Schaefer

* Remove static str, as if we ever need to change socket during a test this would fail

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2980. By Brandon Schaefer

* Move back to the orig symbol spot

2981. By Brandon Schaefer

* Undo that change

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

That change still looks reasonable, and the ci problem unrelated.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I'm not sure this is well motivated.

The test case that triggers the issue this addresses is one that can hardly be described as a "unit test". The only reason I can see for adding it to that binary is the use of umockdev (and that usage for *unit* tests is already controversial).

The unit tests already statically link a *lot* of the contents of libmircommon and this leads to ODR violations.

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

- mir::default_server_socket;

This is an ABI break. We should bump the soname, consolidate the stanzas, etc.

(But see above comment as I'm not sure this "solution" is enabling something we want to do.)

review: Needs Fixing
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Sounds good, ill be moving the test (that needed this) over to acceptable tests once umockdev tests have landed there.

We should just be aware (should i make a comment/bug somewhere?) that if a server is ran after the test_module_deleter this will cause invalid reads on global strings.

Unmerged revisions

2981. By Brandon Schaefer

* Undo that change

2980. By Brandon Schaefer

* Move back to the orig symbol spot

2979. By Brandon Schaefer

* Remove static str, as if we ever need to change socket during a test this would fail

2978. By Brandon Schaefer

* Dont use global constructors, causes issues when you dlopen/dlclose on the mircommon during tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/client/mir_connection_api.cpp'
2--- src/client/mir_connection_api.cpp 2015-07-25 08:10:48 +0000
3+++ src/client/mir_connection_api.cpp 2015-09-30 21:06:13 +0000
4@@ -64,7 +64,7 @@
5 if (socket_env)
6 sock = socket_env;
7 else
8- sock = mir::default_server_socket;
9+ sock = mir::default_server_socket();
10 }
11
12 auto const conf = configuration(sock);
13
14=== modified file 'src/common/env/default_configuration.cpp'
15--- src/common/env/default_configuration.cpp 2013-12-12 07:51:12 +0000
16+++ src/common/env/default_configuration.cpp 2015-09-30 21:06:13 +0000
17@@ -21,9 +21,7 @@
18 #include <cstdlib>
19 #include <sstream>
20
21-namespace
22-{
23-const char* init()
24+std::string mir::default_server_socket()
25 {
26 std::ostringstream formatter;
27
28@@ -32,10 +30,5 @@
29
30 formatter << dir << "/mir_socket";
31
32- static auto result = formatter.str();
33- return result.c_str();
34-}
35-}
36-
37-const char *const mir::default_server_socket = init();
38-
39+ return formatter.str();
40+}
41
42=== modified file 'src/common/symbols.map'
43--- src/common/symbols.map 2015-09-17 06:06:28 +0000
44+++ src/common/symbols.map 2015-09-30 21:06:13 +0000
45@@ -105,7 +105,6 @@
46
47 # These symbols are supposed to be "private" (they're under src/include)
48 # but they are used by libmirplatform, libmirclient or libmirserver
49- mir::default_server_socket;
50 mir::libraries_for_path*;
51 mir::logging::input_timestamp*;
52 mir::logging::log*;
53@@ -199,6 +198,10 @@
54 mir::dispatch::ReadableFd::dispatch*;
55 mir::dispatch::ReadableFd::relevant_events*;
56 mir::logger::Logger::log*;
57+
58+ # These symbols are supposed to be "private" (they're under src/include)
59+ # but they are used by libmirplatform, libmirclient or libmirserver
60+ mir::default_server_socket*;
61 };
62 local: *;
63 } MIR_COMMON_5;
64
65=== modified file 'src/include/common/mir/default_configuration.h'
66--- src/include/common/mir/default_configuration.h 2015-02-22 07:46:25 +0000
67+++ src/include/common/mir/default_configuration.h 2015-09-30 21:06:13 +0000
68@@ -21,9 +21,11 @@
69 #ifndef MIR_DEFAULT_CONFIGURATION_
70 #define MIR_DEFAULT_CONFIGURATION_
71
72+#include <string>
73+
74 namespace mir
75 {
76-extern const char *const default_server_socket;
77+extern std::string default_server_socket();
78 }
79
80 #endif
81
82=== modified file 'src/platform/options/default_configuration.cpp'
83--- src/platform/options/default_configuration.cpp 2015-09-24 15:42:21 +0000
84+++ src/platform/options/default_configuration.cpp 2015-09-30 21:06:13 +0000
85@@ -139,7 +139,7 @@
86 add_options()
87 (host_socket_opt, po::value<std::string>(),
88 "Host socket filename")
89- (server_socket_opt, po::value<std::string>()->default_value(::mir::default_server_socket),
90+ (server_socket_opt, po::value<std::string>()->default_value(::mir::default_server_socket()),
91 "Socket filename [string:default=$XDG_RUNTIME_DIR/mir_socket or /tmp/mir_socket]")
92 (no_server_socket_opt, "Do not provide a socket filename for client connections")
93 (arw_server_socket_opt, "Make socket filename globally rw (equivalent to chmod a=rw)")

Subscribers

People subscribed via source and target branches