[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ftw/nftw is limited by stack size
From: |
Petr Vandrovec |
Subject: |
Re: ftw/nftw is limited by stack size |
Date: |
Fri, 17 Jan 2003 18:18:49 +0100 |
On 17 Jan 03 at 17:56, Jim Meyering wrote:
> Ulrich Drepper <address@hidden> wrote:
> > Jim Meyering wrote:
> >
> >> What do you think about rewriting it to use space on the heap
> >> rather than on the stack?
> >
> > It makes the general case slower for the few lunatics with such
> > filesystem hierachies. That's absolutely not desirable.
>
> Hi Uli,
>
> Are you sure it'd make a significant difference in performance?
> I want a portable version of ftw that is immune to such abuse,
> and am willing to incur a reasonable performance penalty, so I'll
> probably implement it and make du use the more robust version.
>
> > Instead you could work around the problem (for some platforms) by using
> > not the normal stack, but instead some allocated memory.
> >
> > use mmap() to allocate many many megabytes of memory (maybe even you the
> > automatic-grow feature Linux provides, although this might also be
> > limited by the stack size). This won't actually require any physical
> > memory. Then use makecontext and setcontext to use this memory.
>
> Yes, but should every application that uses ftw -- and that wants
> to avoid that limitation -- have to go to such lengths?
Most of apps expect that max. path length is PATH_MAX, and fail misserably
when faced longer path - for example getcwd() & co. returns truncated path
silently on some kernels... And as you cannot pass paths longer than
PATH_MAX to open/stat anyway...
Petr Vandrovec
address@hidden