[EMAIL PROTECTED] added to the distribution list because one of
my proposed solutions is an APR enhancement]

Brad Nicholes wrote:

  It appears that we are running into the same problem with Apache 2.0
that we had with Apache 1.3.  The problem is recursive functions that
declare large stack variables such as:

static int read_type_map(apr_file_t **map, negotiation_state *neg,
request_rec *rr)
{
   request_rec *r = neg->r;
   apr_file_t *map_ = NULL;
   apr_status_t status;
   char buffer[MAX_STRING_LEN];           <------------ resolves to
819


That's definitely bad. I can think of three solutions, given that this buffer is used to read a line at a time with apr_file_gets():

1. Use a smaller buffer size
2. Allocate the buffer from a pool (but that solution has its own problems,
  because allocating an 8KB block from a pool will often necessitate
  an additional malloc)
3. Create a variant of apr_file_gets() that allocates its own space
  from a pool supplied by the caller.  (It could use a power-of-two
  allocator.)

I think I like the third option the best.  Anybody else have an
opinion on this?

--Brian





Reply via email to