[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test-memchr crash
From: |
Eric Blake |
Subject: |
Re: test-memchr crash |
Date: |
Tue, 16 Jun 2009 06:16:19 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Simon Josefsson on 6/16/2009 1:30 AM:
> checking whether strstr works in linear time... no
> ...
> PASS: test-strstr
>
> I checked, and the gnulib strstr replacement is used.
Oh. That's because your strstr is already non-linear (your glibc 2.7 is
older than when they picked up my strstr implementation, around Feb 2008
and glibc 2.9). So there's only a narrow window of time where glibc has
the new strstr that uses memchr with an overestimated length, but also has
a broken memchr, and we have not yet run into a host in the wild in that
category other than the Debian bug report.
All that said, I think I will still commit this patch, unless anyone objects:
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAko3jRIACgkQ84KuGfSFAYAnwQCgjG3uuYEhqaLbQ+nJjvOj9I9x
DaEAn3ClFYg5cKAQ2GnLCYwacs4hMc8j
=wcuk
-----END PGP SIGNATURE-----
>From a099937a4efb3208abd6db29d63706439ed42c4f Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 16 Jun 2009 06:14:05 -0600
Subject: [PATCH] strstr: replace on platforms with broken memchr
* m4/strstr.m4 (gl_FUNC_STRSTR): Also replace strstr if the
platform version is linear but memchr is broken, per Debian bug
521737.
* doc/posix-functions/strstr.texi (strstr): Document the fix.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 8 ++++++++
doc/posix-functions/strstr.texi | 7 ++++++-
m4/strstr.m4 | 9 ++++++---
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1a06849..38e62f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-06-16 Eric Blake <address@hidden>
+
+ strstr: replace on platforms with broken memchr
+ * m4/strstr.m4 (gl_FUNC_STRSTR): Also replace strstr if the
+ platform version is linear but memchr is broken, per Debian bug
+ 521737.
+ * doc/posix-functions/strstr.texi (strstr): Document the fix.
+
2009-06-15 Eric Blake <address@hidden>
hash: avoid memory leak on allocation failure
diff --git a/doc/posix-functions/strstr.texi b/doc/posix-functions/strstr.texi
index ffd2ad7..2e58050 100644
--- a/doc/posix-functions/strstr.texi
+++ b/doc/posix-functions/strstr.texi
@@ -11,7 +11,12 @@ Portability problems fixed by Gnulib:
@item
This function has quadratic instead of linear worst-case complexity on some
platforms:
-glibc 2.8, MacOS X 10.3, FreeBSD 6.2, NetBSD 3.0, OpenBSD 4.0, AIX 5.1, HP-UX
11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw.
+glibc 2.8, MacOS X 10.3, FreeBSD 6.2, NetBSD 3.0, OpenBSD 4.0, AIX
+5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw.
+
address@hidden
+This function can trigger memchr bugs on some platforms:
+glibc 2.10.
@end itemize
Portability problems not fixed by Gnulib:
diff --git a/m4/strstr.m4 b/m4/strstr.m4
index f48bebb..9f4819d 100644
--- a/m4/strstr.m4
+++ b/m4/strstr.m4
@@ -1,5 +1,5 @@
-# strstr.m4 serial 5
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+# strstr.m4 serial 6
+dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -8,6 +8,7 @@ dnl Check that strstr is efficient.
AC_DEFUN([gl_FUNC_STRSTR],
[
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_REQUIRE([gl_FUNC_MEMCHR])
AC_CACHE_CHECK([whether strstr works in linear time],
[gl_cv_func_strstr_linear],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
@@ -57,7 +58,9 @@ AC_DEFUN([gl_FUNC_STRSTR],
[gl_cv_func_strstr_linear="guessing no"])
])
])
- if test "$gl_cv_func_strstr_linear" != yes; then
+ # If strstr is quadratic, or if memchr is broken (as in glibc 2.10 on
+ # some 64-bit architectures), then we need the replacement.
+ if test "$gl_cv_func_strstr_linear$gl_cv_func_memchr_works" != yesyes; then
REPLACE_STRSTR=1
AC_LIBOBJ([strstr])
fi
--
1.6.3.rc3.2.g4b51
- test-memchr crash, Simon Josefsson, 2009/06/12
- Re: test-memchr crash, Bruno Haible, 2009/06/12
- Re: test-memchr crash, Eric Blake, 2009/06/12
- Re: test-memchr crash, Simon Josefsson, 2009/06/13
- Re: test-memchr crash, Eric Blake, 2009/06/16
- Re: test-memchr crash, Simon Josefsson, 2009/06/16
- Re: test-memchr crash,
Eric Blake <=
- strstr (was: test-memchr crash), Eric Blake, 2009/06/16
- Re: strstr (was: test-memchr crash), Bruno Haible, 2009/06/17
- Re: strstr, Eric Blake, 2009/06/17
- Re: strstr, Eric Blake, 2009/06/17
- Re: strstr, Bruno Haible, 2009/06/18
- Re: strstr, Bruno Haible, 2009/06/18
- Re: strstr, Eric Blake, 2009/06/18
- Re: test-memchr crash, Simon Josefsson, 2009/06/16