Mir

Merge lp:~afrantzis/mir/fix-1454201-usc-crash-for-0.13 into lp:mir/0.13

Proposed by Alexandros Frantzis
Status: Merged
Merged at revision: 2539
Proposed branch: lp:~afrantzis/mir/fix-1454201-usc-crash-for-0.13
Merge into: lp:mir/0.13
Diff against target: 128 lines (+59/-0)
5 files modified
src/server/compositor/gl_program_family.cpp (+5/-0)
tests/unit-tests/compositor/CMakeLists.txt (+1/-0)
tests/unit-tests/compositor/test_gl_program_family.cpp (+49/-0)
tests/unit-tests/compositor/test_gl_renderer.cpp (+2/-0)
tests/unit-tests/examples/test_demo_renderer.cpp (+2/-0)
To merge this branch: bzr merge lp:~afrantzis/mir/fix-1454201-usc-crash-for-0.13
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+258863@code.launchpad.net

Commit message

compositor: Release current GL context before deleting shader objects to avoid crash (LP: #1454201)

Description of the change

compositor: Release current GL context before deleting shader objects to avoid crash (LP: #1454201)

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

Seems to work, but I'm not sure why.

Unfortunately...

$ bin/mir_unit_tests --gtest_filter=GLRenderer.*:DemoRenderer.*
...
[ FAILED ] 5 tests, listed below:
[ FAILED ] GLRenderer.disables_blending_for_rgbx_surfaces
[ FAILED ] GLRenderer.binds_for_every_primitive_when_tessellate_is_overridden
[ FAILED ] GLRenderer.opaque_alpha_channel
[ FAILED ] GLRenderer.generates_alpha_channel_content
[ FAILED ] DemoRenderer.detects_embellishments_on_renderables

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/compositor/gl_program_family.cpp'
2--- src/server/compositor/gl_program_family.cpp 2015-02-02 14:04:10 +0000
3+++ src/server/compositor/gl_program_family.cpp 2015-05-12 12:27:37 +0000
4@@ -19,6 +19,7 @@
5 #include "mir/compositor/gl_program_family.h"
6
7 #include <mutex>
8+#include <EGL/egl.h>
9
10 namespace mir { namespace compositor {
11
12@@ -53,6 +54,10 @@
13 // need any reference counting or to worry about how many copy constructions
14 // might have been followed by destructor calls during container resizes.
15
16+ // Workaround for lp:1454201. Release any current GL context to avoid crashes
17+ // in the glDelete* functions that follow.
18+ eglMakeCurrent(eglGetCurrentDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
19+
20 for (auto& p : program)
21 {
22 if (p.second.id)
23
24=== modified file 'tests/unit-tests/compositor/CMakeLists.txt'
25--- tests/unit-tests/compositor/CMakeLists.txt 2015-03-31 02:35:42 +0000
26+++ tests/unit-tests/compositor/CMakeLists.txt 2015-05-12 12:27:37 +0000
27@@ -4,6 +4,7 @@
28 ${CMAKE_CURRENT_SOURCE_DIR}/test_temporary_buffers.cpp
29 ${CMAKE_CURRENT_SOURCE_DIR}/test_multi_threaded_compositor.cpp
30 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_queue.cpp
31+ ${CMAKE_CURRENT_SOURCE_DIR}/test_gl_program_family.cpp
32 ${CMAKE_CURRENT_SOURCE_DIR}/test_gl_renderer.cpp
33 ${CMAKE_CURRENT_SOURCE_DIR}/test_gl_texture_cache.cpp
34 ${CMAKE_CURRENT_SOURCE_DIR}/test_occlusion.cpp
35
36=== added file 'tests/unit-tests/compositor/test_gl_program_family.cpp'
37--- tests/unit-tests/compositor/test_gl_program_family.cpp 1970-01-01 00:00:00 +0000
38+++ tests/unit-tests/compositor/test_gl_program_family.cpp 2015-05-12 12:27:37 +0000
39@@ -0,0 +1,49 @@
40+/*
41+ * Copyright © 2015 Canonical Ltd.
42+ *
43+ * This program is free software: you can redistribute it and/or modify
44+ * it under the terms of the GNU General Public License version 3 as
45+ * published by the Free Software Foundation.
46+ *
47+ * This program is distributed in the hope that it will be useful,
48+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
49+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50+ * GNU General Public License for more details.
51+ *
52+ * You should have received a copy of the GNU General Public License
53+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
54+ *
55+ * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
56+ */
57+
58+#include "mir/compositor/gl_program_family.h"
59+#include "mir_test_doubles/mock_gl.h"
60+#include "mir_test_doubles/mock_egl.h"
61+
62+#include <gtest/gtest.h>
63+#include <gmock/gmock.h>
64+
65+namespace mtd = mir::test::doubles;
66+namespace mc = mir::compositor;
67+
68+// Regression test for LP: #1454201
69+TEST(GLProgramFamily, releases_gl_context_before_deleting_shader_objects)
70+{
71+ using namespace testing;
72+
73+ NiceMock<mtd::MockGL> mock_gl;
74+ NiceMock<mtd::MockEGL> mock_egl;
75+
76+ ON_CALL(mock_gl, glCreateShader(_)).WillByDefault(Return(1));
77+ ON_CALL(mock_gl, glCreateProgram()).WillByDefault(Return(1));
78+
79+ {
80+ mc::GLProgramFamily family;
81+ family.add_program("vertex shader", "fragment shader");
82+
83+ InSequence seq;
84+ EXPECT_CALL(mock_egl, eglMakeCurrent(_,EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT));
85+ EXPECT_CALL(mock_gl, glDeleteProgram(_)).Times(1);
86+ EXPECT_CALL(mock_gl, glDeleteShader(_)).Times(2);
87+ }
88+}
89
90=== modified file 'tests/unit-tests/compositor/test_gl_renderer.cpp'
91--- tests/unit-tests/compositor/test_gl_renderer.cpp 2015-04-08 07:22:41 +0000
92+++ tests/unit-tests/compositor/test_gl_renderer.cpp 2015-05-12 12:27:37 +0000
93@@ -30,6 +30,7 @@
94 #include <mir_test_doubles/mock_buffer_stream.h>
95 #include <mir/compositor/buffer_stream.h>
96 #include <mir_test_doubles/mock_gl.h>
97+#include <mir_test_doubles/mock_egl.h>
98
99 using testing::SetArgPointee;
100 using testing::InSequence;
101@@ -143,6 +144,7 @@
102 }
103
104 testing::NiceMock<mtd::MockGL> mock_gl;
105+ testing::NiceMock<mtd::MockEGL> mock_egl;
106 std::shared_ptr<mtd::MockBuffer> mock_buffer;
107 mir::geometry::Rectangle display_area;
108 std::shared_ptr<testing::NiceMock<mtd::MockRenderable>> renderable;
109
110=== modified file 'tests/unit-tests/examples/test_demo_renderer.cpp'
111--- tests/unit-tests/examples/test_demo_renderer.cpp 2015-01-21 07:34:50 +0000
112+++ tests/unit-tests/examples/test_demo_renderer.cpp 2015-05-12 12:27:37 +0000
113@@ -20,6 +20,7 @@
114 #include "mir/compositor/destination_alpha.h"
115 #include "mir_test_doubles/fake_renderable.h"
116 #include "mir_test_doubles/mock_gl.h"
117+#include "mir_test_doubles/mock_egl.h"
118 #include "playground/demo-shell/demo_renderer.h"
119 #include <gtest/gtest.h>
120
121@@ -31,6 +32,7 @@
122 struct DemoRenderer : public testing::Test
123 {
124 testing::NiceMock<mtd::MockGL> mock_gl;
125+ testing::NiceMock<mtd::MockEGL> mock_egl;
126 geom::Rectangle region{{0, 0}, {100, 100}};
127 mc::DestinationAlpha dest_alpha{mc::DestinationAlpha::opaque};
128 int const shadow_radius{20};

Subscribers

People subscribed via source and target branches