Thanks for reporting that. It's a bug in the glibc regular expression matcher,
and as such will need a glibc fix. I plan to propose a patch there. In the
meantime I fixed the Gnulib replacement for the matcher, here:
http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=5513b40999149090987a0341c018d05d3eea1272
and have installed the attached patches to GNU grep, so that the bug should be
fixed if you configure grep using the --with-included-regex option.
From e289b4fce62bf805c999be8a0c7a5e976cd1c9e3 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 19 Sep 2015 13:59:41 -0700
Subject: [PATCH 1/2] build: update gnulib submodule to latest
---
gnulib | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gnulib b/gnulib
index 5a5a938..5513b40 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 5a5a9388e93d00a7bcb97700a7a552bef20343fd
+Subproject commit 5513b40999149090987a0341c018d05d3eea1272
--
2.1.0
From 2f06b72a909c36b3ea0f9014aa13e4faf874c329 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 19 Sep 2015 14:17:55 -0700
Subject: [PATCH 2/2] Add test for pop_fail_stack bug
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problem reported by Hanno Böck in: http://bugs.gnu.org/21513
If you use --with-included-regex the bug fix is in gnulib, here:
http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=5513b40999149090987a0341c018d05d3eea1272
If you use glibc, the bug fix has not been installed yet.
* tests/Makefile.am (XFAIL_TESTS): Add backref-alt if system matcher.
(TESTS): Add backref-alt.
* tests/backref-alt: New file.
* tests/triple-backref: Remove unused var.
Don't skip if tested with glibc, as Makefile.am now handles this.
---
tests/Makefile.am | 11 +++++++++++
tests/backref-alt | 27 +++++++++++++++++++++++++++
tests/triple-backref | 17 -----------------
3 files changed, 38 insertions(+), 17 deletions(-)
create mode 100755 tests/backref-alt
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c95d5a9..d379821 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,16 +24,27 @@ AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
LDADD = ../lib/libgreputils.a $(LIBINTL) ../lib/libgreputils.a
dfa_match_aux_LDADD = ../src/dfa.$(OBJEXT) $(LDADD)
+# The triple-backref test is expected to fail with both the system
+# matcher (i.e., with glibc) and with the included matcher.
+# Both matchers need to be fixed.
+# FIXME-2015: Remove this once the glibc and gnulib bugs are fixed.
XFAIL_TESTS = triple-backref
# Equivalence classes are only supported when using the system
# matcher (which means only with glibc).
+# The included matcher needs to be fixed.
+# FIXME-2015: Remove this once the gnulib bug is fixed.
if USE_INCLUDED_REGEX
XFAIL_TESTS += equiv-classes
+else
+# The backslash-alt test fails for glibc, which needs to be fixed.
+# FIXME-2015: Remove this once the glibc bug is fixed.
+XFAIL_TESTS += backref-alt
endif
TESTS = \
backref \
+ backref-alt \
backref-multibyte-slow \
backref-word \
backslash-s-and-repetition-operators \
diff --git a/tests/backref-alt b/tests/backref-alt
new file mode 100755
index 0000000..d6a8f2e
--- /dev/null
+++ b/tests/backref-alt
@@ -0,0 +1,27 @@
+#! /bin/sh
+# Test for a bug in glibc's regex code as of 2015-09-19.
+#
+# Copyright 2015 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+echo aa > in || framework_failure_
+
+fail=0
+
+grep -E 'b|(.)b|\1|b' in >out
+status=$?
+# POSIX isn’t clear whether this regular expression should be invalid,
+# (because the \1 is out of range for REs that could precede it)
+# or valid but \1 should not match. Allow either interpretation.
+test $status -eq 2 || test $status -eq 1 || fail=1
+
+grep -E '0|()0|\1|0' in >out
+status=$?
+test $status -eq 2 || test $status -eq 1 || fail=1
+
+Exit $fail
diff --git a/tests/triple-backref b/tests/triple-backref
index d3cf5c3..035c576 100755
--- a/tests/triple-backref
+++ b/tests/triple-backref
@@ -9,23 +9,6 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../src
-failures=0
-
-# FIXME-2014: once the glibc bug is fixed, remove this skip-if-glibc guard.
-# Since this tests for an as-yet-unfixed bug in glibc,
-# we expect it to fail on such systems.
-# Since we expect this test to fail, we must skip this test on
-# non-glibc systems.
-cat <<\EOF > glibc.c
-#include <features.h>
-#if defined __GNU_LIBRARY__ && __GLIBC__ >= 2
-#else
-"run this test only with glibc"
-#endif
-EOF
-$CC -c glibc.c \
- || skip_ 'this test runs only on systems with glibc'
-
echo a > in || framework_failure_
fail=0
--
2.1.0