[Bug 4177] "read" not working since 1.19.x

bugzilla at busybox.net bugzilla at busybox.net
Tue Jan 10 23:55:18 UTC 2012


https://bugs.busybox.net/show_bug.cgi?id=4177

--- Comment #7 from Denys Vlasenko <vda.linux at googlemail.com> 2012-01-10 23:55:18 UTC ---
(In reply to comment #5)
> Created attachment 3631 [details]
> config 1.19.2
> 
> With
> http://git.busybox.net/busybox/commit/shell/shell_common.c?id=10c0131a8a1b3db7fd6b23b72ebd7b33afc7b018
> reverted it's working for me.

Essentially, that patch added

+ pfd[0].fd = fd;
+ pfd[0].events = POLLIN;
+ if (poll(pfd, 1, timeout) != 1) {...}

before actual read:

+ if (read(fd, &buffer[bufpos], 1) != 1) {

which is a completely valid operation. It works for me, with both my .config
and hush; and your .config and ash (your .config has hush disabled). In strace,
I see this:

poll([{fd=0, events=POLLIN}], 1, -1)    = 1 ([{fd=0, revents=POLLIN|POLLERR}])
read(0, "I", 1)                         = 1
poll([{fd=0, events=POLLIN}], 1, -1)    = 1 ([{fd=0, revents=POLLIN}])
read(0, "N", 1)                         = 1
poll([{fd=0, events=POLLIN}], 1, -1)    = 1 ([{fd=0, revents=POLLIN}])
read(0, "T", 1)                         = 1
poll([{fd=0, events=POLLIN}], 1, -1)    = 1 ([{fd=0, revents=POLLIN}])
read(0, "E", 1)                         = 1
poll([{fd=0, events=POLLIN}], 1, -1)    = 1 ([{fd=0, revents=POLLIN}])
read(0, "L", 1)                         = 1
poll([{fd=0, events=POLLIN}], 1, -1)    = 1 ([{fd=0, revents=POLLIN}])
read(0, " ", 1)                         = 1
poll([{fd=0, events=POLLIN}], 1, -1)    = 1 ([{fd=0, revents=POLLIN}])
read(0, "S", 1)                         = 1
poll([{fd=0, events=POLLIN}], 1, -1)    = 1 ([{fd=0, revents=POLLIN}])
read(0, "S", 1)                         = 1
poll([{fd=0, events=POLLIN}], 1, -1)    = 1 ([{fd=0, revents=POLLIN}])
read(0, "D", 1)                         = 1

As you see, _for me_ poll does return. For you, for some reason it waits
forever. This seem to be a kernel bug. (In fact, my kernel appears to exhibit a
minor bug too: the POLLERR bit is bogus. Luckily, we ignore it...).

Try "strace -oLOG sh -c read </SOME/FILE". Note on what files it fails. I
hazard to guess it would work on ordinary files, but would it work (as in: not
hang until ^C) on /dev/null? On /proc/version? /proc/mounts? etc...

If it works on some of these file types but not others, let me know what is the
exact syscall it stops at (likely it will be "poll([{fd=0, events=POLLIN}], 1,
-1...") and what is the affected kernel version. Then we will probably need to
bug kernel people...

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list