Mir

Comment 0 for bug 1270964

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

SwitchingBundle:: last_consumed can be used without ever being set, thus its initial value of zero can wrongly be used and lead to bogus behavior.

TEST_F(SwitchingBundleTest, compositor_client_interleaved)
{
    int nbuffers = 3;
    mc::SwitchingBundle bundle(nbuffers, allocator, basic_properties);
    mg::Buffer* client_buffer = nullptr;

    //(nbufs=3,fcomp=0,ncomp=0,fready=0,nready=0,fclient=0,nclient=0)

    client_buffer = bundle.client_acquire();

    //(nbufs=3,fcomp=0,ncomp=0,fready=0,nready=0,fclient=0,nclient=1)

    bundle.client_release(client_buffer);

    //(nbufs=3,fcomp=0,ncomp=0,fready=0,nready=1,fclient=1,nclient=0)

    client_buffer = bundle.client_acquire();

    //(nbufs=3,fcomp=0,ncomp=0,fready=0,nready=1,fclient=1,nclient=1)

    bundle.compositor_acquire(0);

    //(nbufs=3,fcomp=2,ncomp=1,fready=0,nready=1,fclient=1,nclient=1) <-- BUG starts here
    // Should be:
    //(nbufs=3,fcomp=0,ncomp=1,fready=0,nready=0,fclient=1,nclient=1)

    bundle.client_release(client_buffer);

    //(nbufs=3,fcomp=2,ncomp=1,fready=0,nready=2,fclient=2,nclient=0)
    // Should be:
    //(nbufs=3,fcomp=0,ncomp=1,fready=1,nready=1,fclient=2,nclient=0)

    client_buffer = bundle.client_acquire(); // <- locks here if in buggy state
}

Merge proposal with fix will come shortly...