Control: tag -1 patch

Hello Paul,
I could trace from your core the crash into a call to 
XftTextExtents8 in libxft2 library.

There is just one location that calls that function which
is responsible to draw the window title near the icon in
the window bar.


There I could reproduce that crash:

Program received signal SIGSEGV, Segmentation fault.
0x00007fd9e594d364 in XftGlyphExtents (dpy=dpy@entry=0x55c072ed2260, 
pub=pub@entry=0x55c072f1edd0, glyphs=glyphs@entry=0x7ffd6f6611f0, 
nglyphs=nglyphs@entry=-1, extents=extents@entry=0x7ffd6f662254) at 
../../src/xftextent.c:50
50              if (XftFontCheckGlyph (dpy, pub, FcFalse, *g++, missing, 
&nmissing))
(gdb) bt
#0  0x00007fd9e594d364 in XftGlyphExtents (dpy=dpy@entry=0x55c072ed2260, 
pub=pub@entry=0x55c072f1edd0, glyphs=glyphs@entry=0x7ffd6f6611f0, 
nglyphs=nglyphs@entry=-1, extents=extents@entry=0x7ffd6f662254) at 
../../src/xftextent.c:50
#1  0x00007fd9e594d656 in XftTextExtents8 (dpy=0x55c072ed2260, 
pub=0x55c072f1edd0, string=0x55c072ee5aa0 "benutzer@debian: ~", len=-1, 
extents=0x7ffd6f662254) at ../../src/xftextent.c:139
#2  0x000055c071a5953f in gui_draw_task (tk=0x55c072ee2d70) at hpanel.c:593
#3  0x000055c071a59cba in gui_draw_taskbar () at hpanel.c:848
#4  0x000055c071a5a414 in handle_propertynotify (win=948, at=364) at 
hpanel.c:1139
#5  0x000055c071a58655 in main (argc=<optimized out>, argv=<optimized out>) at 
hpanel.c:1276


This happens after starting more applications until the
first character of the window title of one window does not
fit as a whole near the icon anymore.
It crashes when len reaches -1.


(gdb) list gui_draw_task
589                     /* check how many chars can fit */
590                     len = strlen (tk->name);
591                     while (1)
592                     {
593                             XftTextExtents8 (dd, xfs, tk->name, len, &ext);
594                             if (ext.width < taskw - (text_x - x) - 2 && len 
> 0)
595                                     break;
596                             len--;
597                     }


There is a fallback code path, when libxft2 is not used, that looks like this:

623             /* check how many chars can fit */
624             len = strlen (tk->name);
625
626             while (XTextWidth (xfs, tk->name, len) >= taskw - (text_x - x) 
- 2
627                              && len > 0)
628                     len--;


In package fspanel, where hpanel seems to be forked off,
this bug does not happen as fspanel does not use libxft2 at
this point at least.


Attached patch leaves the while loop if len reaches 0.


Kind regards,
Bernhard

Reply via email to