Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 217612 - sys-libs/uclibc-0.9.28.3-r3 readdir_r() imlementation is broken on uclibc
Summary: sys-libs/uclibc-0.9.28.3-r3 readdir_r() imlementation is broken on uclibc
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal
Assignee: Embedded Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-14 09:54 UTC by Natanael Copa
Modified: 2008-04-16 06:05 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
apr-1.2.11-readdir_r.patch (apr-1.2.11-readdir_r.patch,534 bytes, patch)
2008-04-14 11:22 UTC, Natanael Copa
Details | Diff
apr-1.2.11-readdir_r.patch (apr-1.2.11-readdir_r.patch,515 bytes, patch)
2008-04-14 13:49 UTC, Natanael Copa
Details | Diff
40_all_uClibc-0.9.28.3-readdir_r.patch (40_all_uClibc-0.9.28.3-readdir_r.patch,486 bytes, patch)
2008-04-15 12:07 UTC, Natanael Copa
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Natanael Copa 2008-04-14 09:54:47 UTC
This causes strange errors in subversion. If you for example compile subversion with ipv6 support but in runtime never load the ipv6 kernel module you get errors like:

svn: Can't read directory '.': Address family not supported by protocol

The problem here is that apr_read_dir() assumes that the return value is set upon reaching end of directory stream. This is not the case and apr does a hack to work around this in glibc but this workaround does not work for uclibc.

POSIX claims [1]:
Upon successful return, the pointer returned at *result shall have the same value as the argument entry. Upon reaching the end of the directory stream, this pointer shall have the value NULL.

The apr assumes errno==0 or errno==EINVAL which is wrong.
Comment 1 Natanael Copa 2008-04-14 11:22:15 UTC
Created attachment 149672 [details, diff]
apr-1.2.11-readdir_r.patch

this patch does the right thing and saves the day.
Comment 2 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2008-04-14 12:25:22 UTC
This code is slightly different in APR trunk.
Could you check if it was fixed there?

The ebuild for APR trunk is available in Eaedificāta Repository:
http://www.ffta.host.sk/Eaedificata/index.html
Comment 3 Natanael Copa 2008-04-14 13:47:29 UTC
(In reply to comment #2)
> This code is slightly different in APR trunk.
> Could you check if it was fixed there?
> 
> The ebuild for APR trunk is available in Eaedificāta Repository:
> http://www.ffta.host.sk/Eaedificata/index.html
> 

yeah, the way trunk handle it should also work.
https://svn.apache.org/repos/asf/apr/apr/trunk/file_io/unix/dir.c.



Comment 4 Natanael Copa 2008-04-14 13:49:11 UTC
Created attachment 149683 [details, diff]
apr-1.2.11-readdir_r.patch

updated patch. does the same as upstream trunk.
Comment 5 Natanael Copa 2008-04-14 13:56:52 UTC
argh!!! no the code in trunk does not work for uclibc.

 # svn up
svn: Can't read directory '.': Address family not supported by protocol
Comment 6 Natanael Copa 2008-04-14 15:03:58 UTC
Comment on attachment 149672 [details, diff]
apr-1.2.11-readdir_r.patch

this is probably the safest way to deal with this. probably also solves the solaris stuff
Comment 7 Natanael Copa 2008-04-14 15:04:21 UTC
Comment on attachment 149683 [details, diff]
apr-1.2.11-readdir_r.patch

this didnt work. first one does.
Comment 8 Natanael Copa 2008-04-14 15:09:41 UTC
i would say that the posix specification is a bit unclear on the return status. What is safe is: *result shall have the same value as the argument 'entry' on success. Upon end of directory stream, the '*result' is NULL.

That is how first patch works.
Comment 9 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2008-04-14 16:26:31 UTC
If the code from trunk doesn't work, then please report an upstream bug at:
https://issues.apache.org/bugzilla/
Comment 10 Natanael Copa 2008-04-15 11:56:13 UTC
The posix is a bit unclear but it seems like uclibc tries to behave like gnu libc and they have fixed in in uclibc trunk.

So this actually ends up to be a bug in the uclibc implementation.

Comment 11 Natanael Copa 2008-04-15 12:07:06 UTC
Created attachment 149790 [details, diff]
40_all_uClibc-0.9.28.3-readdir_r.patch

patch for uclibc
Comment 12 Natanael Copa 2008-04-15 12:33:45 UTC
please reasign to embedded
Comment 13 Christian Heim (RETIRED) gentoo-dev 2008-04-16 06:05:46 UTC
OK, uClibc-0.9.28.3-r4 contains pulls in Natanael's patch from uClibc trunk, which  should be fixing this issue.