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
=== modified file 'src/server/compositor/gl_program_family.cpp'
--- src/server/compositor/gl_program_family.cpp 2015-02-02 14:04:10 +0000
+++ src/server/compositor/gl_program_family.cpp 2015-05-12 12:27:37 +0000
@@ -19,6 +19,7 @@
19#include "mir/compositor/gl_program_family.h"19#include "mir/compositor/gl_program_family.h"
2020
21#include <mutex>21#include <mutex>
22#include <EGL/egl.h>
2223
23namespace mir { namespace compositor {24namespace mir { namespace compositor {
2425
@@ -53,6 +54,10 @@
53 // need any reference counting or to worry about how many copy constructions54 // need any reference counting or to worry about how many copy constructions
54 // might have been followed by destructor calls during container resizes.55 // might have been followed by destructor calls during container resizes.
5556
57 // Workaround for lp:1454201. Release any current GL context to avoid crashes
58 // in the glDelete* functions that follow.
59 eglMakeCurrent(eglGetCurrentDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
60
56 for (auto& p : program)61 for (auto& p : program)
57 {62 {
58 if (p.second.id)63 if (p.second.id)
5964
=== modified file 'tests/unit-tests/compositor/CMakeLists.txt'
--- tests/unit-tests/compositor/CMakeLists.txt 2015-03-31 02:35:42 +0000
+++ tests/unit-tests/compositor/CMakeLists.txt 2015-05-12 12:27:37 +0000
@@ -4,6 +4,7 @@
4 ${CMAKE_CURRENT_SOURCE_DIR}/test_temporary_buffers.cpp4 ${CMAKE_CURRENT_SOURCE_DIR}/test_temporary_buffers.cpp
5 ${CMAKE_CURRENT_SOURCE_DIR}/test_multi_threaded_compositor.cpp5 ${CMAKE_CURRENT_SOURCE_DIR}/test_multi_threaded_compositor.cpp
6 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_queue.cpp6 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_queue.cpp
7 ${CMAKE_CURRENT_SOURCE_DIR}/test_gl_program_family.cpp
7 ${CMAKE_CURRENT_SOURCE_DIR}/test_gl_renderer.cpp8 ${CMAKE_CURRENT_SOURCE_DIR}/test_gl_renderer.cpp
8 ${CMAKE_CURRENT_SOURCE_DIR}/test_gl_texture_cache.cpp9 ${CMAKE_CURRENT_SOURCE_DIR}/test_gl_texture_cache.cpp
9 ${CMAKE_CURRENT_SOURCE_DIR}/test_occlusion.cpp10 ${CMAKE_CURRENT_SOURCE_DIR}/test_occlusion.cpp
1011
=== added file 'tests/unit-tests/compositor/test_gl_program_family.cpp'
--- tests/unit-tests/compositor/test_gl_program_family.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit-tests/compositor/test_gl_program_family.cpp 2015-05-12 12:27:37 +0000
@@ -0,0 +1,49 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#include "mir/compositor/gl_program_family.h"
20#include "mir_test_doubles/mock_gl.h"
21#include "mir_test_doubles/mock_egl.h"
22
23#include <gtest/gtest.h>
24#include <gmock/gmock.h>
25
26namespace mtd = mir::test::doubles;
27namespace mc = mir::compositor;
28
29// Regression test for LP: #1454201
30TEST(GLProgramFamily, releases_gl_context_before_deleting_shader_objects)
31{
32 using namespace testing;
33
34 NiceMock<mtd::MockGL> mock_gl;
35 NiceMock<mtd::MockEGL> mock_egl;
36
37 ON_CALL(mock_gl, glCreateShader(_)).WillByDefault(Return(1));
38 ON_CALL(mock_gl, glCreateProgram()).WillByDefault(Return(1));
39
40 {
41 mc::GLProgramFamily family;
42 family.add_program("vertex shader", "fragment shader");
43
44 InSequence seq;
45 EXPECT_CALL(mock_egl, eglMakeCurrent(_,EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT));
46 EXPECT_CALL(mock_gl, glDeleteProgram(_)).Times(1);
47 EXPECT_CALL(mock_gl, glDeleteShader(_)).Times(2);
48 }
49}
050
=== modified file 'tests/unit-tests/compositor/test_gl_renderer.cpp'
--- tests/unit-tests/compositor/test_gl_renderer.cpp 2015-04-08 07:22:41 +0000
+++ tests/unit-tests/compositor/test_gl_renderer.cpp 2015-05-12 12:27:37 +0000
@@ -30,6 +30,7 @@
30#include <mir_test_doubles/mock_buffer_stream.h>30#include <mir_test_doubles/mock_buffer_stream.h>
31#include <mir/compositor/buffer_stream.h>31#include <mir/compositor/buffer_stream.h>
32#include <mir_test_doubles/mock_gl.h>32#include <mir_test_doubles/mock_gl.h>
33#include <mir_test_doubles/mock_egl.h>
3334
34using testing::SetArgPointee;35using testing::SetArgPointee;
35using testing::InSequence;36using testing::InSequence;
@@ -143,6 +144,7 @@
143 }144 }
144145
145 testing::NiceMock<mtd::MockGL> mock_gl;146 testing::NiceMock<mtd::MockGL> mock_gl;
147 testing::NiceMock<mtd::MockEGL> mock_egl;
146 std::shared_ptr<mtd::MockBuffer> mock_buffer;148 std::shared_ptr<mtd::MockBuffer> mock_buffer;
147 mir::geometry::Rectangle display_area;149 mir::geometry::Rectangle display_area;
148 std::shared_ptr<testing::NiceMock<mtd::MockRenderable>> renderable;150 std::shared_ptr<testing::NiceMock<mtd::MockRenderable>> renderable;
149151
=== modified file 'tests/unit-tests/examples/test_demo_renderer.cpp'
--- tests/unit-tests/examples/test_demo_renderer.cpp 2015-01-21 07:34:50 +0000
+++ tests/unit-tests/examples/test_demo_renderer.cpp 2015-05-12 12:27:37 +0000
@@ -20,6 +20,7 @@
20#include "mir/compositor/destination_alpha.h"20#include "mir/compositor/destination_alpha.h"
21#include "mir_test_doubles/fake_renderable.h"21#include "mir_test_doubles/fake_renderable.h"
22#include "mir_test_doubles/mock_gl.h"22#include "mir_test_doubles/mock_gl.h"
23#include "mir_test_doubles/mock_egl.h"
23#include "playground/demo-shell/demo_renderer.h"24#include "playground/demo-shell/demo_renderer.h"
24#include <gtest/gtest.h>25#include <gtest/gtest.h>
2526
@@ -31,6 +32,7 @@
31struct DemoRenderer : public testing::Test32struct DemoRenderer : public testing::Test
32{33{
33 testing::NiceMock<mtd::MockGL> mock_gl;34 testing::NiceMock<mtd::MockGL> mock_gl;
35 testing::NiceMock<mtd::MockEGL> mock_egl;
34 geom::Rectangle region{{0, 0}, {100, 100}};36 geom::Rectangle region{{0, 0}, {100, 100}};
35 mc::DestinationAlpha dest_alpha{mc::DestinationAlpha::opaque};37 mc::DestinationAlpha dest_alpha{mc::DestinationAlpha::opaque};
36 int const shadow_radius{20};38 int const shadow_radius{20};

Subscribers

People subscribed via source and target branches