| 1 |
#! /bin/sh |
| 2 |
# Test for a bug in glibc's regex code as of 2015-09-19. |
| 3 |
# |
| 4 |
# Copyright 2015-2025 Free Software Foundation, Inc. |
| 5 |
# |
| 6 |
# Copying and distribution of this file, with or without modification, |
| 7 |
# are permitted in any medium without royalty provided the copyright |
| 8 |
# notice and this notice are preserved. |
| 9 |
|
| 10 |
. "${srcdir=.}/init.sh"; path_prepend_ ../src |
| 11 |
|
| 12 |
echo aa > in || framework_failure_ |
| 13 |
|
| 14 |
fail=0 |
| 15 |
|
| 16 |
grep -E 'b|(.)b|\1|b' in >out |
| 17 |
status=$? |
| 18 |
# POSIX isn't clear whether this regular expression should be invalid, |
| 19 |
# (because the \1 is out of range for REs that could precede it) |
| 20 |
# or valid but \1 should not match. Allow either interpretation. |
| 21 |
test $status -eq 2 || test $status -eq 1 || fail=1 |
| 22 |
|
| 23 |
grep -E '0|()0|\1|0' in >out |
| 24 |
status=$? |
| 25 |
test $status -eq 2 || test $status -eq 1 || fail=1 |
| 26 |
|
| 27 |
# This test is a reduced version of the one in Bug#27838. |
| 28 |
# It triggers this glibc assertion failure: |
| 29 |
# grep: regexec.c:1342: pop_fail_stack: Assertion `num >= 0' failed. |
| 30 |
LC_ALL=C grep -E '(()x)|\2' in > out |
| 31 |
status=$? |
| 32 |
test $status -eq 2 || test $status -eq 1 || fail=1 |
| 33 |
|
| 34 |
Exit $fail |