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
=== modified file 'src/server/compositor/switching_bundle.cpp'
--- src/server/compositor/switching_bundle.cpp 2014-01-20 16:40:37 +0000
+++ src/server/compositor/switching_bundle.cpp 2014-01-21 12:34:43 +0000
@@ -77,6 +77,7 @@
77 first_client{0}, nclients{0},77 first_client{0}, nclients{0},
78 snapshot{-1}, nsnapshotters{0},78 snapshot{-1}, nsnapshotters{0},
79 last_consumed{0},79 last_consumed{0},
80 compositor_ever_acquired{false},
80 overlapping_compositors{false},81 overlapping_compositors{false},
81 framedropping{false}, force_drop{0}82 framedropping{false}, force_drop{0}
82{83{
@@ -273,7 +274,7 @@
273 int compositor;274 int compositor;
274275
275 // Multi-monitor acquires close to each other get the same frame:276 // Multi-monitor acquires close to each other get the same frame:
276 bool same_frame = (frameno == last_consumed);277 bool same_frame = compositor_ever_acquired && (frameno == last_consumed);
277278
278 int avail = nfree();279 int avail = nfree();
279 bool can_recycle = ncompositors || avail;280 bool can_recycle = ncompositors || avail;
@@ -303,6 +304,7 @@
303 nready--;304 nready--;
304 ncompositors++;305 ncompositors++;
305 last_consumed = frameno;306 last_consumed = frameno;
307 compositor_ever_acquired = true;
306 }308 }
307309
308 overlapping_compositors = (ncompositors > 1);310 overlapping_compositors = (ncompositors > 1);
309311
=== modified file 'src/server/compositor/switching_bundle.h'
--- src/server/compositor/switching_bundle.h 2014-01-13 06:12:33 +0000
+++ src/server/compositor/switching_bundle.h 2014-01-21 12:34:43 +0000
@@ -98,7 +98,10 @@
98 mutable std::mutex guard;98 mutable std::mutex guard;
99 std::condition_variable cond;99 std::condition_variable cond;
100100
101 // the last frame acquired by the compositor. its value is invalid
102 // if compositor_ever_acquired is false
101 unsigned long last_consumed;103 unsigned long last_consumed;
104 bool compositor_ever_acquired;
102105
103 bool overlapping_compositors;106 bool overlapping_compositors;
104107
105108
=== modified file 'tests/unit-tests/compositor/test_switching_bundle.cpp'
--- tests/unit-tests/compositor/test_switching_bundle.cpp 2014-01-13 06:12:33 +0000
+++ tests/unit-tests/compositor/test_switching_bundle.cpp 2014-01-21 12:34:43 +0000
@@ -329,6 +329,38 @@
329 }329 }
330}330}
331331
332/*
333 Regression test for LP#1270964
334 In the situation emulated here SwitchingBundle::last_consumed ise used without ever being set,
335 thus its initial value of zero will wrongly be used and lead to bogus behavior.
336 */
337TEST_F(SwitchingBundleTest, compositor_client_interleaved)
338{
339 int nbuffers = 3;
340 mc::SwitchingBundle bundle(nbuffers, allocator, basic_properties);
341 mg::Buffer* client_buffer = nullptr;
342
343 client_buffer = bundle.client_acquire();
344
345 bundle.client_release(client_buffer);
346
347 client_buffer = bundle.client_acquire();
348
349 bundle.compositor_acquire(0);
350
351 //(nbufs=3,fcomp=2,ncomp=1,fready=0,nready=1,fclient=1,nclient=1) <-- BUG starts here
352 // Should be:
353 //(nbufs=3,fcomp=0,ncomp=1,fready=0,nready=0,fclient=1,nclient=1)
354
355 bundle.client_release(client_buffer);
356
357 //(nbufs=3,fcomp=2,ncomp=1,fready=0,nready=2,fclient=2,nclient=0)
358 // Should be:
359 //(nbufs=3,fcomp=0,ncomp=1,fready=1,nready=1,fclient=2,nclient=0)
360
361 client_buffer = bundle.client_acquire(); // <- would lock here if in buggy state
362}
363
332TEST_F(SwitchingBundleTest, overlapping_compositors_get_different_frames)364TEST_F(SwitchingBundleTest, overlapping_compositors_get_different_frames)
333{365{
334 // This test simulates bypass behaviour366 // This test simulates bypass behaviour
@@ -868,4 +900,3 @@
868 }900 }
869 }901 }
870}902}
871

Subscribers

People subscribed via source and target branches