2010-02-23 05:06:24 FAT 32 K cluster
Karthikeyan Jeevanandam (INDIA)
Message: 86374
Hi Mike,
uClinux is crashing with "Data access misaligned address violation" - "Bus Error" in the following scenario
1.Partition a USB HDD with FAT32 partition
2.Format the FAT32 partition with 32k cluster size
3.Create a folder with some files under it
4. Mount the USB
5. Switch to mounted dir and give "ls" command
Please let us know the reason behind it.
Processor: BF527
uClinux distribution: 2009RC1
Let me know if you need more info
Regards,
Karthik
QuoteReplyEditDelete
2010-02-23 07:02:23 Re: FAT 32 K cluster
Mike Frysinger (UNITED STATES)
Message: 86375
see if it fails w/out USB in the stack. create a FAT32 file image and loop mount it.
dd if=/dev/zero of=file count=<some count> .......
mkfs.vfat flie ......
mount -o loop file .........
QuoteReplyEditDelete
2010-02-23 08:29:49 Re: FAT 32 K cluster
Wolfgang Muees (GERMANY)
Message: 86380
Hmmmm...
there was an Issue with 32 KByte Clustersize with the "ls" command of Busybox:
There was a buffer allocated on the stack, and with 32 KByte Clustersize, this buffer has done a stack overflow.
The fix was to allocate the buffer on the heap, or set a bigger stacksize for Busybox.
You will also get this issue on FAT16 devices with 32 KByte Cluster (2 GTBytes).
(someone should fix this issue in Busybox).
regards
Wolfgang
TranslateQuoteReplyEditDelete
2010-02-23 08:38:51 Re: FAT 32 K cluster
Mike Frysinger (UNITED STATES)
Message: 86381
post a diff and/or file/line reference in busybox for someone to look at
QuoteReplyEditDelete
2010-02-23 11:52:24 Re: FAT 32 K cluster
Wolfgang Muees (GERMANY)
Message: 86389
Oh well,
this was long ago - and I had to ask another programmer about that.
OK, here it comes. The "error" is in uClibc (which is in the toolchain, I believe).
In /libc/sysdeps/linux/common/getdents.c, there is the function
__getdents(fd, buf, nbytes)
This function is using alloca() to alloc nbytes on the stack(!).
This function is called from
/libc/misc/dirent/readdir.c
bytes = __getdents(dir->dd_fd, dir->dd_buf, dir->dd_max);
So, if dir->dd_max is big (depending on the clustersize), the alloca() is exceeding the limit of the uclinux stack.
This problem is revealing first if you have a multi-threaded application, because the thread stack is smaller than the application stack.
Using MIN(dir->dd_max, 2048) in the call to __getdents() has resolved the problem (recorded from the memory of the gui who fixed the error).
Mike, can you please check this out and file a patch to uclibc?
regards
Wolfgang
TranslateQuoteReplyEditDelete
2010-02-23 11:56:36 Re: FAT 32 K cluster
Mike Frysinger (UNITED STATES)
Message: 86390
i thought we fixed the getdents issues in uClibc ... i'll have to check it again, thanks
QuoteReplyEditDelete
2010-02-23 22:28:43 Re: FAT 32 K cluster
Karthikeyan Jeevanandam (INDIA)
Message: 86411
Hi Wolfgang, Mike,
Thanks for the information. Please let us know the patch details for this issue.
Regards,
Karthik
QuoteReplyEditDelete
2010-02-24 02:44:06 Re: FAT 32 K cluster
Wolfgang Muees (GERMANY)
Message: 86416
As I though a little more about it...
it may be wise to do a grep for __getdents in the whole uClibc. And it may also be wise to make a grep for alloca.
These stack-overwrites are hard to identify, especially for threaded applications.
regards
Wolfgang