Bug 173988

Summary: pthread_attr_setschedparam behaviour doesn't match POSIX
Product: Red Hat Enterprise Linux 3 Reporter: Bastien Nocera <bnocera>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: drepper
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-11-23 14:39:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 170417    

Description Bastien Nocera 2005-11-23 14:11:14 UTC
When the scheduler has already been set, and the priority is above that allowed
by the scheduler, pthread_attr_setschedparam doesn't fail with EINVAL when it
should [1].

This is due to:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/nptl/pthread_attr_setschedparam.c.diff?r1=1.2&r2=1.3&cvsroot=glibc

[1]         EINVAL the  priority  specified in param is outside the range of
                    allowed priorities for the scheduling policy currently in
                    attr  (1  to  99  for  SCHED_FIFO  and  SCHED_RR;  0  for
                    SCHED_OTHER).

pthread_attr_setschedparam should error with an EINVAL when the scheduler type
has already been set, and the priority isn't in the allowed range, rather than
just during pthread_create.

Comment 2 Jakub Jelinek 2005-11-23 14:23:13 UTC
Doesn't look like a bug to me.
POSIX says:
http://www.opengroup.org/onlinepubs/009695399/functions/pthread_attr_setschedparam.html
The pthread_attr_setschedparam() function may fail if:
     [EINVAL]
             The value of param is not valid, or the value specified by attr does
not refer to an initialized thread
             attribute object.
     [ENOTSUP]
             An attempt was made to set the attribute to an unsupported value.
"MAY FAIL IF" is not "SHALL FAIL IF", therefore it is conforming if the error
isn't returned.  The only guarantee that this gives you is if such an error
is detected and error returned, then the errno value for that must be EINVAL.

Comment 3 Bastien Nocera 2005-11-23 14:34:53 UTC
Then the man-page is broken:
       The pthread_attr_setschedparam function  returns  the  following  error
       codes on error:

              EINVAL the  priority  specified in param is outside the range of
                     allowed priorities for the scheduling policy currently in
                     attr  (1  to  99  for  SCHED_FIFO  and  SCHED_RR;  0  for
                     SCHED_OTHER).

$ whereis pthread_attr_setschedparam
pthread_attr_setschedparam: /usr/share/man/man3/pthread_attr_setschedparam.3thr.gz
$ rpm -qf /usr/share/man/man3/pthread_attr_setschedparam.3thr.gz
glibc-devel-2.3.2-95.33


Comment 4 Jakub Jelinek 2005-11-23 14:39:03 UTC
That is a LinuxThreads man page, clearly marked as that.
In RHEL4 there is pthread_attr_setschedparam man page in the 3p section
as well that describes the POSIX (and thus also NPTL) behaviour.
For RHEL4 U3 we are removing all LinuxThreads man pages from glibc-devel,
but in RHEL3 the POSIX man pages aren't provided (yet), therefore the
LinuxThreads man pages shouldn't be deleted there.