On Tue, Jan 12, 2021 at 03:31:23PM +0000, Jeff Hostetler via GitGitGadget wrote: > Teach packet_write_gently() to use a stack buffer rather than a static > buffer when composing the packet line message. This helps get us ready > for threaded operations. Sounds like a good goal, but... > static int packet_write_gently(const int fd_out, const char *buf, size_t size) > { > - static char packet_write_buffer[LARGE_PACKET_MAX]; > + char packet_write_buffer[LARGE_PACKET_MAX]; > size_t packet_size; 64k is awfully big for the stack, especially if you are thinking about having threads. I know we've run into issues around that size before (though I don't offhand recall whether there was any recursion involved). We might need to use thread-local storage here. Heap would also obviously work, but I don't think we'd want a new allocation per write (or maybe it wouldn't matter; we're making a syscall, so a malloc() may not be that big a deal in terms of performance). -Peff