Skip to content

mesa/st: do st_framebuffers_purge before reuse stdraw

lina jia requested to merge jialina/mesa:main into main

st_framebuffer might leak when dri_drawable of surf1 and surf2 are allocated on the same address on android. The sequence is as follows.

  1. surf1 and st_framebuffer1 are created by eglCreateWindowSurface.
  2. surf1 do rendering by eglMakeCurrent and st_framebuffer1 is inserted to winsys_buffer and stfbi_ht by eglMakeCurrent.
  3. surf1 is destroyed by eglDestroySurface and st_framebuffer1 is removed from stfbi_ht.
  4. On android, surf2 be created by eglCreateWindowSurface and is probably allocated on the same address with surf1 which has alreadly destroyed in step 3). The st_framebuffer2 is on the same address with st_framebuffer1.
  5. surf2 do rendering by eglMakeCurrent and st_framebuffer2 is inserted to winsys_buffer and stfbi_ht by eglMakeCurrent after st_framebuffer_reuse_or_create. Then st_framebuffers_purge is called by eglMakeCurrent and try to remove st_framebuffer1 from winsys_buffer but failed, because of st_framebuffer2 which has the same address with st_framebuffer1 is found in stfbi_ht.
  6. st_framebuffer1 is leaked and isn't released untill context destroyed.

So do st_framebuffers_purge before st_framebuffer_reuse_or_create to keep the consistency between winsys_buffer and stfbi_ht. This was introduced in: 5124bf98 Yong Zhang had found this problem and more details can be found in

Signed-off-by: default avatarjialina jialina@bytedance.com Part-of: <!10945>

Edited by lina jia

Merge request reports