Bug 50019

Summary: after few (de)activating kwin effect, xorg crash
Product: xorg Reporter: David Heidelberg (okias) <david>
Component: Server/Ext/GLXAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: major    
Priority: medium CC: haagch, sxyaqwedc, will
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 44202    
Attachments:
Description Flags
xorg.log
none
gdb
none
Possible workaround none

Description David Heidelberg (okias) 2012-05-16 11:20:10 UTC
Created attachment 61731 [details]
xorg.log

HW: AMD A3870K, GPU 6550D on-CPU.
System: Gentoo ~amd64

How to reproduce:
1) let system start with activated kwin OpenGL effects
2) press ALT-F11 (de/activate effects) (with combination with Chrome or Firefox is best for fast reproduce)
3) after few presses xorg die.

Dmesg here, xorg with -O0 and -ggdb etc. in attachment.

$ dmesg | grep drm -C2
ACPI: acpi_idle registered with cpuidle
Linux agpgart interface v0.103
[drm] Initialized drm 1.1.0 20060810
[drm] radeon defaulting to kernel modesetting.
[drm] radeon kernel modesetting enabled.
[drm] initializing kernel modesetting (SUMO 0x1002:0x9640 0x1043:0x84C8).
[drm] register mmio base: 0xFEB00000
[drm] register mmio size: 262144
ATOM BIOS: General
radeon 0000:00:01.0: VRAM: 256M 0x0000000000000000 - 0x000000000FFFFFFF (256M used)
radeon 0000:00:01.0: GTT: 512M 0x0000000010000000 - 0x000000002FFFFFFF
[drm] Detected VRAM RAM=256M, BAR=256M
[drm] RAM width 32bits DDR
[TTM] Zone  kernel: Available graphics memory: 3951330 kiB
[TTM] Zone   dma32: Available graphics memory: 2097152 kiB
[TTM] Initializing pool allocator
[TTM] Initializing DMA pool allocator
[drm] radeon: 256M of VRAM memory ready
[drm] radeon: 512M of GTT memory ready.
[drm] Supports vblank timestamp caching Rev 1 (10.10.2010).
[drm] Driver supports precise vblank timestamp query.
radeon 0000:00:01.0: irq 42 for MSI/MSI-X
radeon 0000:00:01.0: radeon: using MSI.
[drm] radeon: irq initialized.
[drm] GART: num cpu pages 131072, num gpu pages 131072
[drm] radeon: ib pool ready.
[drm] Loading SUMO Microcode
[drm] PCIE GART of 512M enabled (table at 0x0000000000040000).
radeon 0000:00:01.0: WB enabled
[drm] fence driver on ring 0 use gpu addr 0x10000c00 and cpu addr 0xffff8802244a3c00
[drm] ring test on 0 succeeded in 1 usecs
[drm] ib test on ring 0 succeeded in 0 usecs
[drm] Radeon Display Connectors
[drm] Connector 0:
[drm]   VGA
[drm]   HPD2
[drm]   DDC: 0x6440 0x6440 0x6444 0x6444 0x6448 0x6448 0x644c 0x644c
[drm]   Encoders:
[drm]     CRT1: INTERNAL_UNIPHY2
[drm]     CRT1: NUTMEG
[drm] Connector 1:
[drm]   DVI-D
[drm]   HPD1
[drm]   DDC: 0x6430 0x6430 0x6434 0x6434 0x6438 0x6438 0x643c 0x643c
[drm]   Encoders:
[drm]     DFP1: INTERNAL_UNIPHY2
[drm] Connector 2:
[drm]   DisplayPort
[drm]   HPD3
[drm]   DDC: 0x6450 0x6450 0x6454 0x6454 0x6458 0x6458 0x645c 0x645c
[drm]   Encoders:
[drm]     DFP2: INTERNAL_UNIPHY
[drm] Internal thermal controller without fan control
[drm] radeon: power management initialized
[drm] fb mappable at 0xC0142000
[drm] vram apper at 0xC0000000
[drm] size 8294400
[drm] fb depth is 24
[drm]    pitch is 7680
fbcon: radeondrmfb (fb0) is primary device
Console: switching to colour frame buffer device 240x67
fb0: radeondrmfb frame buffer device
drm: registered panic notifier
[drm] Initialized radeon 2.15.0 20080528 for 0000:00:01.0 on minor 0
Comment 1 Michel Dänzer 2012-05-16 15:19:40 UTC
Can you get a full backtrace with gdb?
Comment 2 David Heidelberg (okias) 2012-05-16 15:27:14 UTC
Created attachment 61735 [details]
gdb

I'm afraid it didn't bring needed information. It look like without debug. I have suspicion, that some lower level package is compiled with omit-frame-pointer :(
Comment 3 David Heidelberg (okias) 2012-06-03 08:47:12 UTC
It always die in dri2_*. In this moment was hard to get it crash, but combination of kwin effects (OpenGL2 Shaders) + VLC with opengl visualisation ProjectM

(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x00007f341c93bd62 in dri2_invalidate_drawable (dPriv=0x2d59490) at dri2.c:68
68      dri2.c: No such file or directory.
(gdb) bt
#0  0x00007f341c93bd62 in dri2_invalidate_drawable (dPriv=0x2d59490) at dri2.c:68
#1  0x00007f341f0e3d85 in __glXDRIinvalidateBuffers (pDraw=0x37062d0, priv=0x36e3ca0, id=23087722)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/glx/glxdri2.c:427
#2  0x00007f341e845ffb in DRI2InvalidateDrawable (pDraw=0x37062d0)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/hw/xfree86/dri2/dri2.c:598
#3  0x00007f341e8467b6 in DRI2InvalidateWalk (pWin=0x37062d0, data=0x2859cc0)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/hw/xfree86/dri2/dri2.c:844
#4  0x00000000004761e8 in TraverseTree (pWin=0x285b130, func=0x7f341e84676f <DRI2InvalidateWalk>, data=0x2859cc0)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/dix/window.c:315
#5  0x00007f341e846bf1 in DRI2SwapBuffers (client=0x356c980, pDraw=0x2ae0820, target_msc=0, divisor=0, remainder=0, swap_target=0x7fff05dcf1c0, 
    func=0x7f341e848126 <DRI2SwapEvent>, data=0x2ae0820) at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/hw/xfree86/dri2/dri2.c:964
#6  0x00007f341e8482bd in ProcDRI2SwapBuffers (client=0x356c980)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/hw/xfree86/dri2/dri2ext.c:400
#7  0x00007f341e8487d3 in ProcDRI2Dispatch (client=0x356c980)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/hw/xfree86/dri2/dri2ext.c:566
#8  0x000000000043436f in Dispatch () at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/dix/dispatch.c:428
#9  0x0000000000425152 in main (argc=10, argv=0x7fff05dcf3b8, envp=0x7fff05dcf410)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/dix/main.c:288
(gdb) bt full
#0  0x00007f341c93bd62 in dri2_invalidate_drawable (dPriv=0x2d59490) at dri2.c:68
        drawable = 0x2b12190
#1  0x00007f341f0e3d85 in __glXDRIinvalidateBuffers (pDraw=0x37062d0, priv=0x36e3ca0, id=23087722)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/glx/glxdri2.c:427
        private = 0x36e3ca0
        screen = 0x2832f60
#2  0x00007f341e845ffb in DRI2InvalidateDrawable (pDraw=0x37062d0)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/hw/xfree86/dri2/dri2.c:598
        pPriv = 0x3566d60
        ref = 0x3592860
#3  0x00007f341e8467b6 in DRI2InvalidateWalk (pWin=0x37062d0, data=0x2859cc0)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/hw/xfree86/dri2/dri2.c:844
No locals.
#4  0x00000000004761e8 in TraverseTree (pWin=0x285b130, func=0x7f341e84676f <DRI2InvalidateWalk>, data=0x2859cc0)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/dix/window.c:315
        result = 1
        pChild = 0x37062d0
#5  0x00007f341e846bf1 in DRI2SwapBuffers (client=0x356c980, pDraw=0x2ae0820, target_msc=0, divisor=0, remainder=0, swap_target=0x7fff05dcf1c0, 
    func=0x7f341e848126 <DRI2SwapEvent>, data=0x2ae0820) at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/hw/xfree86/dri2/dri2.c:964
        pWin = 0x285b130
        pPixmap = 0x2859cc0
        pScreen = 0x2801d80
        ds = 0x28022a0
        pPriv = 0x2f839a0
        pDestBuffer = 0x31779b0
        pSrcBuffer = 0x3261390
        ret = 1
        i = 3
        ust = 1338738147972846
        current_msc = 423256
        __func__ = "DRI2SwapBuffers"
#6  0x00007f341e8482bd in ProcDRI2SwapBuffers (client=0x356c980)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/hw/xfree86/dri2/dri2ext.c:400
        stuff = 0x35b0660
        rep = {type = 0 '\000', pad1 = 0 '\000', sequenceNumber = 0, length = 0, swap_hi = 56019328, swap_lo = 0, pad2 = 98365936, pad3 = 32767, 
          pad4 = 56019328, pad5 = 0}
        pDrawable = 0x2ae0820
        target_msc = 0
        divisor = 0
        remainder = 0
        swap_target = 403
        status = 0
#7  0x00007f341e8487d3 in ProcDRI2Dispatch (client=0x356c980)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/hw/xfree86/dri2/dri2ext.c:566
        stuff = 0x35b0660
#8  0x000000000043436f in Dispatch () at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/dix/dispatch.c:428
        clientReady = 0x29a7690
        result = 0
---Type <return> to continue, or q <return> to quit---
        client = 0x356c980
        nready = 0
        icheck = 0x86d110
        start_tick = 6740
#9  0x0000000000425152 in main (argc=10, argv=0x7fff05dcf3b8, envp=0x7fff05dcf410)
    at /var/tmp/portage/x11-base/xorg-server-1.12.2/work/xorg-server-1.12.2/dix/main.c:288
        i = 1
        alwaysCheckForInput = {0, 1}
Comment 4 Michel Dänzer 2012-06-06 02:52:54 UTC
Created attachment 62655 [details] [review]
Possible workaround

(In reply to comment #3)
> #0  0x00007f341c93bd62 in dri2_invalidate_drawable (dPriv=0x2d59490) at
> dri2.c:68

Can you print *dPriv here?

This patch might work around the crash, but I don't understand how dri_drawable() can ever return NULL...
Comment 5 Michel Dänzer 2012-06-28 07:01:00 UTC
After more investigation, I think I found the problem and fix in the xserver GLX code:

http://lists.x.org/archives/xorg-devel/2012-June/032008.html
Comment 6 Michel Dänzer 2012-07-03 02:41:30 UTC
*** Bug 51626 has been marked as a duplicate of this bug. ***
Comment 7 Michel Dänzer 2012-07-11 11:41:45 UTC
*** Bug 51980 has been marked as a duplicate of this bug. ***
Comment 8 David Heidelberg (okias) 2012-07-14 11:59:14 UTC
I didn't found it applied in xserver git repository, what is status? Chris confirmed it work, right? Is needed more testing?
Comment 9 David Heidelberg (okias) 2012-07-14 12:22:37 UTC
Tested-by: David Heidelberger <d.okias at gmail.com>

seems ROCK STABLE :D

fixed for me, just get it into git and 1.12.4
Comment 10 Michel Dänzer 2012-07-17 09:15:32 UTC
I had to adapt the fix to review comments, but it's in Git master now, see below. Hopefully it'll be backported to the 1.12 branch as well.

commit a2d0829531249e24dbca25fc20ed30a2bb2d8ed8
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Jul 12 13:16:37 2012 +0200

    glx: Free DRI2 drawable reference to destroyed GLX drawable.
    
    Otherwise the reference can lead to use after free in
    __glXDRIinvalidateBuffers().
Comment 11 Michel Dänzer 2012-07-17 10:09:03 UTC
*** Bug 52190 has been marked as a duplicate of this bug. ***

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.