Mir

Merge lp:~dandrader/mir/switchingBundle_lp1270964 into lp:mir

Proposed by Daniel d'Andrada
Status: Superseded
Proposed branch: lp:~dandrader/mir/switchingBundle_lp1270964
Merge into: lp:mir
Diff against target: 91 lines (+38/-2)
3 files modified
src/server/compositor/switching_bundle.cpp (+3/-1)
src/server/compositor/switching_bundle.h (+3/-0)
tests/unit-tests/compositor/test_switching_bundle.cpp (+32/-1)
To merge this branch: bzr merge lp:~dandrader/mir/switchingBundle_lp1270964
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Fixing
PS Jenkins bot (community) continuous-integration Needs Fixing
Mir development team Pending
Review via email: mp+202388@code.launchpad.net

This proposal has been superseded by a proposal from 2014-01-21.

Commit message

Only use SwitchingBundle::last_consumed after it has been set.
Otherwise SwitchingBundle::compositor_acquire could follow a bogus code path.
(LP: #1270964)

Description of the change

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

(1) The new test fails:
[ RUN ] SwitchingBundleTest.compositor_client_interleaved
/home/dan/bzr/mir/tmp.964/tests/unit-tests/compositor/test_switching_bundle.cpp:389: Failure
Value of: bundle.first_ready
  Actual: 1
Expected: 0
[ FAILED ] SwitchingBundleTest.compositor_client_interleaved (0 ms)
The same failure is occurring on desktop amd64 and armhf (Nexus 10).

(2) I'm undecided about this approach:
47 + friend class SwitchingBundleTest_compositor_client_interleaved_Test;
It's certainly a convenient solution for introspection. But that then allows the test to couple to internal members it shouldn't be coupled to.

And before anyone asks, this has nothing to do with bug 1270245 (which still happens with this branch).

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

(2) Please remove "friend class ..." and all the ASSERT_EQ statements that depend on it. They're not needed to produce a correct regression test, as shown here:
  https://code.launchpad.net/~vanvugt/mir/test-1270964/+merge/202406
Feel free to merge that branch into this one.

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> (1) The new test fails:
> [ RUN ] SwitchingBundleTest.compositor_client_interleaved
> /home/dan/bzr/mir/tmp.964/tests/unit-
> tests/compositor/test_switching_bundle.cpp:389: Failure
> Value of: bundle.first_ready
> Actual: 1
> Expected: 0
> [ FAILED ] SwitchingBundleTest.compositor_client_interleaved (0 ms)
> The same failure is occurring on desktop amd64 and armhf (Nexus 10).

Sorry, I rushed with that proposal right before my EOD.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/compositor/switching_bundle.cpp'
2--- src/server/compositor/switching_bundle.cpp 2014-01-20 16:40:37 +0000
3+++ src/server/compositor/switching_bundle.cpp 2014-01-21 12:34:43 +0000
4@@ -77,6 +77,7 @@
5 first_client{0}, nclients{0},
6 snapshot{-1}, nsnapshotters{0},
7 last_consumed{0},
8+ compositor_ever_acquired{false},
9 overlapping_compositors{false},
10 framedropping{false}, force_drop{0}
11 {
12@@ -273,7 +274,7 @@
13 int compositor;
14
15 // Multi-monitor acquires close to each other get the same frame:
16- bool same_frame = (frameno == last_consumed);
17+ bool same_frame = compositor_ever_acquired && (frameno == last_consumed);
18
19 int avail = nfree();
20 bool can_recycle = ncompositors || avail;
21@@ -303,6 +304,7 @@
22 nready--;
23 ncompositors++;
24 last_consumed = frameno;
25+ compositor_ever_acquired = true;
26 }
27
28 overlapping_compositors = (ncompositors > 1);
29
30=== modified file 'src/server/compositor/switching_bundle.h'
31--- src/server/compositor/switching_bundle.h 2014-01-13 06:12:33 +0000
32+++ src/server/compositor/switching_bundle.h 2014-01-21 12:34:43 +0000
33@@ -98,7 +98,10 @@
34 mutable std::mutex guard;
35 std::condition_variable cond;
36
37+ // the last frame acquired by the compositor. its value is invalid
38+ // if compositor_ever_acquired is false
39 unsigned long last_consumed;
40+ bool compositor_ever_acquired;
41
42 bool overlapping_compositors;
43
44
45=== modified file 'tests/unit-tests/compositor/test_switching_bundle.cpp'
46--- tests/unit-tests/compositor/test_switching_bundle.cpp 2014-01-13 06:12:33 +0000
47+++ tests/unit-tests/compositor/test_switching_bundle.cpp 2014-01-21 12:34:43 +0000
48@@ -329,6 +329,38 @@
49 }
50 }
51
52+/*
53+ Regression test for LP#1270964
54+ In the situation emulated here SwitchingBundle::last_consumed ise used without ever being set,
55+ thus its initial value of zero will wrongly be used and lead to bogus behavior.
56+ */
57+TEST_F(SwitchingBundleTest, compositor_client_interleaved)
58+{
59+ int nbuffers = 3;
60+ mc::SwitchingBundle bundle(nbuffers, allocator, basic_properties);
61+ mg::Buffer* client_buffer = nullptr;
62+
63+ client_buffer = bundle.client_acquire();
64+
65+ bundle.client_release(client_buffer);
66+
67+ client_buffer = bundle.client_acquire();
68+
69+ bundle.compositor_acquire(0);
70+
71+ //(nbufs=3,fcomp=2,ncomp=1,fready=0,nready=1,fclient=1,nclient=1) <-- BUG starts here
72+ // Should be:
73+ //(nbufs=3,fcomp=0,ncomp=1,fready=0,nready=0,fclient=1,nclient=1)
74+
75+ bundle.client_release(client_buffer);
76+
77+ //(nbufs=3,fcomp=2,ncomp=1,fready=0,nready=2,fclient=2,nclient=0)
78+ // Should be:
79+ //(nbufs=3,fcomp=0,ncomp=1,fready=1,nready=1,fclient=2,nclient=0)
80+
81+ client_buffer = bundle.client_acquire(); // <- would lock here if in buggy state
82+}
83+
84 TEST_F(SwitchingBundleTest, overlapping_compositors_get_different_frames)
85 {
86 // This test simulates bypass behaviour
87@@ -868,4 +900,3 @@
88 }
89 }
90 }
91-

Subscribers

People subscribed via source and target branches