loader/dri3: Avoid freeing renderbuffers in use
authorThomas Hellstrom <thellstrom@vmware.com>
Thu, 11 Jan 2018 09:19:23 +0000 (10:19 +0100)
committerThomas Hellstrom <thellstrom@vmware.com>
Fri, 12 Jan 2018 08:17:35 +0000 (09:17 +0100)
commit897c54d522ab960a879b763a15e489f630c491ee
tree36d0cba708d2e7e4055c722d5fbe7d332a03a697
parente63adf8b1ea56c9c2d0794f563bced765fb8300a
loader/dri3: Avoid freeing renderbuffers in use

Upon reception of an event that lowered the number of active back buffers,
the code would immediately try to free all back buffers with an id equal to or
higher than the new number of active back buffers.

However, that could lead to an active or to-be-active back buffer being freed,
since the old number of back buffers was used when obtaining an idle back
buffer for use.

This lead to crashes when lowering the number of active back buffers by
transitioning from page-flipping to non-page-flipping presents.

Fix this by computing the number of active back buffers only when trying to
obtain a new back buffer.

Fixes: 15e208c4cc ("loader/dri3: Don't accidently free buffer holding new back content")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104214
Cc: "17.3" <mesa-stable@lists.freedesktop.org>
Tested-by: Andriy.Khulap <andriy.khulap@globallogic.com>
Tested-by: Vadym Shovkoplias <vadym.shovkoplias@globallogic.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
src/loader/loader_dri3_helper.c