Bug 253

Summary: poll() syscall emulation not compiled when needed
Product: uClibc Reporter: Michael Deutschmann <michael>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: minor CC: uclibc-cvs
Priority: P5    
Version: 0.9.30.1   
Target Milestone: 0.9.30.3   
Hardware: PC   
OS: Linux   
Host: i386-pc-linux-uclibc Target: i386-pc-linux-uclibc
Build: i386-pc-linux-uclibc
Attachments: Patch to fix poll() on Linux 2.0
Revised patch to prevent poll syscall use on Linux 2.0

Description Michael Deutschmann 2009-03-31 05:05:18 UTC
Created attachment 217 [details]
Patch to fix poll() on Linux 2.0

uClibc includes an emulation of the poll() syscall, but avoids compiling it if it thinks the kernel has a native poll().  It presently tests this by seeing if __NR_poll is defined.

Unfortunately, Linux 2.0.*, the one version that needs this emulation, has for some time defined __NR_poll without actually implementing it, causing an unpatched uClibc to provide a poll() that always returns ENOSYS.

I'm including a simple patch to fix this problem.  (The patch creates one new header, "uClibc_khpresence.h", which is shared with my solution to another problem, and thus contains one definition unneeded for this specific bug.)
Comment 1 Mike Frysinger 2009-07-20 11:44:15 UTC
look at how glibc implements __ASSUME_POLL_SYSCALL ... we should use the same define and implementation, and use the existing common/bits/kernel-features.h rather than adding a new uClibc_khpresence.h.
Comment 2 Michael Deutschmann 2009-07-22 06:16:09 UTC
(In reply to comment #1)
> look at how glibc implements __ASSUME_POLL_SYSCALL ... we should use the same
> define and implementation, and use the existing common/bits/kernel-features.h
> rather than adding a new uClibc_khpresence.h.
There is no common/bits/kernel-features.h in my copy of uClibc.  

There is a kernel-features.h buried in linuxthreads, but linuxthreads is expected to go away eventually.
Comment 3 Mike Frysinger 2009-07-22 06:28:48 UTC
then you're using a very old copy of uClibc and you need to update to the latest
Comment 4 Michael Deutschmann 2009-07-22 06:37:44 UTC
(In reply to comment #3)
> then you're using a very old copy of uClibc and you need to update to the
> latest

I'm using 0.9.30.1, which is still the latest according to the front page.  And according to "find -name kernel-features.h", the only such file exists under libpthread. 

Comment 5 Mike Frysinger 2009-07-22 06:59:46 UTC
changes arent committed to the release.  if you want *new* code to be committed, you really have to be using the latest live source tree.
Comment 6 Michael Deutschmann 2009-10-08 22:53:08 UTC
Created attachment 689 [details]
Revised patch to prevent poll syscall use on Linux 2.0

Modified version of my previous Linux 2.0 poll fix, which now depends on a symbol __ASSUME_POLL_SYSCALL from <bits/kernel-features.h>, instead of __HAVE_ASM_POLL_H.
Comment 7 Michael Deutschmann 2009-10-08 22:56:15 UTC
I'm still using the release tree, but I've modified my patches to add a <bits/kernel-features.h> containing the symbol glibc uses, and use that file.

I'm attaching the part of the patch that works on poll.h.  

The patch that adds kernel-features.h would not apply on top of an existing kernel-features.h, so it's not included.  The symbol is __ASSUME_POLL_SYSCALL, and I set it to apply on 2.2.0 or higher.  (Glibc turns it on at a precise 2.1 release I don't recall off hand.)
Comment 8 Bernhard Reutner-Fischer 2009-10-08 23:01:51 UTC
Michael, please provide a git diff against current master. TIA
Comment 9 Bernhard Reutner-Fischer 2010-03-04 14:46:39 UTC
fixed on master and on 0_9_30. Thanks for the report.