bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* grep-3.5 fails to build on Solaris when libsigsegv is installed
@ 2020-09-29  2:02 Bruno Haible
  2020-09-29  2:28 ` release process analysis Bruno Haible
  2020-10-04 23:26 ` grep-3.5 fails to build on Solaris when libsigsegv is installed Paul Eggert
  0 siblings, 2 replies; 15+ messages in thread
From: Bruno Haible @ 2020-09-29  2:02 UTC (permalink / raw)
  To: bug-gnulib

Hi Paul,

On Solaris 10, when libsigsegv is installed with the same --prefix as
passed to grep's configure:
  - grep 3.4 builds fine.
  - grep 3.5 fails to build:

  CCLD     grep
ld: warning: file /PREFIX/lib/libiconv.so: attempted multiple inclusion of file
Undefined                       first referenced
 symbol                             in file
stackoverflow_install_handler       ../lib/libgreputils.a(c-stack.o)
sigsegv_install_handler             ../lib/libgreputils.a(c-stack.o)
ld: fatal: symbol referencing errors. No output written to grep
*** Error code 1

Also, a build error is seen in the gnulib-tests directory:
$ gmake check
...
  CCLD     test-c-stack
Undefined                       first referenced
 symbol                             in file
stackoverflow_install_handler       ../lib/libgreputils.a(c-stack.o)
sigsegv_install_handler             ../lib/libgreputils.a(c-stack.o)
ld: fatal: symbol referencing errors. No output written to test-c-stack
gmake[3]: *** [Makefile:3301: test-c-stack] Error 1

In both versions, config.status contains
S["LIBSIGSEGV"]="/PREFIX/lib/libsigsegv.a -lc"

The difference is that in grep-3.4
S["LIBCSTACK"]="/PREFIX/lib/libsigsegv.a -lc"
whereas in grep-3.5
S["LIBCSTACK"]=""

I can reproduce the problem with a testdir of module 'c-stack'.

This patch fixes it. BUT... see below.


2020-09-28  Bruno Haible  <bruno@clisp.org>

	c-stack: Fix link error when libsigsegv is used (regression 2020-09-20).
	* m4/c-stack.m4 (gl_PREREQ_C_STACK): Link with libsigsegv when
	libsigsegv is installed and stack overflow heuristics work.

diff --git a/m4/c-stack.m4 b/m4/c-stack.m4
index e98f80f..b86fc8f 100644
--- a/m4/c-stack.m4
+++ b/m4/c-stack.m4
@@ -7,7 +7,7 @@
 
 # Written by Paul Eggert.
 
-# serial 18
+# serial 19
 
 AC_DEFUN([AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC],
   [
@@ -360,9 +360,10 @@ AC_DEFUN([gl_PREREQ_C_STACK],
 
    AC_CHECK_TYPES([stack_t], , , [#include <signal.h>])
 
-   dnl c-stack does not need -lsigsegv if the system has XSI heuristics.
+   dnl c-stack.c uses libsigsegv when HAVE_XSI_STACK_OVERFLOW_HEURISTIC and
+   dnl HAVE_LIBSIGSEGV are both 1.
    if test "$gl_cv_lib_sigsegv" = yes \
-       && test "$gl_cv_sys_xsi_stack_overflow_heuristic" != yes; then
+       && test "$gl_cv_sys_xsi_stack_overflow_heuristic" = yes; then
      AC_SUBST([LIBCSTACK], [$LIBSIGSEGV])
      AC_SUBST([LTLIBCSTACK], [$LTLIBSIGSEGV])
    fi


BUT I don't want to push it since there seems to be also a mistake in
c-stack.c. Before the 2020-09-20 patch, the idea of c-stack.c was:
  - If HAVE_XSI_STACK_OVERFLOW_HEURISTIC is defined, use that heuristic.
  - Otherwise, if libsigsegv is present, use it to catch stack overflows.
    (It contains 3 different heuristics.)
  - Otherwise, punt.

There was a comment:

/* Only use libsigsegv if we need it; platforms like Solaris can
   detect stack overflow without the overhead of an external
   library.  */
#if HAVE_LIBSIGSEGV && ! HAVE_XSI_STACK_OVERFLOW_HEURISTIC

In the new code, there is a comment:

/* Use libsigsegv only if needed; kernels like Solaris can detect
   stack overflow without the overhead of an external library.  */
#define USE_LIBSIGSEGV (HAVE_XSI_STACK_OVERFLOW_HEURISTIC && HAVE_LIBSIGSEGV)

There seems to be a logic mistake, here.

Bruno



^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-10-12 12:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29  2:02 grep-3.5 fails to build on Solaris when libsigsegv is installed Bruno Haible
2020-09-29  2:28 ` release process analysis Bruno Haible
2020-09-29  7:00   ` Dagobert Michelsen
2020-09-29 20:56     ` Paul Eggert
2020-09-29 21:10       ` Dagobert Michelsen
2020-09-29 20:56   ` Jeffrey Walton
2020-09-29 22:32     ` Bruno Haible
2020-10-04 23:26 ` grep-3.5 fails to build on Solaris when libsigsegv is installed Paul Eggert
2020-10-04 23:40   ` AS_IF Bruno Haible
2020-10-05  1:50     ` AS_IF Paul Eggert
2020-10-06 21:56       ` AS_IF Bruno Haible
2020-10-07  0:52         ` AS_IF Zack Weinberg
2020-10-12  7:01           ` AS_IF Paul Eggert
2020-10-12 12:57             ` AS_IF Zack Weinberg
2020-10-05  8:06   ` grep-3.5 fails to build on Solaris when libsigsegv is installed Paul Eggert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).