Bug 60086 - Wayland platform backend crashes if there's no back buffer during dri2_swap_buffers
Summary: Wayland platform backend crashes if there's no back buffer during dri2_swap_b...
Alias: None
Product: Mesa
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Kristian Høgsberg
QA Contact:
Depends on:
Reported: 2013-01-30 19:35 UTC by Rafael Antognolli
Modified: 2013-02-08 16:26 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

Swap buffer when a segv happens. (3.02 KB, text/plain)
2013-01-30 19:35 UTC, Rafael Antognolli
Make sure we have a back buffer in swap buffers (1.46 KB, patch)
2013-02-06 20:46 UTC, Kristian Høgsberg
Details | Splinter Review

Description Rafael Antognolli 2013-01-30 19:35:25 UTC
Created attachment 73945 [details]
Swap buffer when a segv happens.

When using the Wayland platform backend of Mesa, if there's no call to any rendering/drawing function, there will be no back buffer present (it should be NULL). This causes any call to dri2_swap_buffers to segfault, since it accesses dri2_surf->back->age.

The egl semantics is that the back buffer is undefined at this situation, maybe presenting only garbage when the swap buffer is done, but it should not crash.

This segfault behavior was reproduced when using the Wayland backend of EFL, and a test program was written with a window and a canvas, without any objects on it. It would trigger a swap buffer but no call was done to allocate a back buffer.

There's a backtrace attached to this bug that shows where the error happens.
Comment 1 Kristian Høgsberg 2013-02-06 20:46:20 UTC
Created attachment 74305 [details] [review]
Make sure we have a back buffer in swap buffers

This should fix the problem.
Comment 2 Rafael Antognolli 2013-02-08 12:50:08 UTC
The patch fix the problem, as expected, thanks!

Is there any chance that it gets backported to the stable release/branch too?
Comment 3 Kristian Høgsberg 2013-02-08 16:26:25 UTC
Pushed to master.  I added the NOTE in the commit message that will make sure it gets picked to the stable branches.  I don't know if there's a 9.0.x release planned but 9.1.0 should be out end of Feb and should include this patch.

commit 1fe007399c1ed28b8cef9d4f040164480423f2c9
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Wed Feb 6 15:41:54 2013 -0500

    egl-wayland: Make sure we allocate a back buffer even if nothing was rendere
    At eglSwapBuffer time, we blindly assume we have a back buffer, but the
    back buffer only gets allocated when somebody tries to render something.
    NOTE: This is a candidate for the 9.0 and 9.1 branches.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.