OK, I'm going to ignore comment #4 for now in case that's just masking the problem...
When the bug does occur, the CPU usage of mir_unit_tests is around 150% the whole time...
$ time bin/mir_unit_tests --gtest_filter="BufferQueueTest.compositor_never_owns_client_buffers"
Note: Google Test filter = BufferQueueTest.compositor_never_owns_client_buffers
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from BufferQueueTest
[ RUN ] BufferQueueTest.compositor_never_owns_client_buffers
[ OK ] BufferQueueTest.compositor_never_owns_client_buffers (26077 ms)
[----------] 1 test from BufferQueueTest (26077 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (26077 ms total)
[ PASSED ] 1 test.
OK, I'm going to ignore comment #4 for now in case that's just masking the problem...
When the bug does occur, the CPU usage of mir_unit_tests is around 150% the whole time...
$ time bin/mir_unit_tests --gtest_ filter= "BufferQueueTes t.compositor_ never_owns_ client_ buffers" .compositor_ never_owns_ client_ buffers .compositor_ never_owns_ client_ buffers .compositor_ never_owns_ client_ buffers (26077 ms)
Note: Google Test filter = BufferQueueTest
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from BufferQueueTest
[ RUN ] BufferQueueTest
[ OK ] BufferQueueTest
[----------] 1 test from BufferQueueTest (26077 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (26077 ms total)
[ PASSED ] 1 test.
real 0m26.102s
user 0m26.322s
sys 0m12.151s
So it sounds like a simple case of racing.