[dev] Fix for dwm crash due to emoji in window titles

563 views
Skip to first unread message

Alexander Krotov

unread,
Jul 18, 2018, 7:20:12 PM7/18/18
to dev mail list
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.
0001-Ignore-Xft-errors-when-drawing-text.patch

Hiltjo Posthuma

unread,
Jul 19, 2018, 11:42:25 AM7/19/18
to dev mail list
On Thu, Jul 19, 2018 at 02:19:43AM +0300, Alexander Krotov wrote:
> 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:
> [1]https://lists.suckless.org/dev/1608/30274.html
> Here is an attempt to fix the bug that makes dwm freeze:
> [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
> From: Alexander Krotov <ila...@gmail.com>
> 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

unread,
Jul 22, 2018, 8:35:31 PM7/22/18
to d...@suckless.org
On Thu, 19 Jul 2018, at 11:41 PM, Hiltjo Posthuma wrote:
> 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.

> 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

unread,
Jul 23, 2018, 12:04:17 AM7/23/18
to d...@suckless.org
On Mon, 23 Jul 2018 08:34:53 +0800
Kai Hendry <hen...@iki.fi> wrote:

Dear Kai,

> 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 <d...@frign.de>

Kai Hendry

unread,
Jul 23, 2018, 2:30:26 AM7/23/18
to d...@suckless.org
Thanks for agreeing with me Laslo,

On Mon, 23 Jul 2018, at 12:05 PM, Laslo Hunhold wrote:
> 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

unread,
Jul 23, 2018, 3:31:28 AM7/23/18
to dev mail list
On Mon, Jul 23, 2018 at 08:34:53AM +0800, Kai Hendry wrote:
> On Thu, 19 Jul 2018, at 11:41 PM, Hiltjo Posthuma wrote:
> > 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

> Draconian error handling was the hallmark of XML.
>
> > 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

unread,
Jul 23, 2018, 11:43:13 AM7/23/18
to dev mail list
On Mon, Jul 23, 2018 at 9:31 AM, Hiltjo Posthuma <hil...@codemadness.org> wrote:
> On Mon, Jul 23, 2018 at 08:34:53AM +0800, Kai Hendry wrote:
>> On Thu, 19 Jul 2018, at 11:41 PM, Hiltjo Posthuma wrote:
>> > 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
>
>> Draconian error handling was the hallmark of XML.
>>
>> > 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

unread,
Sep 9, 2018, 10:32:32 PM9/9/18
to d...@suckless.org
On Mon, 23 Jul 2018, at 11:41 PM, Silvan Jegen wrote:
> 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

unread,
Sep 10, 2018, 1:24:33 AM9/10/18
to d...@suckless.org
Tried rolling back to dwm 6.0 but couldn't get font rendering to work. :/

https://s.natalian.org/2018-09-10/font.png

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

Reply all
Reply to author
Forward
0 new messages