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
=== modified file 'src/client/mir_connection_api.cpp'
--- src/client/mir_connection_api.cpp 2015-07-25 08:10:48 +0000
+++ src/client/mir_connection_api.cpp 2015-09-30 21:06:13 +0000
@@ -64,7 +64,7 @@
64 if (socket_env)64 if (socket_env)
65 sock = socket_env;65 sock = socket_env;
66 else66 else
67 sock = mir::default_server_socket;67 sock = mir::default_server_socket();
68 }68 }
6969
70 auto const conf = configuration(sock);70 auto const conf = configuration(sock);
7171
=== modified file 'src/common/env/default_configuration.cpp'
--- src/common/env/default_configuration.cpp 2013-12-12 07:51:12 +0000
+++ src/common/env/default_configuration.cpp 2015-09-30 21:06:13 +0000
@@ -21,9 +21,7 @@
21#include <cstdlib>21#include <cstdlib>
22#include <sstream>22#include <sstream>
2323
24namespace24std::string mir::default_server_socket()
25{
26const char* init()
27{25{
28 std::ostringstream formatter;26 std::ostringstream formatter;
2927
@@ -32,10 +30,5 @@
3230
33 formatter << dir << "/mir_socket";31 formatter << dir << "/mir_socket";
3432
35 static auto result = formatter.str();33 return formatter.str();
36 return result.c_str();34}
37}
38}
39
40const char *const mir::default_server_socket = init();
41
4235
=== modified file 'src/common/symbols.map'
--- src/common/symbols.map 2015-09-17 06:06:28 +0000
+++ src/common/symbols.map 2015-09-30 21:06:13 +0000
@@ -105,7 +105,6 @@
105 105
106 # These symbols are supposed to be "private" (they're under src/include)106 # These symbols are supposed to be "private" (they're under src/include)
107 # but they are used by libmirplatform, libmirclient or libmirserver107 # but they are used by libmirplatform, libmirclient or libmirserver
108 mir::default_server_socket;
109 mir::libraries_for_path*;108 mir::libraries_for_path*;
110 mir::logging::input_timestamp*;109 mir::logging::input_timestamp*;
111 mir::logging::log*;110 mir::logging::log*;
@@ -199,6 +198,10 @@
199 mir::dispatch::ReadableFd::dispatch*;198 mir::dispatch::ReadableFd::dispatch*;
200 mir::dispatch::ReadableFd::relevant_events*;199 mir::dispatch::ReadableFd::relevant_events*;
201 mir::logger::Logger::log*;200 mir::logger::Logger::log*;
201
202 # These symbols are supposed to be "private" (they're under src/include)
203 # but they are used by libmirplatform, libmirclient or libmirserver
204 mir::default_server_socket*;
202 };205 };
203 local: *;206 local: *;
204} MIR_COMMON_5;207} MIR_COMMON_5;
205208
=== modified file 'src/include/common/mir/default_configuration.h'
--- src/include/common/mir/default_configuration.h 2015-02-22 07:46:25 +0000
+++ src/include/common/mir/default_configuration.h 2015-09-30 21:06:13 +0000
@@ -21,9 +21,11 @@
21#ifndef MIR_DEFAULT_CONFIGURATION_21#ifndef MIR_DEFAULT_CONFIGURATION_
22#define MIR_DEFAULT_CONFIGURATION_22#define MIR_DEFAULT_CONFIGURATION_
2323
24#include <string>
25
24namespace mir26namespace mir
25{27{
26extern const char *const default_server_socket;28extern std::string default_server_socket();
27}29}
2830
29#endif31#endif
3032
=== modified file 'src/platform/options/default_configuration.cpp'
--- src/platform/options/default_configuration.cpp 2015-09-24 15:42:21 +0000
+++ src/platform/options/default_configuration.cpp 2015-09-30 21:06:13 +0000
@@ -139,7 +139,7 @@
139 add_options()139 add_options()
140 (host_socket_opt, po::value<std::string>(),140 (host_socket_opt, po::value<std::string>(),
141 "Host socket filename")141 "Host socket filename")
142 (server_socket_opt, po::value<std::string>()->default_value(::mir::default_server_socket),142 (server_socket_opt, po::value<std::string>()->default_value(::mir::default_server_socket()),
143 "Socket filename [string:default=$XDG_RUNTIME_DIR/mir_socket or /tmp/mir_socket]")143 "Socket filename [string:default=$XDG_RUNTIME_DIR/mir_socket or /tmp/mir_socket]")
144 (no_server_socket_opt, "Do not provide a socket filename for client connections")144 (no_server_socket_opt, "Do not provide a socket filename for client connections")
145 (arw_server_socket_opt, "Make socket filename globally rw (equivalent to chmod a=rw)")145 (arw_server_socket_opt, "Make socket filename globally rw (equivalent to chmod a=rw)")

Subscribers

People subscribed via source and target branches