Discussion:
[dev] Fix for dwm crash due to emoji in window titles
Alexander Krotov
2018-07-18 23:19:43 UTC
Permalink
From time to time there are threads about the bug in dwm that make it crash
when it cannot render some glyphs in window titles (usually emoji).

Here is a way to reproduce the bug:
https://lists.suckless.org/dev/1608/30274.html

Here is an attempt to fix the bug that makes dwm freeze:
https://lists.suckless.org/dev/1802/32534.html

Attached is a patch that fixes the bug for me. With it applied the symbol
is simply not rendered (while other symbols are) and dwm continues to be
usable.

It fixes both the crash due to symbols in the window title and due to
symbols in the status bar (xsetroot -name).

I do not understand xlib and Xft enough to make a more clean fix, but
hopefully maintainers can improve it and apply to the mainline. Meanwhile,
dwm users can use this workaround.
Hiltjo Posthuma
2018-07-19 15:41:16 UTC
Permalink
Post by Alexander Krotov
From time to time there are threads about the bug in dwm that make it
crash when it cannot render some glyphs in window titles (usually
emoji).
[1]https://lists.suckless.org/dev/1608/30274.html
[2]https://lists.suckless.org/dev/1802/32534.html
Attached is a patch that fixes the bug for me. With it applied the
symbol is simply not rendered (while other symbols are) and dwm
continues to be usable.
It fixes both the crash due to symbols in the window title and due to
symbols in the status bar (xsetroot -name).
I do not understand xlib and Xft enough to make a more clean fix, but
hopefully maintainers can improve it and apply to the mainline.
Meanwhile, dwm users can use this workaround.
References
1. https://lists.suckless.org/dev/1608/30274.html
2. https://lists.suckless.org/dev/1802/32534.html
From 99e82a4d44650c98edb17836fcef743cc87a614a Mon Sep 17 00:00:00 2001
Date: Thu, 19 Jul 2018 02:10:28 +0300
Subject: [PATCH] Ignore Xft errors when drawing text
---
dwm.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/dwm.c b/dwm.c
index 4465af1..63a9df1 100644
--- a/dwm.c
+++ b/dwm.c
@@ -731,7 +731,11 @@ drawbar(Monitor *m)
if ((w = m->ww - sw - x) > bh) {
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
+ XSetErrorHandler(xerrordummy);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
+ XSync(dpy, False);
+ XSetErrorHandler(xerror);
+
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else {
--
2.18.0
It is not a fix, it will just ignore the error.

The emoji crash is a bug in Xft.
--
Kind regards,
Hiltjo
Kai Hendry
2018-07-23 00:34:53 UTC
Permalink
Post by Hiltjo Posthuma
It is not a fix, it will just ignore the error.
Shouldn't https://en.wikipedia.org/wiki/Robustness_principle apply?

Draconian error handling was the hallmark of XML.
Post by Hiltjo Posthuma
The emoji crash is a bug in Xft.
Do you happen to have the bug number handy so I can please track it? Guess it's on https://bugs.freedesktop.org/ but failed to find it.

Thank you,
Laslo Hunhold
2018-07-23 04:05:58 UTC
Permalink
On Mon, 23 Jul 2018 08:34:53 +0800
Kai Hendry <***@iki.fi> wrote:

Dear Kai,
Post by Kai Hendry
Shouldn't https://en.wikipedia.org/wiki/Robustness_principle apply?
Draconian error handling was the hallmark of XML.
I agree with you in the given case, but the robustness principle
probably brought us SGML and all its implications. Be careful what you
wish for, as being liberal with what input you accept can lead to
horrible security and consistency implications.

With best regards

Laslo Hunhold
--
Laslo Hunhold <***@frign.de>
Kai Hendry
2018-07-23 06:29:32 UTC
Permalink
Thanks for agreeing with me Laslo,
Post by Laslo Hunhold
I agree with you in the given case, but the robustness principle
probably brought us SGML and all its implications. Be careful what you
wish for, as being liberal with what input you accept can lead to
horrible security and consistency implications.
HTML parsing is pretty well defined https://html.spec.whatwg.org/multipage/parsing.html#parsing

Wouldn't you agree the Web has dealt with these "implications"? It's not pretty, but it works.
Hiltjo Posthuma
2018-07-23 07:31:10 UTC
Permalink
Post by Kai Hendry
Post by Hiltjo Posthuma
It is not a fix, it will just ignore the error.
Shouldn't https://en.wikipedia.org/wiki/Robustness_principle apply?
Robustness is not ignoring errors. It should not ignore errors.

If anything:
https://en.wikipedia.org/wiki/Fail-fast
Post by Kai Hendry
Draconian error handling was the hallmark of XML.
Post by Hiltjo Posthuma
The emoji crash is a bug in Xft.
Do you happen to have the bug number handy so I can please track it? Guess it's on https://bugs.freedesktop.org/ but failed to find it.
Thank you,
Its the first item when searching for: "xft emoji bug".
https://bugzilla.redhat.com/show_bug.cgi?id=1498269


I cannot reproduce it on my OpenBSD system either. It is probably patched to do
the sane thing there.
--
Kind regards,
Hiltjo
Silvan Jegen
2018-07-23 15:41:43 UTC
Permalink
Post by Hiltjo Posthuma
Post by Kai Hendry
Post by Hiltjo Posthuma
It is not a fix, it will just ignore the error.
Shouldn't https://en.wikipedia.org/wiki/Robustness_principle apply?
Robustness is not ignoring errors. It should not ignore errors.
https://en.wikipedia.org/wiki/Fail-fast
Post by Kai Hendry
Draconian error handling was the hallmark of XML.
Post by Hiltjo Posthuma
The emoji crash is a bug in Xft.
Do you happen to have the bug number handy so I can please track it? Guess it's on https://bugs.freedesktop.org/ but failed to find it.
Thank you,
Its the first item when searching for: "xft emoji bug".
https://bugzilla.redhat.com/show_bug.cgi?id=1498269
It feels like the source for this ominous crash has finally been found
after what feels like an eternity. According to the bug report there
won't be a fix in Xft any time soon though since they suggest to
people to just not use Xft...


Cheers,

Silvan
Kai Hendry
2018-09-10 02:31:37 UTC
Permalink
Post by Silvan Jegen
It feels like the source for this ominous crash has finally been found
after what feels like an eternity. According to the bug report there
won't be a fix in Xft any time soon though since they suggest to
people to just not use Xft...
What's a good approach going forward here? Or a workaround? Rollback to dwm that didn't use Xft?

My Xorg just crashed losing my state because of this insane bug and I am rather fed up now.
Kai Hendry
2018-09-10 05:23:29 UTC
Permalink
Tried rolling back to dwm 6.0 but couldn't get font rendering to work. :/

Loading Image...

Now I am using Alexander Krotov's original patch, which works. So thanks for that.
Loading...