Thursday, January 22, 2026

Solving the "gitk X Error: BadLength" Rendering Crash

If you’ve recently tried to run gitk and were met with a confusing X11 crash message, you aren’t alone. This common error looks like this:

 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)

The Problem: Font Rendering Overload
The root cause is usually a bug in the libXft library, which gitk (via Tcl/Tk) uses to render text. When a commit message contains emojis or certain wide Unicode characters, the system attempts to render them using high-resolution bitmap fonts (like Noto Color Emoji). The rendering request becomes "too large" for the X server to handle, causing an immediate crash.
The Solutions
1. The Best Fix: Install Unifont
The most reliable and "clean" solution is to install the unifont package. This provides a universal fallback font that handles these characters without triggering the rendering bug.
Commandsudo apt install unifont
2. The Quick Fix: Remove the Problematic Font
If you don't need color emojis in your terminal or system tools, you can simply remove the font package that usually triggers the crash.
Commandsudo apt remove --purge fonts-noto-color-emoji
Note: This may make emojis look like simple wireframe boxes in some applications.
3. For WSL2 Users
If you are running Linux via WSL2 on Windows, you can avoid X11 rendering issues entirely by using the Windows native version of gitk directly from your terminal:
Command/mnt/c/Program\ Files/Git/cmd/gitk.exe
Summary
This isn't a bug in your code or your Git repository—it's a system-level font rendering conflict. Installing unifont is generally the best way to get back to work without losing emoji support elsewhere.

No comments:

Post a Comment