Re: [hackers] [libsl] die() on failure in ecalloc?

From: Markus Teich <>
Date: Fri, 4 Nov 2016 19:53:35 +0100

Heyho Hiltjo,

> > My proposal would be to change ecalloc to use die() and in the rare cases
> > where the allocation error should be handled gracefully just don't use
> > ecalloc, but calloc directly.
> >
> > Btw: The drw unification patches are still not merged to libsl, only to dwm,
> > dmenu and sent.
> >
> Do you want to (re)send the patch or should I just change it?

Just patch util.c in dmenu and dwm to use die(), as I just did it in sent. If
you also maintain libsl, feel free to use the old patch queue with explanations
in the commit messages or just create a new commit by pulling drw.[ch] and
util.[ch] from one of the other projects.

> > In dwm there are three usages (new monitor, new client, XineramaScreenInfo)
> > as well, all of them with immediate references and therefore segfaults.
> >
> > In dmenu there are no uses of ecalloc() apart from the ones implied by drw.c
> > usage and in sent there are currently no calls to ecalloc() as well, however
> > I'd like to introduce it there with the die() behavior.
> >
> It's definitely a bug.
> > 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.

Received on Fri Nov 04 2016 - 19:53:35 CET

This archive was generated by hypermail 2.3.0 : Fri Nov 04 2016 - 20:00:34 CET