Bug 370303 - Infinite recursion leading to stack overflow under XWayland
Summary: Infinite recursion leading to stack overflow under XWayland
Status: RESOLVED FIXED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Boudhayan Gupta
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-08 14:53 UTC by Peter Wu
Modified: 2016-10-14 09:09 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 16.12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Wu 2016-10-08 14:53:37 UTC
While testing Spectacle in Weston+XWayland on top of Plasma (X11), it segfaulted.

A stack trace showed recursive calls to getWindowPixmap with the same window argument:

QPixmap X11ImageGrabber::getWindowPixmap(xcb_window_t window, bool blendPointer)
{
...
    if (xcbImage.isNull()) {
        return getWindowPixmap(QX11Info::appRootWindow(), blendPointer)
                .copy(geomReply->x, geomReply->y, geomReply->width, geomReply->height);
    }


Reproducible: Always

Steps to Reproduce:
1. Install xorg-server-xwayland and configure weston as described at https://wiki.archlinux.org/index.php/wayland#XWayland
2. Launch weston
3. Inside weston, launch Spectacle

Actual Results:  
Segfault (stack overflow)

Expected Results:  
A screenshot (or failing to do so, an error message explaining why).

xorg-server 1.18.4-1
plasma-workspace 5.8.0-1
spectacle 16.08.1-1 (happens on this version and on git)
Comment 1 Peter Wu 2016-10-14 09:09:39 UTC
Git commit 7a5603fda8f1e591d31dba1ad178c44ad6847cc2 by Peter Wu.
Committed on 14/10/2016 at 09:08.
Pushed by peterwu into branch 'master'.

Refactor pixmap grabbing, add robustness

Do not go in an infinite loop when the root window cannot be captured
(bug 370303). Avoid crashing xcb_image_destroy by checking for NULL.

Split the getWindowPixmap into three logical methods depending on the
consumer: obtaining a pixmap from KWin, obtaining a pixmap from a single
window and obtaining a pixmap from a full screen. This enables some
optimizations, like obtaining a smaller area of the screen without
cropping. Additionally, it will make fixing HiDPI support easier.

Added robustness: if KWin somehow fails, now it will fallback to a
fullscreen capture instead of an null pixmap.

REVIEW: 129176
FIXED-IN: 16.12

M  +78   -30   src/PlatformBackends/X11ImageGrabber.cpp
M  +7    -2    src/PlatformBackends/X11ImageGrabber.h

http://commits.kde.org/spectacle/7a5603fda8f1e591d31dba1ad178c44ad6847cc2