Subject: Re: bug#27838: grep error: "regexec.c:1375: pop_fail_stack: Assertion `num >= 0' failed."

From: Paul Eggert <[email-masked]>
Date: Wed, 26 Jul 2017 09:24:59 -0700

Thanks, that is due to an already known bug in glibc; see:

https://sourceware.org/bugzilla/show_bug.cgi?id=18986
https://debbugs.gnu.org/21513

To work around the problem with grep, use './configure --with-included-regex' 
when building grep, or encourage your upstream distributor to do so (or better 
yet, to fix glibc). You might also follow up on the glibc bug report to mention 
that the problem affects you too.

In the meantime I installed the attached patch, to add your test case to grep's 
test suite. The test is expected to fail if glibc regex is used.
From 3fb90a86a9aebe164bb4bb0e03f779ef8004d4d5 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Wed, 26 Jul 2017 09:22:57 -0700
Subject: [PATCH] tests: add Bug#27838 test case

* tests/backref-alt: New test case from a fuzzer.
---
 tests/backref-alt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/backref-alt b/tests/backref-alt
index d5bae5c..7bfaf18 100755
--- a/tests/backref-alt
+++ b/tests/backref-alt
@@ -24,4 +24,10 @@ grep -E '0|()0|\1|0' in >out
 status=$?
 test $status -eq 2 || test $status -eq 1 || fail=1
 
+# This fuzz test comes from Bug#27838.
+printf '\1772{\177)\216\216\n\216\216\t\0372{\177)(\037W3|\244\\\220)\0373|d{\244k\220)\0373|(|2{\177)(\037W3|\244\\\220)\0373|d{\244k\220)\0373|d{\220)(\013\0373|2{\177)\216\255\t\216\216\t\0373|$\\2\n' >pat
+LC_ALL=C grep -E -f pat in >out
+status=$?
+test $status -eq 2 || test $status -eq 1 || fail=1
+
 Exit $fail
-- 
2.7.4