i386/62699: fstat randomly crashes with "out of memory"
sigma at pair.com
Wed Feb 11 10:20:15 PST 2004
>Synopsis: fstat randomly crashes with "out of memory"
>Arrival-Date: Wed Feb 11 10:20:14 PST 2004
>Originator: Kevin Martin
pair Networks, Inc
FreeBSD koloda.pair.com 4.8-STABLE FreeBSD 4.8-STABLE #0: Fri Oct 3 11:10:15 EDT 2003 sigma at koloda.pair.com:/usr/src/sys/compile/PAIRqm i386
About 1 in every 1000 runs, "fstat" will die with "Out of memory". The problem has been traced to line 349 of fstat.c 184.108.40.206, where filed.fd_lastfile occasionally gets a huge, incorrect value, and subsequently tries to malloc several gigabytes to hold the array of files.
Watch for "Out of memory" instances.
A workaround is simply to insert a sanity check that fd_lastfile is less than, say, 100000. A more elegant workaround would be a comparison to the real size of the file table. A real fix would be to find out why garbage ends up in the filed structure, which is read via KVM_READ just a few lines earlier.
More information about the freebsd-i386