Re: [hackers] [dwm] [PATCH] make OOM on new client non-fatal

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sat, 12 Nov 2016 01:24:33 +0100

On Fri, Nov 11, 2016 at 11:38 PM, Markus Teich
<markus.teich_AT_stusta.mhn.de> wrote:
>> >>> I can at least imagine cases where quitting on allocation failure is not
>> >>> good. For example dwm is running, a new client starting up, but there is
>> >>> no memory left for the client struct. In this case dwm should just print
>> >>> an error, but not quit to give the user the chance to fix the problem
>> >>> without losing all their work in the other clients (which would die as
>> >>> well, if dwm dies and the X-Server quits).
>> >>
>> >> I agree it should either die completely or give a very clear error message.
>> >
>> > I'll make a patch for dwm.
>>
>> No need anymore :)
>
> Heyho Hiltjo,
>
> that is what I meant. I'm not sure if it's the best idea to just ignore the new
> client. Maybe there is a way we can tell the X-Server that we refuse to manage
> this client?
>
> --Markus
>
>
> dwm.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/dwm.c b/dwm.c
> index 0afd630..47aaf3c 100644
> --- a/dwm.c
> +++ b/dwm.c
> _AT_@ -1024,7 +1024,10 @@ manage(Window w, XWindowAttributes *wa)
> Window trans = None;
> XWindowChanges wc;
>
> - c = ecalloc(1, sizeof(Client));
> + if (!(c = calloc(1, sizeof(Client)))) {
> + perror("dwm: calloc in manage()");
> + return;
> + }
> c->win = w;
> /* geometry */
> c->x = c->oldx = wa->x;
> --
> 2.7.3
>
>

I'm not sure, in the end it's not up to me to decide, I'm not the
maintainer of dwm. My main concern is the warning is not clear enough:
the error is generally logged to the console which is not viewed by
the user when X11 is started. Exit to the console is very clear, but
also disruptive.

In my use-cases (desktop and non-critical) I don't mind the current behaviour.

NOTE that there are other cases too in the code (and probably X11 and
stuff) where allocations could be fatal. Maybe it should not be solved
directly in dwm.

Kind regards,
Hiltjo
Received on Sat Nov 12 2016 - 01:24:33 CET

This archive was generated by hypermail 2.3.0 : Sat Nov 12 2016 - 01:36:15 CET