Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kaputt! Linenumbersymbol with Hack font #1

Closed
zartstrom opened this issue Sep 18, 2016 · 24 comments
Closed

Kaputt! Linenumbersymbol with Hack font #1

zartstrom opened this issue Sep 18, 2016 · 24 comments

Comments

@zartstrom
Copy link

zartstrom commented Sep 18, 2016

9776, Hex 2630, Octal 23060
vim-airline
Crash
76/309☰ :137

Hack font related, triggered by airline with the linenumbersymbol?!

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7685a1e in XftDrawGlyphSpec () from /usr/lib/libXft.so.2
(gdb) bt
#0 0x00007ffff7685a1e in XftDrawGlyphSpec () from /usr/lib/libXft.so.2
#1 0x000000000042296e in rxvt_font_xft::draw(rxvt_drawable&, int, int, unsigned int const*, int, int, int) ()
#2 0x000000000041cfc2 in rxvt_term::scr_refresh() ()
#3 0x000000000041ea72 in rxvt_term::flush() ()
#4 0x0000000000439cee in ev_invoke_pending() ()
#5 0x000000000043a73d in ev_run ()
#6 0x0000000000419333 in main ()

(gdb)

@blueyed
Copy link
Owner

blueyed commented Sep 18, 2016

@zartstrom
Do you have a reproducible, simple test case, please? ;D

Please paste the git diff from the src we've been fiddling with for reference.

Also, what is the airline setting / symbol name?!

Note: only happened when the terminal was wide enough (half your screen).

@blueyed blueyed changed the title Linenumbersymbol?! Kaputt! Linenumbersymbol with Hack font Sep 18, 2016
@zartstrom
Copy link
Author

zartstrom commented Sep 19, 2016

I cloned the repo again, commented out the three other patches and did a
diff -Naur ./src/rxvt-unicode-9.22/src/rxvtfont.C ../PKGBUILD-rxvt-unicode-wide/src/rxvt-unicode-9.22/src/rxvtfont.C > patch.txt
The diff is shown below. We deleted so many lines? :o
../PKGBUILD-rxvt-unicode-wide is the version we fiddled with.

I try to come up with the evil character and a more isolated scenario to reproduce the crash.

--- ./src/rxvt-unicode-9.22/src/rxvtfont.C  2016-09-19 20:27:35.289822043 +0200
+++ ../PKGBUILD-rxvt-unicode-wide/src/rxvt-unicode-9.22/src/rxvtfont.C  2016-09-18 20:34:48.336894812 +0200
@@ -1030,10 +1030,10 @@

   careful = xcs->lbearing < 0 || xcs->rbearing > prop->width * wcw;

-#if !ENABLE_WIDE_GLYPHS
+//#if !ENABLE_WIDE_GLYPHS
   if (careful && !OVERLAP_OK (w, wcw, prop))
     return false;
-#endif
+//#endif

   return true;
 }
@@ -1245,22 +1245,11 @@

       FT_Face face = XftLockFace (f);

-/*
- * use ascent, descent and height from XftFont *f instead of FT_Face face.
- * this somehow reproduces the behaviour of the line height as seen on xterm.
-
       ascent  = (face->size->metrics.ascender + 63) >> 6;
       descent = (-face->size->metrics.descender + 63) >> 6;
       height  = max (ascent + descent, (face->size->metrics.height + 63) >> 6);
       width   = 0;

- */
-
-      ascent  = f->ascent;
-      descent = f->descent;
-      height  = max (ascent + descent, f->height);
-      width   = 0;
-
       bool scalable = face->face_flags & FT_FACE_FLAG_SCALABLE;

       XftUnlockFace (f);
@@ -1284,21 +1273,12 @@
           XGlyphInfo g;
           XftTextExtents16 (disp, f, &ch, 1, &g);

-/*  
- * bukind: don't use g.width as a width of a character!
- * instead use g.xOff, see e.g.: http://keithp.com/~keithp/render/Xft.tutorial
-
           g.width -= g.x;

           int wcw = WCWIDTH (ch);
           if (wcw > 0) g.width = (g.width + wcw - 1) / wcw;

           if (width    < g.width       ) width    = g.width;
- */
-          int wcw = WCWIDTH (ch);
-          if (wcw > 1) g.xOff = g.xOff / wcw;
-          if (width < g.xOff) width = g.xOff;
-
           if (height   < g.height      ) height   = g.height;
           if (glheight < g.height - g.y) glheight = g.height - g.y;
         }
@@ -1361,6 +1341,7 @@
   if (!prop || prop->width == rxvt_fontprop::unset)
     return true;

+
   // check character against base font bounding box
   FcChar32 ch = unicode;
   XGlyphInfo g;
@@ -1370,15 +1351,16 @@
   int wcw = max (WCWIDTH (unicode), 1);

   careful = g.x > 0 || w > prop->width * wcw;
+  printf("Careful: %d\n", careful);

 #if !ENABLE_WIDE_GLYPHS
   if (careful && !OVERLAP_OK (w, wcw, prop))
     return false;
+#endif

   // this weeds out _totally_ broken fonts, or glyphs
   if (!OVERLAP_OK (g.xOff, wcw, prop))
     return false;
-#endif

   return true;
 }
@@ -1496,6 +1478,7 @@
 #endif
             XftDrawRect (d2, &term->pix_colors[bg >= 0 ? bg : Color_bg].c, 0, 0, w, h);

+          printf("1:%d %d %d %d %d\n", d2, &term->pix_colors[fg].c, f, enc, ep - enc);
           XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc);
           XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y);
         }
@@ -1504,6 +1487,7 @@
     }
   else
     {
+      printf("2:%d %d %d %d %d\n", d, &term->pix_colors[fg].c, f, enc, ep - enc);
       clear_rect (d, x, y, w, h, bg);
       XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc);
     }

@blueyed
Copy link
Owner

blueyed commented Sep 20, 2016

We deleted so many lines? :o

They come from the other patches (line-spacing-fix.patch at least); so you have patched the new clone already, but removed those patches.

Can you please try it from the branch that is used for the patch: https://github.com/blueyed/rxvt-unicode/tree/display-wide-glyphs:

git clone -b display-wide-glyphs https://github.com/blueyed/rxvt-unicode
cd rxvt-unicode
wget http://dist.schmorp.de/rxvt-unicode/rxvt-unicode-9.22.tar.bz2
tar xf rxvt-unicode-9.22.tar.bz2
cp -a rxvt-unicode-9.22/{libev,libptytty} .
./configure --enable-unicode3 --enable-256-color --enable-wide-glyphs --disable-smart-resize
make
src/rxvt

(no need to install it)

If you can reproduce it, you can bisect it:
git bisect bad
git checkout fdce9d7 # first commit of this patch
make
src/rxvt

Then either git bisect good (no crash) or git bisect bad (crash): git will move you to the next commit then. Just run make && src/rxvt then to test it.

Let's see if that helps.

Then, of course a simple test case (minimal vimrc to trigger this) would be nice.
Also the value of &columns from Vim seemed to be important (possibly to make the char in the lower right visible).

Thanks!

@blueyed
Copy link
Owner

blueyed commented Sep 20, 2016

FYI: maxlinenr is only used when the window is wider than 80 chars in airline: https://github.com/blueyed/vim-airline/blob/7a720bbbd74b22fc029844c9ff087bbc1e09effb/autoload/airline/init.vim#L133-L139.

@blueyed
Copy link
Owner

blueyed commented Sep 20, 2016

Check also if changing something in this area helps:

  let g:airline_section_z = airline#section#create(['windowswap', 'obsession', '%3p%%'.spc, 'linenr', 'maxlinenr', spc.':%3v'])
  • remove 'maxlinenr', from there
  • replace spc.' with ' (a regular space)

@blueyed
Copy link
Owner

blueyed commented Sep 20, 2016

Please also paste the output from xrdb -q|grep -i urxvt.

@zartstrom
Copy link
Author

I built rxvt by your instructions on my work laptop, and it reproduced the crash as well. (execute nvim in the rxvt window).
I replaced ☰ (= U2630) by another character as value for g:airline_symbols.maxlinenr, and nvim didn't crash. ⇒ U2630 (together with the rest of my settings) causes the crash.

The output of xrdb -q|grep -i urxvt is

URxvt*depth:    24
URxvt*buffered: false
URxvt*background:   [95]#000000
URxvt*foreground:   #FFFFFF
URxvt.font: xft:Hack:size=10:antialias=true:hinting=true,xft:Symbola,xft:UbuntuMonoDerivativePowerline Nerd Font
URxvt.boldFont: xft:Hack:style=Bold:size=10:antialias=true:hinting=true,xft:DejaVu Sans Mono:size=12,xft:FontAwesome:size=12
URxvt.italicFont:   xft:Hack:style=Italic:size=10:antialias=true:hinting=true,xft:DejaVu Sans Mono:size=12,xft:FontAwesome:size=12
URxvt.boldItalicFont:   xft:Hack:style=Bold Italic:size=10:antialias=true:hinting=true,xft:DejaVu Sans Mono:size=12,xft:FontAwesome:size=12
URxvt*scrollstyle:  rxvt
URxvt*scrollBar:    false
URxvt*skipBuiltinGlyphs:    false
URxvt*perl-ext-common:  resize-font,fullscreen,vtwheel
URxvt.resize-font.smaller:  C-Down
URxvt.resize-font.bigger:   C-Up
URxvt.keysym.F11:   perl:fullscreen:switch
URxvt.keysym.Home:  \033[1~
URxvt.keysym.End:   \033[4~
URxvt.keysym.KP_Home:   \033[1~
URxvt.keysym.KP_End:    \033[4~
URxvt.letterSpace:  -1
URxvt*.transparent: true
URxvt*.shading: 60

@zartstrom
Copy link
Author

Started bisecting (btw what a cool command!). It seems your first commit is the culprit.
git co 15ced41 && make -B && src/rxvt is good (commit from Emanuele Giaquinta 8 weeks ago)
and next
git co fdce9d7 && make -B && src/rxvt is bad/crashes

@blueyed
Copy link
Owner

blueyed commented Sep 21, 2016

It seems your first commit is the culprit.

Not unlikely, especially given there are fixes to it later.. ;)
Can you then test all following commits to see if they are all causing the crash, please?

@blueyed
Copy link
Owner

blueyed commented Sep 21, 2016

Can you also create a screen dump of the output that would cause the crash, i.e. from a working urxvt instance, the paste it into a file and upload it as a gist and/or paste it here.
Hopefully that makes it easier to reproduce.
Make sure that cat screendump.txt also causes the crash in a bad urxvt instance then.

@zartstrom
Copy link
Author

to no avail, I tried all commits, but there's a segmentation fault every time.

I don't understand the screen dump thing, I need some guidance..

Until now I did not find any text that lets rxvt crash by cat'ing or echo'ing. I.e. cat'ing the help file airline.txt does not lead to a crash (but displays U2630 correctly)

@blueyed
Copy link
Owner

blueyed commented Sep 21, 2016

I don't understand the screen dump thing, I need some guidance..

Create the test case in a working instance (i.e. using the system urxvt), and then just mark the whole window using the mouse (Shift-click-drag etc), then paste it into a file: it won't have the colors etc, but all the test. Basically an ASCII screenshot.

@blueyed
Copy link
Owner

blueyed commented Sep 21, 2016

Also try commenting your urxvt options, e.g. buffered.

Mine

% xrdb -q|grep -i urxvt | grep -v keysym|sort
URxvt.cutchars: "\\`\"'&()*,;<>?@[]^{|│}«»‘’"
URxvt.fading:   0
URxvt.font: xft:UbuntuMonoDerivativePowerline Nerd Font:size=8,xft:DejaVu Sans Mono,xft:monospace,xft:Symbola
URxvt.geometry: 84x32
URxvt.iconFile: /usr/share/icons/gnome/32x32/apps/gnome-terminal.png
URxvt.jumpScroll:   true
URxvt*letterSpace:  -1
URxvt.matcher.button:   2
URxvt.matcher.pattern.0:    (?:https?:/ /|ftp:/ /|news:/ /|mailto:|file:/ /|\\bwww\\.) [\\w\\-\\@;\\/?:&=%\\$.+!*\\x27,~#]* ( \\([\\w\\-\\@;\\/?:&=%\\$.+!*\\x27,~#]*\\) | [\\w\\-\\@;\\/?:&=%\\$+*~])+
URxvt.matcher.pattern.1:    [a-f0-9]{7,10}\\.\\.[a-f0-9]{7,10}
URxvt.perl-ext-common:  default,-matcher,urxvt-perls/url-select,urxvt-perls/keyboard-select,urxvt-font-size/font-size,bell-command
URxvt.saveLines:    81920
URxvt.scrollBar_floating:   true
URxvt.scrollBar_right:  true
URxvt.scrollBar:    true
URxvt.scrollColor:  #839496
URxvt.scrollstyle:  rxvt
URxvt.scrollTtyKeypress:    true
URxvt.scrollTtyOutput:  false
URxvt.scrollWithBuffer: true
URxvt.searchable-scrollback:    C-M-r
URxvt.secondaryScreen:  1
URxvt.secondaryScroll:  0
URxvt.skipScroll:   true
URxvt.tabbed.saveLines: 1000
URxvt.tabbed.scrollBar: false
URxvt.tabbed.secondaryScroll:   true
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tabbar-fg: 3
URxvt.tabbed.tab-bg:    1
URxvt.tabbed.tab-fg:    0
URxvt.urgentOnBell: true
URxvt.url-launcher: open-in-running-browser
URxvt.urlLauncher:  open-in-running-browser
URxvt.url-select.button:    2
URxvt.url-select.launcher:  open-in-running-browser
URxvt.url-select.underline: false
URxvt.visualBell:   true

@blueyed
Copy link
Owner

blueyed commented Sep 25, 2016

I've pushed some (probably unrelated) thing to https://github.com/blueyed/rxvt-unicode/tree/display-wide-glyphs, please try it though.

Any progress with making me able to reproduce and debug it? :)

@zartstrom
Copy link
Author

i will check it!

@zartstrom
Copy link
Author

I found at least something.
I wrote a test.sh, that tries to print a bold ☰.

#!/bin/bash

bold=$(tput bold)
echo "test ${bold}23/46☰"

If I start urxvt (./rxvt) and run ./test.sh the terminal crashes.
BUT if I start urxvt and cat test.sh the content of the file is displayed correctly. And if I then do ./test.sh urxvt doesn't crash, but displays a bold 23/46☰

The output of xrdb -q|grep -i urxvt is

URxvt*depth:    24
URxvt*buffered: false
URxvt*background:   [95]#000000
URxvt*foreground:   #FFFFFF
URxvt.font: xft:Hack:size=10
URxvt*scrollstyle:  rxvt
URxvt*scrollBar:    false
URxvt*perl-ext-common:  resize-font,fullscreen,vtwheel
URxvt.resize-font.smaller:  C-Down
URxvt.resize-font.bigger:   C-Up
URxvt.keysym.F11:   perl:fullscreen:switch
URxvt.keysym.Home:  \033[1~
URxvt.keysym.End:   \033[4~
URxvt.keysym.KP_Home:   \033[1~
URxvt.keysym.KP_End:    \033[4~
URxvt.letterSpace:  -1
URxvt*.transparent: true
URxvt*.shading: 60

Especially there is only one font setting URxvt.font: xft:Hack:size=10, but nothing for bold or italics fonts.

Lets see if you can reproduce the crash!

@blueyed
Copy link
Owner

blueyed commented Sep 28, 2016

I've used (only) your Xresources and have the Hack font installed, but the symbol gets not displayed for me?! (I see the square box). No crashes though.
With only Hack you should also not see it, since it's coming from Symbola IIRC?!
You are also using extra/ttf-hack from Arch, and not a custom Hack font/download?!

@zartstrom
Copy link
Author

Ctrl+Shift says the ☰ comes from Arial Unicode MS. fc-list doesn't list any other Hack-font.

grml, I destroyed my testcase. I simplified the test.sh script (assuming knowing what the cause of the problem is) and the ./test.sh in my last comment doesn't crash urxvt. (but nvim still crashes)

I'll try further...

@blueyed
Copy link
Owner

blueyed commented Sep 28, 2016

How can it come from Arial, if you are using just a single font?
Are there other font related settings in your Xresources?
Having a minimal Xresources file would be nice, once you can reproduce it again.

@blueyed
Copy link
Owner

blueyed commented Sep 28, 2016

I think we're far across the point where enabling debugging symbols and using gdb properly would be easier btw.. ;)
crossing fingers

@blueyed
Copy link
Owner

blueyed commented Oct 21, 2016

FWIW: ☰ (U2630) comes from Symbola for me.

I am currently trying to fix another (minor) issue, and noticed that it bascally boils down to wcwidth, so I've investigated into a major hack to make urxvt report the wcwidth through looking at the font.
It seems to work good so far, so that might become might next hack to this problem that is not accepted upstream.. ;)

@blueyed
Copy link
Owner

blueyed commented Nov 6, 2016

When looking into this a few weeks ago, I've started an alternative approach.
Please try this instead: https://github.com/blueyed/PKGBUILD-rxvt-unicode-wcwidthcallback

@blueyed
Copy link
Owner

blueyed commented Nov 7, 2016

Canonical location for now: blueyed/rxvt-unicode#1.

@blueyed
Copy link
Owner

blueyed commented Nov 9, 2016

The new patch is in the AUR: https://aur.archlinux.org/packages/rxvt-unicode-wcwidthcallback.

It might be interesting to see the reason for the crash still, but I consider this patch obsolete after all, and close this issue therefore for now.

@blueyed blueyed closed this as completed Nov 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants