`squid -N` crashes due to unreasonable heap allocation
To reproduce:
# apk add squid # (From a fresh Alpine 3.18.0 image)
# squid -N
2023/07/04 19:45:45| WARNING: BCP 177 violation. Detected non-functional IPv6 loopback.
2023/07/04 19:45:45| FATAL: xcalloc: Unable to allocate 1073741816 blocks of 432 bytes!
2023/07/04 19:45:45| Squid Cache (Version 5.9): Terminated abnormally.
CPU Usage: 0.026 seconds = 0.023 user + 0.004 sys
Maximum Resident Size: 52736 KB
Page faults with physical i/o: 0
Aborted (core dumped)
# echo $?
134
I did a little hunting with GDB, and tracked the offending xcalloc
call to line 144 in squid/src/fde.cc:
Table = static_cast<fde *>(xcalloc(Squid_MaxFD, sizeof(fde)));
On my system, sizeof(fde)
is 408. I have no idea why they're allocating 408 bytes for each possible file descriptor.