Email List: Xaustin-group-futures-lX
[All Lists]

Bugs in Work Item 1.2.3

To: yyyyyyyyyyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: Bugs in Work Item 1.2.3
From: Andrew Josey <yyyyyy@xxxxxxxxxxxxxxxxx>
Date: Tue, 16 Nov 2004 06:56:41 GMT
For your information, these are the bugs filed to
date for  Base WG work item 1.2.3. Thanks to Paul.
regards
Andrew
-----------------------------------------------------

        Bug report from : Paul Eggert , UCLA


@ page 7 line 140 section scandir comment {20041111a}

Problem:

Lines 140-142 currently say:

  The scandir() function shall return -1 if the directory cannot be
  opened for reading or if malloc() cannot allocate enough memory
  to hold all the data structures.

There are some problems with this wording.  First, it lists only two
reasons for failing, but there are several other reasons documented
under ERRORS.  Second, the reasons listed here unnecessarily duplicate
two of the reasons documented under ERRORS.  Third, it is nowhere stated
what happens to *namelist upon failure.


Action:

Replace lines 140-142 with:

  Otherwise the scandir() function shall return -1 without modifying
  *namelist.




@ page 7 line 129 section scandir, alphasort objection {20041111b}

Problem:

As specified, scandir has undefined behavior if the directory contains
names that cannot be compared by alphasort (which is strcoll in
disguise) without error.  This is a real hole, since strcoll can fail,
and sometimes does fail in practice.  It means that reliable programs
cannot use scandir unless they know in advance that the directory
names are all acceptable arguments to strcoll.


Action:

If the intent is for scandir to have undefined behavior when directory
names cannot be compared, the standard should warn application writers
about the problem.  Here's one way to do it:

  page 8 line 163.  ERRORS.  Append:

    The alphasort() function may fail if:

      [EINVAL] The d1 or d2 arguments have names that contain
        characters outside the domain of the collating sequence.

  page 8 line 183.  APPLICATION USAGE.  Append:

     Since compar() is passed to qsort(), it must satisfy all the
     constraints of qsort().  In particular, the behavior is undefined
     unless compar() defines a total ordering on the array; and if two
     directory entries compare equal, their order in the sorted array
     is unspecified.  Since alphasort() is based on strcoll() and
     strcoll() is not a total ordering when it fails, the behavior is
     undefined if scandir() is invoked on a directory containing a
     filename that is not an acceptable argument to strcoll().

However, as an application writer I would prefer a scandir() function
that I can use on any directory, so I'd prefer the following change
instead of the above change.  Please note, though, that this does not
describe existing behavior on hosts where strcoll() can fail.

   page 7 line 129.  alphasort() DESCRIPTION.
   Append the following text, taken from getpid():

     When given directory entries by scandir(), the alphasort()
     function shall be a total ordering that is consistent with
     strcoll(); it shall always be successful and no return value is
     reserved to indicate an error.

   page 8 line 183.  APPLICATION USAGE.  Append:

     Since compar() is passed to qsort(), it must satisfy all the
     constraints of qsort().  In particular, the behavior is undefined
     unless compar() defines a total ordering on the array; and if two
     directory entries compare equal, their order in the sorted array
     is unspecified.  alphasort() can be a simple wrapper around
     strcoll() only on hosts where filenames and locales are
     constrained so that strcoll() cannot fail on directory entry
     names.


@ page 7 line 133 section scandir with compar==NULL objection {20041111c}

Problem:

GNU scandir() bypasses the call to qsort() and yields an unsorted
array of names if compar is a null pointer.  This is useful behavior,
since many applications do not need the names to be sorted.  It is
particularly useful for directories whose names contain invalid
characters that would otherwise cause scandir() to have undefined
behavior.  Since the behavior is useful and is common practice, it
should be documented.

Action:

page 7 line 133.  Append "If compar() is a null pointer, qsort() is
  not called and the resulting order of entries is unspecified."



@ page 17 line 437 section mbsnrtowcs comment {20041111d}

Problem:

I'm not convinced of the need for this function in the standard.
The GNU C Library uses it internally in one place.  Nobody else
uses it, as far as I know.

Action:

The simplest action is to remove mbsnrtowcs.

Another possibility is to modify the mbsnrtowcs RATIONALE
to explain the motivation for the function, and modify the
APPLICATION USAGE to give a useful example.


-----
Andrew Josey                                The Open Group  
Austin Group Chair                          Thames Tower, 37-45 Station Road,
Email: yyyyyyy@xxxxxxxxxxxxx                Reading,Berks.RG1 1LX,England
Tel:   +44 118 9508311 ext 2250             Fax: +44 118 9500110

<Prev in Thread] Current Thread [Next in Thread>
  • Bugs in Work Item 1.2.3, Andrew Josey <=