Greg,

I had increased the stack size for busybox and that seemed to fix problem 
in accessing large SD cards.  However, I then ran into a problem with NFS 
mounts. 
Readdir was attempting allocate 32K on my stack.   The alloca() is the 
real problem, but I was willing to take a slight performance hit to save 
memory, so I used this patch instead.

--- uClibc/libc/misc/dirent/opendir.c   (revision 965)
+++ uClibc/libc/misc/dirent/opendir.c   (revision 966)
@@ -67,8 +67,9 @@
        ptr->dd_fd = fd;
        ptr->dd_nextloc = ptr->dd_size = ptr->dd_nextoff = 0;
 
-       ptr->dd_max = statbuf.st_blksize;
-       if (ptr->dd_max < 512)
+//     ptr->dd_max = statbuf.st_blksize;
+//     if (ptr->dd_max < 512)
+//IDEAL  __getdents alloca on the stack this size
                ptr->dd_max = 512;
 
        if (!(ptr->dd_buf = calloc(1, ptr->dd_max))) {


Jeff Johnston



> Date: Wed, 04 Feb 2009 23:34:33 +1000
> From: Greg Ungerer <[email protected]>
> Subject: Re: [uClinux-dev] Stack overflow in the readdir
> To: uClinux development list <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-15; format=flowed
> 
> 
> Hi Davide,
> 
> Davide Zanni wrote:
> >     I have an application that display the content of an USB key with 
> > the function readdir. This work fine but with an USB key the 
application 
> > crash because in the file uClibc/libc/sysdeps/linux/common/getdents.c 
> > the compiler try to allocate about 31K of data with the function 
"alloca 
> > (red_nbytes)" and the default stack size is 12K in the thread that use 

> > the function. To solve the problem I have increased the stack size of 
> > that thread.
> > For the other program that use uClibc and the function readdir, like 
> > busybox, it's possible that the program will crash. It's possible 
change 
> > the allocation of the memory with the malloc to solve the problem for 
> > all the application?
> 
> Try the patch attached to:
> 
> http://mailman.uclinux.org/pipermail/uclinux-dev/2008-June/046758.html
> 
> Please report if it works for you. I have it sitting in my
> queue of patches to apply to the uClinux-dist. I was hoping
> to get some wider confirmation of it working as expected...
> 
> Regards
> Greg
> 
> 
> ------------------------------------------------------------------------
> Greg Ungerer  --  Principal Engineer        EMAIL:     [email protected]
> SnapGear, a McAfee Company                  PHONE:       +61 7 3435 2888
> 825 Stanley St,                             FAX:         +61 7 3891 3630
> Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com

_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to