On 1/20/20 2:49 AM, Martin Liška wrote:

In this case an infinite loop is highly undesirable.

Sure, but the regex code is littered with highly undesirable code like this, as it's easy to use a weird regexp to make the code explode exponentially and there's little practical difference between that an infinite loop.

Come to think of it, the grep test infrastructure already has a way to deal with this sort of thing, so all we need to do to fix this particular glitch is adjust triple-backref to use timeout, which I did by installing the attached patch.

Thanks Andreas for diagnosing the problem. I hope there's a gcc bug report about it somewhere. I could not use Martin's recipe on Fedora 31 x86-64 because gcc -m32 -flto didn't look inside the .a files that the grep build procedure creates and uses. I've never had much luck with -flto anyway as it has a habit of running into compiler bugs. I now also see that Red Hat has qualms about the GOLD linker <https://fedoraproject.org/wiki/Changes/BINUTILS_GOLD> which the recipe relies on, as Google has decided not to continue GOLD development (which was news to me).

I'll mark Bug#21513 as done again, since the original report is fixed. The triple-backref bug is Bug#22793 and also glibc bug 11053, both of which are still open.
>From 759745166c0503680bb8fa1f4f60209292740492 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Mon, 20 Jan 2020 09:32:49 -0800
Subject: [PATCH] tests: work around GCC -fprofile-generate bug
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* tests/triple-backref: Add a 10 s timeout to work around
what appears to be a GCC bug with -fprofile-generate.
Problem reported by Martin Liška, with diagnosis by
Andreas Schwab (Bug#21513).
---
 tests/triple-backref | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
 mode change 100755 => 100644 tests/triple-backref

diff --git a/tests/triple-backref b/tests/triple-backref
old mode 100755
new mode 100644
index 27ab9a3..167b8ac
--- a/tests/triple-backref
+++ b/tests/triple-backref
@@ -8,11 +8,12 @@
 # notice and this notice are preserved.
 
 . "${srcdir=.}/init.sh"; path_prepend_ ../src
+require_timeout_
 
 echo a > in || framework_failure_
 
 fail=0
-grep -E '(.?)(.?)(.?)\3\2\1' in > out || fail=1
+timeout 10 grep -E '(.?)(.?)(.?)\3\2\1' in > out || fail=1
 compare out in || fail=1
 
 Exit $fail
-- 
2.17.1

Reply via email to