From patchwork Tue Aug 14 00:16:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Wu X-Patchwork-Id: 10564975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41B4F13B4 for ; Tue, 14 Aug 2018 00:39:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F9BC291A4 for ; Tue, 14 Aug 2018 00:39:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23E70291D4; Tue, 14 Aug 2018 00:39:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BEFAE291A4 for ; Tue, 14 Aug 2018 00:39:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2691689F47; Tue, 14 Aug 2018 00:38:58 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org X-Greylist: delayed 1362 seconds by postgrey-1.36 at gabe; Tue, 14 Aug 2018 00:38:55 UTC Received: from mail.lekensteyn.nl (mail.lekensteyn.nl [IPv6:2a02:2308::360:1:25]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6493089DA5; Tue, 14 Aug 2018 00:38:55 +0000 (UTC) Received: by lekensteyn.nl with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1fpN0O-0007p9-Ae; Tue, 14 Aug 2018 02:16:12 +0200 From: Peter Wu To: xorg-devel@lists.x.org Date: Tue, 14 Aug 2018 02:16:11 +0200 Message-Id: <20180814001611.27083-1-peter@lekensteyn.nl> X-Mailer: git-send-email 2.18.0 Subject: [Intel-gfx] [PATCH xserver] randr: fix RRCrtcDetachScanoutPixmap crash on server exit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, =?utf-8?q?Michel_D=C3=A4nzer?= MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The following crash was observed with xserver 1.20.1 on exiting xserver after enabling a PRIME output source with the Intel driver: Old value = (WindowPtr) 0x612000159dc0 New value = (WindowPtr) 0x0 // pWin->drawable.pScreen->root = NULL; DeleteWindow (value=0x612000159dc0, wid=) at dix/window.c:1112 1112 dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW); (gdb) bt #0 DeleteWindow (value=0x612000159dc0, wid=) at dix/window.c:1112 #1 0x0000557e7842535b in doFreeResource (res=0x60300000ebf0, skip=) at dix/resource.c:880 #2 0x0000557e784289ed in FreeClientResources (client=0x60e000000040) at dix/resource.c:1146 #3 0x0000557e78428c46 in FreeAllResources () at dix/resource.c:1161 #4 0x0000557e783c25d8 in dix_main (argc=, argv=, envp=) at dix/main.c:292 ... Thread 1 "Xorg" received signal SIGSEGV, Segmentation fault. 0x0000557e7841138c in PixmapStopDirtyTracking (src=0x0, slave_dst=0x61100002ea80) at dix/pixmap.c:251 251 ScreenPtr screen = src->pScreen; (gdb) bt #0 0x0000558e598a938c in PixmapStopDirtyTracking (src=0x0, slave_dst=0x611000038d00) at ../xserver/dix/pixmap.c:251 #1 0x0000558e5990ccd5 in RRCrtcDetachScanoutPixmap (crtc=0x617000004680) at ../xserver/randr/rrcrtc.c:413 #2 0x0000558e5990d001 in RRCrtcDestroyResource (value=0x617000004680, pid=) at ../xserver/randr/rrcrtc.c:900 #3 0x0000558e598bd35b in doFreeResource (res=0x60300000a2a0, skip=) at ../xserver/dix/resource.c:880 #4 0x0000558e598c09ed in FreeClientResources (client=0x60e000000040) at ../xserver/dix/resource.c:1146 #5 0x0000558e598c0c46 in FreeAllResources () at ../xserver/dix/resource.c:1161 #6 0x0000558e5985a5d8 in dix_main (argc=, argv=, envp=) at ../xserver/dix/main.c:292 For some reason, the Window resource ends up being freed before a pixmap when using the intel driver. It does not occur with modesetting (there RRCrtcDestroyResource is called before deleting the root window). Before "Make PixmapDirtyUpdateRec::src a DrawablePtr" the "src" argument was "master->GetScreenPixmap(master)". After that commit, it becomes the root window drawable which can be NULL as shown above. Signed-off-by: Peter Wu --- randr/rrcrtc.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 5d9026266..d5dc235b7 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -398,20 +398,22 @@ RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc) ScreenPtr master = crtc->pScreen->current_master; DrawablePtr mrootdraw = &master->root->drawable; - if (crtc->scanout_pixmap_back) { - pScrPriv->rrDisableSharedPixmapFlipping(crtc); + if (mrootdraw) { + if (crtc->scanout_pixmap_back) { + pScrPriv->rrDisableSharedPixmapFlipping(crtc); - master->StopFlippingPixmapTracking(mrootdraw, - crtc->scanout_pixmap, - crtc->scanout_pixmap_back); + master->StopFlippingPixmapTracking(mrootdraw, + crtc->scanout_pixmap, + crtc->scanout_pixmap_back); - rrDestroySharedPixmap(crtc, crtc->scanout_pixmap_back); - crtc->scanout_pixmap_back = NULL; - } - else { - pScrPriv->rrCrtcSetScanoutPixmap(crtc, NULL); - master->StopPixmapTracking(mrootdraw, - crtc->scanout_pixmap); + rrDestroySharedPixmap(crtc, crtc->scanout_pixmap_back); + crtc->scanout_pixmap_back = NULL; + } + else { + pScrPriv->rrCrtcSetScanoutPixmap(crtc, NULL); + master->StopPixmapTracking(mrootdraw, + crtc->scanout_pixmap); + } } rrDestroySharedPixmap(crtc, crtc->scanout_pixmap);