Gitk crashes when viewing commit containing emoji: X Error of failed request: BadLength (poly request too large or internal Xlib length error)

emojigitunicodex11

I'm able to open gitk but it crashes as soon as I open a commit whom changes contains an emoji (not the commit message).

Error

❯ gitk --all
X Error of failed request:  BadLength (poly request too large or internal Xlib length error)
  Major opcode of failed request:  139 (RENDER)
  Minor opcode of failed request:  20 (RenderAddGlyphs)
  Serial number of failed request:  6687
  Current serial number in output stream:  6706

Env

❯ cat /etc/os-release --plain
NAME="Linux Mint"
VERSION="20 (Ulyana)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 20"
VERSION_ID="20"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=ulyana
UBUNTU_CODENAME=focal

Git

❯ git –version
git version 2.25.1

Examples

6e05ecd add v3->v4 migration script to update variables
https://github.com/rafaelrinaldi/pure/pull/271/commits/6e05ecdad0e4f623050e154e16c0af0315767940

Questions

I tried various things:

  • removing ~/.Xresources config related to fonts
  • editing then removing ~/.config/fontconfig/conf.d/30-icons.conf

Without success, most of the issues I found were related to st terminal. However, I'm not using it but guake, and the issue also happened with yakuake, gnome-terminal and hyper

How could I fix this?

Best Answer

After digging with XFT_DEBUG flag I found something weird. I run the command with the flag and navigate to the problematic commit:

❯ XFT_DEBUG=1 gitk --all
XFT_DEBUG=1
XftFontInfoFill: /usr/share/fonts/truetype/noto/NotoSans-Medium.ttf: 0 (15.9999 pixels)
XftFontInfoFill: /usr/share/fonts/truetype/noto/NotoSans-Medium.ttf: 0 (15.9999 pixels)
…
XftFontInfoFill: /usr/share/fonts/truetype/noto/NotoSans-Medium.ttf: 0 (17.5999 pixels)
XftFontInfoFill: /usr/share/fonts/truetype/noto/NotoSans-Bold.ttf: 0 (17.5999 pixels)
XftFontInfoFill: /usr/share/fonts/truetype/noto/NotoSansSymbols2-Regular.ttf: 0 (17.5999 pixels)
XftFontInfoFill: /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: 2 (17.5999 pixels)
XftFontInfoFill: /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: 0 (17.5999 pixels)
XftFontInfoFill: /usr/share/fonts/truetype/noto/NotoColorEmoji.ttf: 0 (109 pixels)
X Error of failed request:  BadLength (poly request too large or internal Xlib length error)
  Major opcode of failed request:  139 (RENDER)
  Minor opcode of failed request:  20 (RenderAddGlyphs)
  Serial number of failed request:  6687
  Current serial number in output stream:  6706

Then spotted the last line prior to the fail had an excentric pixel size

XftFontInfoFill: /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: 0 (17.5999 pixels)

XftFontInfoFill: /usr/share/fonts/truetype/noto/NotoColorEmoji.ttf: 0 (109 pixels)

Removing the Noto-color-emoji fonts solved the issue

apt remove --purge fonts-noto-color-emoji

No more crash and a consistent font size is used to render

XftFontInfoFill: /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc: 2 (17.5999 pixels)

Version

❯ apt show fonts-noto-color-emoji
…
Version: 0~20200408-1