dwm crashes when opening 50+ clients (tile layout) f09418bb
Many users new to dwm find themselves caught out by being kicked out to the login manager (dwm crashing) when they open 50+ clients for demonstration purposes. The number of clients reported varies depending on the resolution of the monitor.

The cause of this is due to how the default tile layout calculates the height of the next client based on the position of the previous client. Because clients have a minimum size the (ty) position can exceed that of the window height, resulting in (m->wh - ty) becoming negative. The negative height stored as an unsigned int results in a very large height ultimately resulting in dwm crashing.

This patch adds safeguards to prevent the ty and my positions from exceeding that of the window height.
bakkeby · 2020-04-23 09:50 1 file(s) · +4 −2
dwm.c +4 −2
1689 1689
		if (i < m->nmaster) {
1690 1690
			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
1691 1691
			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
1692 -
			my += HEIGHT(c);
1692 +
			if (my + HEIGHT(c) < m->wh)
1693 +
				my += HEIGHT(c);
1693 1694
		} else {
1694 1695
			h = (m->wh - ty) / (n - i);
1695 1696
			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
1696 -
			ty += HEIGHT(c);
1697 +
			if (ty + HEIGHT(c) < m->wh)
1698 +
				ty += HEIGHT(c);
1697 1699
		}
1698 1700
}
1699 1701