DORMANTno replies

[PATCH] Ensure sufficient stack space for async threads

From: Rich Felker <hidden>
Date: 2016-06-15 22:53:39

The recv_sideband function, which runs in a non-main thread, makes use
of a 64k buffer on the stack. While Linux/glibc systems default to
huge thread stack size (typically 2-10 MB), it's not portable to
assume that the stack for a newly created thread will be able to
support large automatic buffers unless you specifically request space
when creating the thread. The attached patch ensures that at least
128k of stack space is available; certainly that could be increased if
it's deemed safer.

Does this actually matter? Well, the default build of git crashes on
musl libc (www.etalabs.net/musl), where the default stack size is 16k.
We're presently in the process of evaluating what's a good default
stack size for musl to give applications that don't request one
(aiming for a balance that avoids breaking programs like git but also
avoids excess memory usage on tiny embedded systems, a major target
for us) and we'll almost certainly increase the default enough that
the current version of git works without explicitly requesting a stack
size. Nonetheless, this could be an issue again in the future when
running/using git on mobile/embedded-type targets (anybody know
Bionic's default?), and since the patch is simple and has essentially
no cost, I think it's worthwhile to include.

If you have questions please include me in the Cc as I'm not
subscribed.

Rich

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help