public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 00/18] posix: glob fixes and refactor
@ 2017-08-11 14:50 Adhemerval Zanella
  2017-08-11 14:51 ` [PATCH 03/18] posix: Consolidate glob implementation Adhemerval Zanella
                   ` (18 more replies)
  0 siblings, 19 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2017-08-11 14:50 UTC (permalink / raw)
  To: libc-alpha

Changes from previous version [1]

  - Add fix for BZ#10246.
  - Incorporate review change for the dynamic implementation for
    C strings.
  - Reorganize patch order.

---

The set fixes some long standing glob issues (gnulib sync and dandling
symlinks), adjust its tests for libsupport, and refactor current 
implementation to use a dynarray implementation for C strings.

To correct provide a C string analogous using dynarray I had to access
its private member directly, so I created a specialized implementation
(malloc/char_array-skeleton.c).  It currently works similar to dynarray,
by including its header which defines static functions.  If it is the
case, one could its function as an internal API.  I added some
function only to manipulate mainly for the work to refactor glob.

The idea to refactor is mainly to remove the alloca and internal buffer
handling boilerplate usage.  So it does not trace its possible stack
usage using 'alloca_used' variable, which is somewhat fragile (since
it just track glob usage itself).  I used 256 bytes for default
string size (for initial stack allocation), but we can also tune it
if required.  The GCC -fstack-usage on x86_64 for shared cases
shows:

  glob.c:246:1:next_brace_sub     32      static
  dynarray-skeleton.c:203:1:globnames_array_free  48      static
  glob.c:1176:1:collated_compare  32      static
  glob.c:1196:1:prefix_array      96      static
  dynarray-skeleton.c:275:1:globnames_array_add__ 64      static
  dynarray-skeleton.c:373:1:char_array_resize.part.3      64      static
  char_array-skeleton.c:257:1:char_array_replace_str_pos  64      static
  char_array-skeleton.c:195:1:char_array_crop     48      static
  char_array-skeleton.c:231:1:char_array_append_str       64      static
  char_array-skeleton.c:117:1:char_array_set_str_size     64      static
  glob.c:271:1:get_home_directory 1200    static
  glob.c:1264:1:glob_in_dir       1104    static
  glob.c:352:1:glob       1216    static

I did not and will not take care of the non-unix code on glob.c (it
is probably broken after the glob refactor).  In fact I would like
to cleanup this implementation even further to remove all code not
really used for GLIBC if gnulib developers want to not keep the
implementation at sync.

Adhemerval Zanella (17):
  posix: Sync glob with gnulib [BZ #1062]
  posix: Adjust glob tests to libsupport
  posix: Consolidate glob implementation
  posix: Allow glob to match dangling symlinks [BZ #866]
  posix: Remove glob GET_LOGIN_NAME_MAX usage
  posix: User LOGIN_NAME_MAX for all user names in glob
  malloc: Add specialized dynarray for C strings
  posix: Use char_array for internal glob dirname
  posix: Remove alloca usage for GLOB_BRACE on glob
  posix: Remove alloca usage on glob dirname
  posix: Use dynarray for globname in glob
  posix: Remove all alloca usage in glob
  posix: Use char_array for home_dir in glob
  posix: Add common function to get home directory
  posix: More check for overflow allocation in glob
  posix: Use enum for __glob_pattern_type result
  posix: Fix glob with GLOB_NOCHECK returning modified patterns
    (BZ#10246)

Florian Weimer (1):
  posix: Rewrite to use struct scratch_buffer instead of extend_alloca

 malloc/Makefile                                    |    4 +-
 malloc/Versions                                    |    7 +
 malloc/char_array-impl.c                           |   57 +
 malloc/char_array-skeleton.c                       |  271 +++++
 malloc/char_array.h                                |   53 +
 malloc/dynarray.h                                  |    9 +
 malloc/dynarray_overflow_failure.c                 |   31 +
 malloc/malloc-internal.h                           |   14 +
 malloc/tst-char_array.c                            |  110 ++
 posix/Makefile                                     |   17 +-
 posix/bug-glob1.c                                  |   88 --
 posix/bug-glob3.c                                  |   45 -
 posix/glob.c                                       | 1194 ++++++++------------
 posix/glob_internal.h                              |   65 ++
 posix/glob_pattern_p.c                             |   29 +
 posix/globfree.c                                   |   37 +
 posix/globfree64.c                                 |   27 +
 posix/globtest.c                                   |  166 +--
 posix/globtest.sh                                  |   36 +
 posix/tst-glob_basic.c                             |   43 +
 posix/tst-glob_common.c                            |  103 ++
 posix/{bug-glob2.c => tst-glob_memory.c}           |  100 +-
 posix/tst-glob_symlinks.c                          |  133 +++
 posix/tst-gnuglob.c                                |  109 +-
 sysdeps/gnu/glob64.c                               |   25 -
 sysdeps/unix/sysv/linux/Makefile                   |    2 +-
 sysdeps/unix/sysv/linux/alpha/Makefile             |    4 -
 sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} |   11 -
 sysdeps/unix/sysv/linux/alpha/globfree.c           |   36 +
 sysdeps/unix/sysv/linux/arm/glob64.c               |    1 -
 sysdeps/unix/sysv/linux/glob.c                     |   23 +
 sysdeps/unix/sysv/linux/glob64.c                   |   55 +
 sysdeps/unix/sysv/linux/globfree.c                 |   23 +
 sysdeps/unix/sysv/linux/globfree64.c               |    0
 sysdeps/unix/sysv/linux/i386/alphasort64.c         |    2 +-
 sysdeps/unix/sysv/linux/i386/getdents64.c          |    2 +-
 sysdeps/unix/sysv/linux/i386/readdir64.c           |    2 +-
 sysdeps/unix/sysv/linux/i386/readdir64_r.c         |    2 +-
 sysdeps/unix/sysv/linux/i386/versionsort64.c       |    2 +-
 sysdeps/unix/sysv/linux/m68k/glob64.c              |    1 -
 sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c   |    1 -
 sysdeps/unix/sysv/linux/{i386 => }/olddirent.h     |    0
 .../unix/sysv/linux/{i386/glob64.c => oldglob.c}   |   51 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c |    1 -
 sysdeps/unix/sysv/linux/s390/s390-32/glob64.c      |   20 +
 sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c     |    2 +
 sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c     |    1 -
 sysdeps/unix/sysv/linux/wordsize-64/glob64.c       |    2 -
 sysdeps/unix/sysv/linux/x86_64/x32/glob.c          |    1 -
 sysdeps/wordsize-64/glob.c                         |    8 -
 sysdeps/wordsize-64/glob64.c                       |    1 -
 51 files changed, 1786 insertions(+), 1241 deletions(-)
 create mode 100644 malloc/char_array-impl.c
 create mode 100644 malloc/char_array-skeleton.c
 create mode 100644 malloc/char_array.h
 create mode 100644 malloc/dynarray_overflow_failure.c
 create mode 100644 malloc/tst-char_array.c
 delete mode 100644 posix/bug-glob1.c
 delete mode 100644 posix/bug-glob3.c
 create mode 100644 posix/glob_internal.h
 create mode 100644 posix/glob_pattern_p.c
 create mode 100644 posix/globfree.c
 create mode 100644 posix/globfree64.c
 create mode 100644 posix/tst-glob_basic.c
 create mode 100644 posix/tst-glob_common.c
 rename posix/{bug-glob2.c => tst-glob_memory.c} (76%)
 create mode 100644 posix/tst-glob_symlinks.c
 delete mode 100644 sysdeps/gnu/glob64.c
 rename sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} (78%)
 create mode 100644 sysdeps/unix/sysv/linux/alpha/globfree.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/glob64.c
 create mode 100644 sysdeps/unix/sysv/linux/glob.c
 create mode 100644 sysdeps/unix/sysv/linux/glob64.c
 create mode 100644 sysdeps/unix/sysv/linux/globfree.c
 create mode 100644 sysdeps/unix/sysv/linux/globfree64.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/glob64.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c
 rename sysdeps/unix/sysv/linux/{i386 => }/olddirent.h (100%)
 rename sysdeps/unix/sysv/linux/{i386/glob64.c => oldglob.c} (62%)
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/glob64.c
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/glob64.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86_64/x32/glob.c
 delete mode 100644 sysdeps/wordsize-64/glob.c
 delete mode 100644 sysdeps/wordsize-64/glob64.c

-- 
2.7.4

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2017-09-02 22:50 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-11 14:50 [PATCH v2 00/18] posix: glob fixes and refactor Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 03/18] posix: Consolidate glob implementation Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 16/18] posix: More check for overflow allocation in glob Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 01/18] posix: Sync glob with gnulib [BZ #1062] Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 05/18] posix: Rewrite to use struct scratch_buffer instead of extend_alloca Adhemerval Zanella
2017-09-01 23:50   ` Paul Eggert
2017-09-02 10:40   ` Paul Eggert
2017-08-11 14:51 ` [PATCH 08/18] malloc: Add specialized dynarray for C strings Adhemerval Zanella
2017-08-17 10:12   ` Florian Weimer
2017-08-17 12:39     ` Adhemerval Zanella
2017-08-17 14:48     ` Pedro Alves
2017-08-11 14:51 ` [PATCH 04/18] posix: Allow glob to match dangling symlinks [BZ #866] Adhemerval Zanella
2017-08-31 22:11   ` Paul Eggert
2017-08-11 14:51 ` [PATCH 13/18] posix: Remove all alloca usage in glob Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 12/18] posix: Use dynarray for globname " Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 11/18] posix: Remove alloca usage on glob dirname Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 18/18] posix: Fix glob with GLOB_NOCHECK returning modified patterns (BZ#10246) Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 17/18] posix: Use enum for __glob_pattern_type result Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 09/18] posix: Use char_array for internal glob dirname Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 10/18] posix: Remove alloca usage for GLOB_BRACE on glob Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 02/18] posix: Adjust glob tests to libsupport Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 06/18] posix: Remove glob GET_LOGIN_NAME_MAX usage Adhemerval Zanella
2017-09-02 22:50   ` Paul Eggert
2017-08-11 14:51 ` [PATCH 15/18] posix: Add common function to get home directory Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 07/18] posix: User LOGIN_NAME_MAX for all user names in glob Adhemerval Zanella
2017-08-11 14:51 ` [PATCH 14/18] posix: Use char_array for home_dir " Adhemerval Zanella
2017-08-17 10:19 ` [PATCH v2 00/18] posix: glob fixes and refactor Florian Weimer
2017-08-17 12:07   ` Adhemerval Zanella
2017-08-17 14:11     ` Paul Eggert
2017-08-17 17:32       ` Adhemerval Zanella
2017-08-17 18:07         ` Florian Weimer
2017-08-17 19:51         ` Paul Eggert
2017-08-17 20:05           ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).