* Set a default maximum memory usage value to avoid excessive swapping.

This commit is contained in:
Sam Hocevar 2008-07-15 20:15:35 +00:00 committed by sam
parent 4d91e25ff0
commit 27983605ca
4 changed files with 12 additions and 4 deletions

View File

@ -159,8 +159,12 @@ untouched.
\fB\-M\fR, \fB\-\-max\-memory\fR=\fImebibytes\fR
Specify the maximum amount of memory, in mebibytes (1 MiB = 1,048,576 bytes),
that children are allowed to allocate. This is useful to detect infinite loops
that eat up a lot of memory. The value should be set reasonably high so as not
to interfer with normal program operation.
that eat up a lot of memory.
The value should be set reasonably high so as not to interfer with normal
program operation. By default, it is set to 1024 MiB in order to avoid
accidental excessive swapping. To disable the limitation, set the maximum
memory usage to -1 instead.
\fBzzuf\fR uses the \fBsetrlimit\fR() call to set memory usage limitations and
relies on the operating system's ability to enforce such limitations.

View File

@ -31,6 +31,10 @@
#define MIN_RATIO 0.00000000001
#define MAX_RATIO 5.0
/* The default maximum memory usage is 1024 MiB. If this value is not set,
* zzuf may bring a machine down to its knees because of I/O. */
#define DEFAULT_MEM 1024
struct fuzz
{
uint32_t seed;

View File

@ -43,7 +43,7 @@ void _zz_opts_init(struct opts *opts)
opts->md5 = 0;
opts->checkexit = 0;
opts->verbose = 0;
opts->maxmem = -1;
opts->maxmem = DEFAULT_MEM;
opts->maxtime = -1;
opts->maxcpu = -1;
opts->delay = 0;

View File

@ -1207,7 +1207,7 @@ static void usage(void)
printf(" -l, --list <list> only fuzz Nth descriptor with N in <list>\n");
printf(" -m, --md5 compute the output's MD5 hash\n");
#if defined HAVE_SETRLIMIT && defined ZZUF_RLIMIT_MEM
printf(" -M, --max-memory <n> maximum child virtual memory size in MB\n");
printf(" -M, --max-memory <n> maximum child virtual memory in MiB (default %u)\n", DEFAULT_MEM);
#endif
printf(" -n, --network fuzz network input\n");
printf(" -p, --ports <list> only fuzz network destination ports in <list>\n");