regex: fix dfa race in multithreaded uses
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 May 2013 21:26:05 +0000 (14:26 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 May 2013 21:27:00 +0000 (14:27 -0700)
commit9ceceed274f83094127f9ff0bf061293c9fe1e7f
tree637e85b0fc75d2110a3b55c9b9beb6cbb8edcf87
parent571f20db52d2165d6cce4b2aacdedb123330d90f
regex: fix dfa race in multithreaded uses

Problem reported by Ludovic Courtès in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00058.html>.
* lib/regex_internal.h (lock_define, lock_init, lock_fini):
New macros.  All uses of __libc_lock_define, __libc_lock_init
changed to use the first two of these.
(__libc_lock_lock, __libc_lock_unlock): New macros, for
non-glibc platforms.
(struct re_dfa_t): Define the lock unconditionally.
* lib/regexec.c (regexec, re_search_stub): Remove some now-incorrect
'#ifdef _LIBC"s.
* modules/regex (Depends-on): Add pthread, if we use the
included regex.

* lib/regcomp.c: Do actions that are not needed for glibc,
but may be needed elsewhere.
(regfree, re_compile_internal): Destroy the lock.
(re_compile_internal): Check for lock-initialization failure.
ChangeLog
lib/regcomp.c
lib/regex_internal.h
lib/regexec.c
modules/regex