[gm45] X crash on X200s with dual monitors (using DisplayPort)

Bug #416421 reported by Luka Renko
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
xf86-video-intel
Fix Released
High
xserver-xorg-video-intel (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: xserver-xorg-video-intel

Up-to-date Kubuntu Karmic. Not using Desktop Effects (compositing).

I have ThinkPad X200s with X4500 graphics. I am using it in dual monitor setup with HP L2045w connected over DVI-DisplayPort. I use the following xrandr command to setup dual monitor:

xrandr --verbose --output LVDS1 --mode 1440x900 --output DVI2 --mode 1680x1050 --left-of LVDS1

My system was running for about an hour and the crash happened when "debuild" called pinentry-qt4 to enter my GPG passphrase to sign the package. This is the last window that appeared on the screen.

I have found the following backtrace in Xorg.log.old:

Backtrace:
0: /usr/bin/X(xorg_backtrace+0x26) [0x4efff6]
1: /usr/bin/X(xf86SigHandler+0x41) [0x4850a1]
2: /lib/libc.so.6 [0x7f910cd26560]
3: /usr/lib/libpixman-1.so.0 [0x7f910e002110]
4: /usr/lib/libpixman-1.so.0(pixman_fill+0x7a) [0x7f910dffd2ca]
5: /usr/lib/xorg/modules//libfb.so(fbFill+0x2b6) [0x7f910aadb906]
6: /usr/lib/xorg/modules//libfb.so(fbPolyFillRect+0x1d2) [0x7f910aadbda2]
7: /usr/lib/xorg/modules/drivers//intel_drv.so(uxa_check_poly_fill_rect+0xf1) [0x7f910b569011]
8: /usr/lib/xorg/modules/drivers//intel_drv.so [0x7f910b565c3f]
9: /usr/lib/xorg/modules/drivers//intel_drv.so(uxa_trapezoids+0x272) [0x7f910b5662a2]
10: /usr/bin/X [0x532f6b]
11: /usr/bin/X(Dispatch+0x384) [0x44dfc4]
12: /usr/bin/X(main+0x3b5) [0x433fa5]
13: /lib/libc.so.6(__libc_start_main+0xfd) [0x7f910cd11acd]
14: /usr/bin/X [0x433429]
Saw signal 11. Server aborting.

Note: I am experiencing occasional hangs of this system when running with external monitor. I still did not have time to properly debug the problem in order to report the problem. I plan to do the in following days.

ProblemType: Bug
Architecture: amd64
Date: Thu Aug 20 15:08:03 2009
DistroRelease: Ubuntu 9.10
MachineType: LENOVO 74705HG
Package: xserver-xorg-video-intel 2:2.8.0-0ubuntu2
ProcCmdLine: BOOT_IMAGE=/vmlinuz-2.6.31-6-generic root=/dev/mapper/plain-root ro single
ProcEnviron:
 LANGUAGE=
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-6.25-generic
RelatedPackageVersions:
 xserver-xorg 1:7.4+3ubuntu5
 libgl1-mesa-glx 7.5-1ubuntu1
 libdrm2 2.4.12-1ubuntu1
 xserver-xorg-video-intel 2:2.8.0-0ubuntu2
 xserver-xorg-video-ati 1:6.12.99+git20090629.f39cafc5-0ubuntu6
SourcePackage: xserver-xorg-video-intel
Uname: Linux 2.6.31-6-generic x86_64
XorgConf: Error: [Errno 2] No such file or directory: '/etc/X11/xorg.conf'
dmi.bios.date: 12/19/2008
dmi.bios.vendor: LENOVO
dmi.bios.version: 6DET38WW (2.02 )
dmi.board.name: 74705HG
dmi.board.vendor: LENOVO
dmi.board.version: Not Available
dmi.chassis.asset.tag: No Asset Information
dmi.chassis.type: 10
dmi.chassis.vendor: LENOVO
dmi.chassis.version: Not Available
dmi.modalias: dmi:bvnLENOVO:bvr6DET38WW(2.02):bd12/19/2008:svnLENOVO:pn74705HG:pvrThinkPadX200s:rvnLENOVO:rn74705HG:rvrNotAvailable:cvnLENOVO:ct10:cvrNotAvailable:
dmi.product.name: 74705HG
dmi.product.version: ThinkPad X200s
dmi.sys.vendor: LENOVO
fglrx: Not loaded
system:
 distro: Ubuntu
 architecture: x86_64kernel: 2.6.31-6-generic

[lspci]
00:02.0 VGA compatible controller [0300]: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller [8086:2a42] (rev 07)
     Subsystem: Lenovo Device [17aa:20e4]

Revision history for this message
Luka Renko (lure) wrote :
Revision history for this message
Luka Renko (lure) wrote :

Note: I have to use xrandr command, as by default I do not get native monitor resolution displayed - see bug 286001

Geir Ove Myhr (gomyhr)
tags: added: crash gm45 karmic
Bryce Harrington (bryce)
Changed in xserver-xorg-video-intel (Ubuntu):
status: New → Confirmed
Bryce Harrington (bryce)
tags: added: kubuntu
Revision history for this message
In , Luka Renko (lure) wrote :

Created an attachment (id=29995)
Xorg.0.log with backrace

HW: ThinkPad X200s with gm45
SW: Kubuntu Karmic up-to-date + update mesa & intel 2.9.0 driver from x-updates PPA

I would like to report reproducible crash from Ubuntu bug 415357 (there is similar crash in bug 416421, but w/o reproduction instructions):
https://launchpad.net/bugs/415357
https://launchpad.net/bugs/416421

Bug is reproducible by performing the following steps:
1. Open Kolourpaint (KDE drawing program), and select the pen tool.
2. Start drawing some doodle by pressing the left button of your mouse
   _without releasing it_ for at least 30 secs (keep the cursor moving).
3. X crashes.

In Xorg.0.log, I get the following backtrace:

0: /usr/bin/X(xorg_backtrace+0x26) [0x4f0136]
1: /usr/bin/X(xf86SigHandler+0x41) [0x4850f1]
2: /lib/libc.so.6 [0x7ffcbef32530]
3: /usr/lib/xorg/modules//libfb.so(fbBresSolid+0x1d6) [0x7ffcbcced336]
4: /usr/lib/xorg/modules//libfb.so(fbSegment+0x282) [0x7ffcbccec4d2]
5: /usr/lib/xorg/modules//libfb.so(fbZeroLine+0xfd) [0x7ffcbcce90ad]
6: /usr/lib/xorg/modules/drivers//intel_drv.so(uxa_check_poly_lines+0x138) [0x7ffcbd775f38]
7: /usr/bin/X [0x539947]
8: /usr/bin/X(ProcPolyLine+0xe2) [0x44be82]
9: /usr/bin/X(Dispatch+0x384) [0x44e044]
10: /usr/bin/X(main+0x3b5) [0x433fa5]
11: /lib/libc.so.6(__libc_start_main+0xfd) [0x7ffcbef1dabd]
12: /usr/bin/X [0x433429]
Saw signal 11. Server aborting.

Revision history for this message
Luka Renko (lure) wrote : Re: X crash on X200s with dual monitors (using DisplayPort)

This bug has similar backtrace as bug 415357 (which is easy to reproduce at least), therefore I have added upstream bug to watchlist.

Changed in xserver-xorg-video-intel:
status: Unknown → Confirmed
Revision history for this message
In , Chris Wilson (ickle) wrote :

Created an attachment (id=30003)
Exercise fbBresSolid()

The attached code exercises the call stack from the reported backtrace, but is insufficient to reproduce the crash here.

Luka, do you mind trying the test case (with gcc large-poly-lines.c -lX11 && ./a.out) and seeing if it reproduces the crash on your machine?

Revision history for this message
In , Chris Wilson (ickle) wrote :

Ok, I can reproduce the crash here by wiggling kolourpaint...

Revision history for this message
In , Chris Wilson (ickle) wrote :

Created an attachment (id=30004)
Assert that the read/write pointer is within bounds

A simple assertion to check that the pointer we are about to read from and write is valid (i.e points to within the destination drawable).

Revision history for this message
In , Chris Wilson (ickle) wrote :

X: fbseg.c:92: fbBresSolid: Assertion `dst >= start && dst < end' failed.

As the assertion above is being hit is not specific to the intel driver, I'm reassigning the bug to the core server.

Bryce Harrington (bryce)
description: updated
Bryce Harrington (bryce)
summary: - X crash on X200s with dual monitors (using DisplayPort)
+ [gm45] X crash on X200s with dual monitors (using DisplayPort)
Revision history for this message
In , Paulo Zanoni (pzanoni) wrote :

I can reproduce this problem on both 1.6.5 and 1.7.4. I didn't have time to test on git master yet.
I also tried Chris Wilson's patch on 1.6.5 and then instead of giving a backtrace X dies with this message:
X: fbseg.c:92: fbBresSolid: Assertion `dst >= start && dst < end' failed.

Link to Mandriva bug report:
https://qa.mandriva.com/show_bug.cgi?id=57105

Bryce Harrington (bryce)
summary: - [gm45] X crash on X200s with dual monitors (using DisplayPort)
+ [g45] [gm45] X crash on X200s with dual monitors (using DisplayPort)
Bryce Harrington (bryce)
summary: - [g45] [gm45] X crash on X200s with dual monitors (using DisplayPort)
+ [gm45] X crash on X200s with dual monitors (using DisplayPort)
Changed in xserver-xorg-video-intel:
importance: Unknown → High
Changed in xserver-xorg-video-intel:
importance: High → Unknown
Changed in xserver-xorg-video-intel:
importance: Unknown → High
Revision history for this message
In , Renato Caldas (seventhguardian) wrote :

I cannot reproduce this with 1.9.5, and judging by the date of this bug I assume it can be closed, right?

Revision history for this message
bugbot (bugbot) wrote :

This bug report was filed against an old version of Ubuntu.
Can you confirm whether this is still an issue in natty?

Please also ensure this bug has tags for each Ubuntu release
that the bug is confirmed as affecting.

Changed in xserver-xorg-video-intel (Ubuntu):
status: Confirmed → New
status: New → Incomplete
Revision history for this message
In , Simon Schubert (corecode) wrote :

I experience a related bug when using KiCad:

[ 2507.868]
Backtrace:
[ 2507.868] 0: /usr/bin/X (xorg_backtrace+0x26) [0x566a86]
[ 2507.868] 1: /usr/bin/X (0x400000+0x16a6e9) [0x56a6e9]
[ 2507.868] 2: /lib/libpthread.so.0 (0x7fa9d12c8000+0xf8a0) [0x7fa9d12d78a0]
[ 2507.868] 3: /usr/lib/xorg/modules/libfb.so (fbBresSolid+0x21c) [0x7fa9cd94a1cc]
[ 2507.868] 4: /usr/lib/xorg/modules/libfb.so (fbSegment+0x3f7) [0x7fa9cd94b667]
[ 2507.868] 5: /usr/lib/xorg/modules/libfb.so (fbPolySegment32+0x4bd) [0x7fa9cd93f88d]
[ 2507.868] 6: /usr/lib/xorg/modules/drivers/intel_drv.so (0x7fa9ce380000+0x380cc) [0x7fa9ce3b80cc]
[ 2507.868] 7: /usr/lib/xorg/modules/drivers/intel_drv.so (0x7fa9ce380000+0x2f1ec) [0x7fa9ce3af1ec]
[ 2507.868] 8: /usr/bin/X (0x400000+0xf9a3f) [0x4f9a3f]
[ 2507.868] 9: /usr/bin/X (0x400000+0x302a3) [0x4302a3]
[ 2507.868] 10: /usr/bin/X (0x400000+0x33cb9) [0x433cb9]
[ 2507.868] 11: /usr/bin/X (0x400000+0x22eea) [0x422eea]
[ 2507.868] 12: /lib/libc.so.6 (__libc_start_main+0xed) [0x7fa9d017f38d]
[ 2507.868] 13: /usr/bin/X (0x400000+0x231dd) [0x4231dd]
[ 2507.868] Segmentation fault at address 0x7fa9cc816ffc

It is reproducible.

No idea why the intel driver symbols don't show up, but addr2line shows me:

0x380cc = xf86-video-intel-2.17.0/uxa/uxa-unaccel.c:24 = uxa_check_poly_segment()
0x2f1ec = xf86-video-intel-2.17.0/uxa/uxa-accel.c:624 = uxa_poly_segment()

Revision history for this message
In , Simon Schubert (corecode) wrote :

Created attachment 56113
gdb backtrace

gdb backtrace of the bug. dst is out of bounds. I can provide core file and binaries if required.

Revision history for this message
In , Simon Schubert (corecode) wrote :

The problem seems to be that there are negative coordinates being passed in to ProcPolySegment:

(gdb) p/x *(xSegment*)&((xPolySegmentReq *)0x2918e1c)[1]
$11 = {x1 = 0x24, y1 = 0x10, x2 = 0xfffe, y2 = 0xffff}

I don't know who is supposed to catch this. Looking at the call sequence, nobody really makes sure that these values are in bounds.

Revision history for this message
In , Chris Wilson (ickle) wrote :

Clipping is performed in fbSegment(), see OUTCODES() and miZeroClipLine().

Revision history for this message
In , Simon Schubert (corecode) wrote :

Ah. I believe this is the problem, or at least very closely related:

<http://cgit.freedesktop.org/xorg/xserver/tree/fb/fbseg.c#n693>:
     if (clip2 != 0 || drawLast)
  len++;

in combination with these variables:

        new_x1 = 36
        new_x2 = 0
        new_y1 = 16
        new_y2 = 0
        clip2 = 10
        len = 37

This incremented len to 37, extending (in reverse) the line below (0, 0), which leads to a segmentation fault.

Revision history for this message
In , Simon Schubert (corecode) wrote :

Ok, I see what is going on there.

The len++ is to make the end coordinates inclusive, which they should be if drawLast is set, or if we clipped the end.

Now, we changed the end coordinates, but we keep the Bresenham error terms, because we want the same angle (I suppose).

However, if we look at fbBresSolid, we see this sequence:

 while (len--)
 {
...
/// (1) ///
  WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
  bits = 0;
  dst += signdx;
...
     e += e1;
/// (2) ///
     if (e >= 0)
     {
/// (3) ///
  WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
  bits = 0;
  dst += dstStride;
  e += e3;
     }
 }

Now assume we have arrived at len = 1. We start the last iteration for the last pixel, at (x2,y2). We draw the pixel (location (1)), and we *should* be done. However, because of the previously unmodified Bresenham error terms, it can happen that the error total overflows (location (2)), and we will draw another pixel, now at (x2+signdx,y2), before adjusting the error terms and exiting the loop.

In short, it might happen that (I'm using signdx=-1, just because my case happens to be that way):

- (orig_x2, orig_y2) get clipped
- the algorithm then goes on to draw:

(x1,y1), (x1-1,y1), ..., (x2,y2), (x2-1,y2)

Now, if x2 = 0, y2 = 0, then we overshoot into negative address land (-1,0) and might segfault (actually do).

Solutions
=========

I don't directly see how this could be fixed:

a) Check dst for every Bresenham error pixel, but that seems excessive.
b) Adjust the error terms, but that would change the slope of the line (slightly)
c) Check for this case in advance and reduce len, but then you'd lose one pixel at the end
d) Rewrite fbseg to draw the error pixel in the next iteration, instead of in the same. This touches central code though.

Revision history for this message
In , Simon Schubert (corecode) wrote :

Just a follow-up to say that solution (d) seems to work for me.

Revision history for this message
Bryce Harrington (bryce) wrote :

We're closing this bug since it is has been some time with no response from the original bug reporter. However, if the issue still exists in the latest development version of Ubuntu and you are the original reporter please feel free to reopen with the requested information. If you are not the original reporter, please don't reopen this one but instead file a new bug and reference this one.

Changed in xserver-xorg-video-intel (Ubuntu):
status: Incomplete → Invalid
Revision history for this message
In , Simon Schubert (corecode) wrote :

Created attachment 57155
reorder Bresenham error correction to avoid overshoot.

When fbBresSolid draws a line, it can happen that after the last
pixel, the Bresenham error term overflows, and fbBresSolid paints
another pixel before adjusting the error term.

However, if this happens on the last pixel (len=0), this extra pixel
might overshoot the boundary, and, in rare cases, lead to a segfault.

Fix this issue by adjusting for the Bresenham error term before
drawing the main pixel, not after.

Revision history for this message
In , Mjd+freedesktop-org (mjd+freedesktop-org) wrote :

I am getting this crash when doing zone fills in KiCad. Fedora 16, unaccelerated video. I have applied Simon Schubert's patch, and the crashes no longer happen.

Revision history for this message
In , Mjd+freedesktop-org (mjd+freedesktop-org) wrote :

Created attachment 59095
A backtrace of a crash caused by this problem

Revision history for this message
In , Mattst88 (mattst88) wrote :
Changed in xserver-xorg-video-intel:
status: Confirmed → Fix Released
Revision history for this message
In , Jeremy Sequoia (jeremyhu) wrote :
Revision history for this message
In , Slapinid (slapinid) wrote :

This bug still occurs with Kicad and recent X11

Changed in xserver-xorg-video-intel:
status: Fix Released → Confirmed
Revision history for this message
In , Ajax-a (ajax-a) wrote :

commit 1b94fd77792310c80b0a2bcf4bf6d4e4c4c23bca
Author: Alex Orange <email address hidden>
Date: Fri Oct 3 15:41:38 2014 -0600

    fb: Fix Bresenham algorithms for commonly used small segments.

Changed in xserver-xorg-video-intel:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.