Merge lp:~andreas-pokorny/mir/fix-1528135 into lp:mir
- fix-1528135
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Andreas Pokorny |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3255 |
Proposed branch: | lp:~andreas-pokorny/mir/fix-1528135 |
Merge into: | lp:mir |
Diff against target: |
315 lines (+187/-45) 5 files modified
debian/mir-test-tools.install (+1/-0) src/server/graphics/default_configuration.cpp (+57/-45) tests/acceptance-tests/test_server_shutdown.cpp (+20/-0) tests/mir_test_framework/CMakeLists.txt (+20/-0) tests/mir_test_framework/platform_graphics_throw.cpp (+89/-0) |
To merge this branch: | bzr merge lp:~andreas-pokorny/mir/fix-1528135 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Mir CI Bot | continuous-integration | Approve | |
Chris Halse Rogers | Approve | ||
Daniel van Vugt | Abstain | ||
Kevin DuBois (community) | Approve | ||
Alan Griffiths | Approve | ||
Review via email:
|
Commit message
Handle exceptions during platform construction
Since we no longer assign the mir::SharedLibrary instance for a graphics platform to a global variable or a DefaultServerCo
Description of the change
I was looking for a more generic solution. But the problem cannot be solved from within make_module_ptr since make_module_ptr is still within the shared library. I.e. one attempt was to attach the SharedLibrary to the exception object instead. That helped only halfways - the exception diagnostic could be printed but still the unwinding information was accessed by libstdc++ again after that. So it just crashed later. I only see a solution that catches the exception outside the library but not too far so that the offending library is still alive...
So the original solution remains unchanged.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) wrote : | # |
No test?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3240
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3240
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel van Vugt (vanvugt) wrote : | # |
I'm all for fixing bug 1528135 by any means. But it doesn't help the fact that make_module_ptr is fundamentally unsafe and needs fixing or removing completely. We can however treat them as separate issues...
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andreas Pokorny (andreas-pokorny) wrote : | # |
> No test?
Oh right I just need a platform that throws on construcion.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andreas Pokorny (andreas-pokorny) wrote : | # |
Ok this need another change. The test platform is incomplete the exception is thrown to early..
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3241
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3242
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3241
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3242
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3242
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andreas Pokorny (andreas-pokorny) wrote : | # |
8: [----------] 1 test from ServerShutdownW
8: [ RUN ] ServerShutdownW
8: unknown file: Failure
8: C++ exception with description "unrecognised option 'logging'" thrown in the test body.
8: [ FAILED ] ServerShutdownW
8: [----------] 1 test from ServerShutdownW
8:
not the exception i was looking for..
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3243
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3243
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3244
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3244
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3245
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3245
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'debian/mir-test-tools.install' |
2 | --- debian/mir-test-tools.install 2015-10-13 02:10:53 +0000 |
3 | +++ debian/mir-test-tools.install 2016-01-20 18:02:01 +0000 |
4 | @@ -9,6 +9,7 @@ |
5 | usr/lib/*/mir/tools/libmirclientlttng.so |
6 | usr/lib/*/mir/tools/libmirserverlttng.so |
7 | usr/lib/*/mir/server-platform/graphics-dummy.so |
8 | +usr/lib/*/mir/server-platform/graphics-throw.so |
9 | usr/lib/*/mir/server-platform/input-stub.so |
10 | usr/lib/*/mir/client-platform/dummy.so |
11 | usr/share/udev_recordings |
12 | |
13 | === modified file 'src/server/graphics/default_configuration.cpp' |
14 | --- src/server/graphics/default_configuration.cpp 2016-01-18 15:48:38 +0000 |
15 | +++ src/server/graphics/default_configuration.cpp 2016-01-20 18:02:01 +0000 |
16 | @@ -38,12 +38,14 @@ |
17 | #include "mir/abnormal_exit.h" |
18 | #include "mir/emergency_cleanup.h" |
19 | #include "mir/log.h" |
20 | +#include "mir/report_exception.h" |
21 | |
22 | #include "mir_toolkit/common.h" |
23 | |
24 | #include <boost/throw_exception.hpp> |
25 | |
26 | #include <map> |
27 | +#include <sstream> |
28 | |
29 | namespace mg = mir::graphics; |
30 | namespace ml = mir::logging; |
31 | @@ -73,51 +75,61 @@ |
32 | [this]()->std::shared_ptr<mg::Platform> |
33 | { |
34 | std::shared_ptr<mir::SharedLibrary> platform_library; |
35 | - |
36 | - // if a host socket is set we should use the host graphics module to create a "guest" platform |
37 | - if (the_options()->is_set(options::host_socket_opt)) |
38 | - { |
39 | - auto const host_connection = the_host_connection(); |
40 | - |
41 | - platform_library = std::make_shared<mir::SharedLibrary>(host_connection->graphics_platform_library()); |
42 | - |
43 | - auto create_guest_platform = platform_library->load_function<mg::CreateGuestPlatform>( |
44 | - "create_guest_platform", |
45 | - MIR_SERVER_GRAPHICS_PLATFORM_VERSION); |
46 | - |
47 | - return create_guest_platform(the_display_report(), host_connection); |
48 | - } |
49 | - |
50 | - // fallback to standalone if host socket is unset |
51 | - if (the_options()->is_set(options::platform_graphics_lib)) |
52 | - { |
53 | - platform_library = std::make_shared<mir::SharedLibrary>(the_options()->get<std::string>(options::platform_graphics_lib)); |
54 | - } |
55 | - else |
56 | - { |
57 | - auto const& path = the_options()->get<std::string>(options::platform_path); |
58 | - auto platforms = mir::libraries_for_path(path, *the_shared_library_prober_report()); |
59 | - if (platforms.empty()) |
60 | - { |
61 | - auto msg = "Failed to find any platform plugins in: " + path; |
62 | - throw std::runtime_error(msg.c_str()); |
63 | - } |
64 | - platform_library = mir::graphics::module_for_device(platforms, dynamic_cast<mir::options::ProgramOption&>(*the_options())); |
65 | - } |
66 | - auto create_host_platform = platform_library->load_function<mg::CreateHostPlatform>( |
67 | - "create_host_platform", |
68 | - MIR_SERVER_GRAPHICS_PLATFORM_VERSION); |
69 | - auto describe_module = platform_library->load_function<mg::DescribeModule>( |
70 | - "describe_graphics_module", |
71 | - MIR_SERVER_GRAPHICS_PLATFORM_VERSION); |
72 | - auto description = describe_module(); |
73 | - mir::log_info("Selected driver: %s (version %d.%d.%d)", |
74 | - description->name, |
75 | - description->major_version, |
76 | - description->minor_version, |
77 | - description->micro_version); |
78 | - |
79 | - return create_host_platform(the_options(), the_emergency_cleanup(), the_display_report()); |
80 | + std::stringstream error_report; |
81 | + try |
82 | + { |
83 | + // if a host socket is set we should use the host graphics module to create a "guest" platform |
84 | + if (the_options()->is_set(options::host_socket_opt)) |
85 | + { |
86 | + auto const host_connection = the_host_connection(); |
87 | + |
88 | + platform_library = std::make_shared<mir::SharedLibrary>(host_connection->graphics_platform_library()); |
89 | + |
90 | + auto create_guest_platform = platform_library->load_function<mg::CreateGuestPlatform>( |
91 | + "create_guest_platform", |
92 | + MIR_SERVER_GRAPHICS_PLATFORM_VERSION); |
93 | + |
94 | + return create_guest_platform(the_display_report(), host_connection); |
95 | + } |
96 | + |
97 | + // fallback to standalone if host socket is unset |
98 | + if (the_options()->is_set(options::platform_graphics_lib)) |
99 | + { |
100 | + platform_library = std::make_shared<mir::SharedLibrary>(the_options()->get<std::string>(options::platform_graphics_lib)); |
101 | + } |
102 | + else |
103 | + { |
104 | + auto const& path = the_options()->get<std::string>(options::platform_path); |
105 | + auto platforms = mir::libraries_for_path(path, *the_shared_library_prober_report()); |
106 | + if (platforms.empty()) |
107 | + { |
108 | + auto msg = "Failed to find any platform plugins in: " + path; |
109 | + throw std::runtime_error(msg.c_str()); |
110 | + } |
111 | + platform_library = mir::graphics::module_for_device(platforms, dynamic_cast<mir::options::ProgramOption&>(*the_options())); |
112 | + } |
113 | + auto create_host_platform = platform_library->load_function<mg::CreateHostPlatform>( |
114 | + "create_host_platform", |
115 | + MIR_SERVER_GRAPHICS_PLATFORM_VERSION); |
116 | + auto describe_module = platform_library->load_function<mg::DescribeModule>( |
117 | + "describe_graphics_module", |
118 | + MIR_SERVER_GRAPHICS_PLATFORM_VERSION); |
119 | + auto description = describe_module(); |
120 | + mir::log_info("Selected driver: %s (version %d.%d.%d)", |
121 | + description->name, |
122 | + description->major_version, |
123 | + description->minor_version, |
124 | + description->micro_version); |
125 | + |
126 | + return create_host_platform(the_options(), the_emergency_cleanup(), the_display_report()); |
127 | + } |
128 | + catch(...) |
129 | + { |
130 | + // access exception information before platform library gets unloaded |
131 | + error_report << "Exception while creating graphics platform" << std::endl; |
132 | + mir::report_exception(error_report); |
133 | + } |
134 | + BOOST_THROW_EXCEPTION(std::runtime_error(error_report.str())); |
135 | }); |
136 | } |
137 | |
138 | |
139 | === modified file 'tests/acceptance-tests/test_server_shutdown.cpp' |
140 | --- tests/acceptance-tests/test_server_shutdown.cpp 2015-08-20 08:40:03 +0000 |
141 | +++ tests/acceptance-tests/test_server_shutdown.cpp 2016-01-20 18:02:01 +0000 |
142 | @@ -17,14 +17,19 @@ |
143 | */ |
144 | |
145 | #include "mir/fatal.h" |
146 | +#include "mir/server.h" |
147 | |
148 | #include "mir_test_framework/interprocess_client_server_test.h" |
149 | #include "mir_test_framework/process.h" |
150 | +#include "mir_test_framework/temporary_environment_value.h" |
151 | +#include "mir_test_framework/executable_path.h" |
152 | +#include "mir/test/doubles/null_logger.h" |
153 | |
154 | #include <gtest/gtest.h> |
155 | |
156 | namespace mt = mir::test; |
157 | namespace mtf = mir_test_framework; |
158 | +namespace mtd = mt::doubles; |
159 | |
160 | using ServerShutdown = mtf::InterprocessClientServerTest; |
161 | |
162 | @@ -50,6 +55,21 @@ |
163 | } |
164 | } |
165 | |
166 | +// Regression test for LP: #1528135 |
167 | +TEST(ServerShutdownWithException, clean_shutdown_on_plugin_construction_exception) |
168 | +{ |
169 | + char const* argv = "ServerShutdownWithException"; |
170 | + mtf::TemporaryEnvironmentValue graphics_platform("MIR_SERVER_PLATFORM_GRAPHICS_LIB", mtf::server_platform("graphics-throw.so").c_str()); |
171 | + mtf::TemporaryEnvironmentValue input_platform("MIR_SERVER_PLATFORM_INPUT_LIB", mtf::server_platform("input-stub.so").c_str()); |
172 | + mir::Server server; |
173 | + |
174 | + server.add_configuration_option(mtd::logging_opt, mtd::logging_descr, false); |
175 | + server.set_command_line_handler([](int, char const* const*){}); |
176 | + server.set_command_line(0, &argv); |
177 | + server.apply_settings(); |
178 | + server.run(); |
179 | +} |
180 | + |
181 | using ServerShutdownDeathTest = ServerShutdown; |
182 | |
183 | TEST_F(ServerShutdownDeathTest, abort_removes_endpoint) |
184 | |
185 | === modified file 'tests/mir_test_framework/CMakeLists.txt' |
186 | --- tests/mir_test_framework/CMakeLists.txt 2016-01-12 03:56:59 +0000 |
187 | +++ tests/mir_test_framework/CMakeLists.txt 2016-01-20 18:02:01 +0000 |
188 | @@ -154,6 +154,25 @@ |
189 | LINK_FLAGS "-Wl,--version-script,${server_symbol_map}" |
190 | ) |
191 | |
192 | +add_library( |
193 | + mirplatformgraphicsthrow MODULE |
194 | + platform_graphics_throw.cpp |
195 | +) |
196 | + |
197 | +target_link_libraries( |
198 | + mirplatformgraphicsthrow |
199 | + |
200 | + mirplatform |
201 | +) |
202 | + |
203 | +set_target_properties( |
204 | + mirplatformgraphicsthrow PROPERTIES; |
205 | + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/server-modules |
206 | + OUTPUT_NAME graphics-throw |
207 | + PREFIX "" |
208 | + LINK_FLAGS "-Wl,--version-script,${server_symbol_map}" |
209 | +) |
210 | + |
211 | add_custom_command(TARGET mir-test-framework-static POST_BUILD |
212 | COMMAND ${CMAKE_COMMAND} -E copy_directory |
213 | ${CMAKE_CURRENT_SOURCE_DIR}/udev_recordings ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/udev_recordings |
214 | @@ -168,6 +187,7 @@ |
215 | string (REPLACE " -Wl,--no-undefined" " " CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) |
216 | |
217 | install(TARGETS mirplatformgraphicsstub LIBRARY DESTINATION ${MIR_SERVER_PLATFORM_PATH}) |
218 | +install(TARGETS mirplatformgraphicsthrow LIBRARY DESTINATION ${MIR_SERVER_PLATFORM_PATH}) |
219 | |
220 | install(TARGETS mirclientplatformstub LIBRARY DESTINATION ${MIR_CLIENT_PLATFORM_PATH}) |
221 | |
222 | |
223 | === added file 'tests/mir_test_framework/platform_graphics_throw.cpp' |
224 | --- tests/mir_test_framework/platform_graphics_throw.cpp 1970-01-01 00:00:00 +0000 |
225 | +++ tests/mir_test_framework/platform_graphics_throw.cpp 2016-01-20 18:02:01 +0000 |
226 | @@ -0,0 +1,89 @@ |
227 | +/* |
228 | + * Copyright © 2015 Canonical Ltd. |
229 | + * |
230 | + * This program is free software: you can redistribute it and/or modify it |
231 | + * under the terms of the GNU General Public License version 3, |
232 | + * as published by the Free Software Foundation. |
233 | + * |
234 | + * This program is distributed in the hope that it will be useful, |
235 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
236 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
237 | + * GNU General Public License for more details. |
238 | + * |
239 | + * You should have received a copy of the GNU General Public License |
240 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
241 | + * |
242 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
243 | + */ |
244 | + |
245 | +#include "mir/graphics/platform.h" |
246 | +#include "mir/test/doubles/null_platform.h" |
247 | +#include "mir/assert_module_entry_point.h" |
248 | +#include "mir/libname.h" |
249 | + |
250 | +#include <boost/throw_exception.hpp> |
251 | + |
252 | +namespace mg = mir::graphics; |
253 | +namespace mo = mir::options; |
254 | +namespace mir |
255 | +{ |
256 | +namespace options |
257 | +{ |
258 | +class ProgramOption; |
259 | +} |
260 | +} |
261 | + |
262 | +namespace |
263 | +{ |
264 | +class ExceptionThrowingPlatform : public mir::test::doubles::NullPlatform |
265 | +{ |
266 | +public: |
267 | + ExceptionThrowingPlatform() |
268 | + { |
269 | + BOOST_THROW_EXCEPTION(std::runtime_error("Exception during construction")); |
270 | + } |
271 | +}; |
272 | + |
273 | +} |
274 | + |
275 | +mg::PlatformPriority probe_graphics_platform(mo::ProgramOption const& /*options*/) |
276 | +{ |
277 | + mir::assert_entry_point_signature<mg::PlatformProbe>(&probe_graphics_platform); |
278 | + return mg::PlatformPriority::unsupported; |
279 | +} |
280 | + |
281 | +mir::ModuleProperties const description { |
282 | + "throw-on-creation", |
283 | + MIR_VERSION_MAJOR, |
284 | + MIR_VERSION_MINOR, |
285 | + MIR_VERSION_MICRO, |
286 | + mir::libname() |
287 | +}; |
288 | + |
289 | +mir::ModuleProperties const* describe_graphics_module() |
290 | +{ |
291 | + mir::assert_entry_point_signature<mg::DescribeModule>(&describe_graphics_module); |
292 | + return &description; |
293 | +} |
294 | + |
295 | +void add_graphics_platform_options(boost::program_options::options_description&) |
296 | +{ |
297 | + mir::assert_entry_point_signature<mg::AddPlatformOptions>(&add_graphics_platform_options); |
298 | +} |
299 | + |
300 | +mir::UniqueModulePtr<mg::Platform> create_host_platform( |
301 | + std::shared_ptr<mo::Option> const&, |
302 | + std::shared_ptr<mir::EmergencyCleanupRegistry> const&, |
303 | + std::shared_ptr<mg::DisplayReport> const&) |
304 | +{ |
305 | + mir::assert_entry_point_signature<mg::CreateHostPlatform>(&create_host_platform); |
306 | + return mir::make_module_ptr<ExceptionThrowingPlatform>(); |
307 | +} |
308 | + |
309 | +mir::UniqueModulePtr<mg::Platform> create_guest_platform( |
310 | + std::shared_ptr<mg::DisplayReport> const&, |
311 | + std::shared_ptr<mg::NestedContext> const&) |
312 | +{ |
313 | + mir::assert_entry_point_signature<mg::CreateGuestPlatform>(&create_guest_platform); |
314 | + return mir::make_module_ptr<ExceptionThrowingPlatform>(); |
315 | +} |
PASSED: Continuous integration, rev:3240 /mir-jenkins. ubuntu. com/job/ mir-ci/ 40/ /mir-jenkins. ubuntu. com/job/ generic- update- mp/39/console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /mir-jenkins. ubuntu. com/job/ mir-ci/ 40/rebuild
https:/