This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/12052] New: posix_spawn() nonconformance (POSIX_SPAWN_SETSCHEDPARAM)


The POSIX.1-2001 specification of posix_spawn() says the following:

    If the  POSIX_SPAWN_SETSCHEDPARAM  flag  is  set  in  the
    spawn-flags  attribute of the object referenced by attrp,
    but POSIX_SPAWN_SETSCHEDULER is not set, the new  process
    image  shall  initially have the scheduling policy of the
    calling process with the scheduling parameters  specified
    in  the  spawn-schedparam  attribute of the object refer-
    enced by attrp.

    If the POSIX_SPAWN_SETSCHEDULER flag is set in the spawn-
    flags   attribute  of  the  object  referenced  by  attrp
    (regardless of the setting of  the  POSIX_SPAWN_SETSCHED-
    PARAM  flag),  the new process image shall initially have
    the scheduling policy specified in the  spawn-schedpolicy
    attribute  of  the  object  referenced  by  attrp and the
    scheduling parameters specified in  the  spawn-schedparam
    attribute of the same object.

However, the glibc source code (sysdeps/posix/spawni.c) is not
consistent with the above specification:

===
#ifdef _POSIX_PRIORITY_SCHEDULING
  /* Set the scheduling algorithm and parameters.  */
  if ((flags & (POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER))
      == POSIX_SPAWN_SETSCHEDPARAM)
    {
      if (__sched_setparam (0, &attrp->__sp) == -1)
	_exit (SPAWN_ERROR);
    }
  else if ((flags & POSIX_SPAWN_SETSCHEDULER) != 0)
    {
      if (__sched_setscheduler (0, attrp->__policy,
				(flags & POSIX_SPAWN_SETSCHEDPARAM) != 0
				? &attrp->__sp : NULL) == -1)
	_exit (SPAWN_ERROR);
    }
#endif
===

There are two problems here:

    * &attrp->__sp is used only if POSIX_SPAWN_SETSCHEDPARAM
      was *also* specified. However, POSIX is explicit that
      POSIX_SPAWN_SETSCHEDPARAM is ignored when
      POSIX_SPAWN_SETSCHEDULER is specified.
    * If POSIX_SPAWN_SETSCHEDPARAM is not specified, then
      the last argument of sched_setscheduler() is NULL.
      This yields an EINVAL error from sched_setscheduler()
      and a consequent _exit (SPAWN_ERROR) in the child.

The final if statement should simply be:

      if (__sched_setscheduler (0, attrp->__policy, &attrp->__sp) == -1)

-- 
           Summary: posix_spawn() nonconformance (POSIX_SPAWN_SETSCHEDPARAM)
           Product: glibc
           Version: 2.12
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper dot fsp at gmail dot com
        ReportedBy: mtk dot manpages at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=12052

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]