[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new module 'sigsegv'

From: Bruno Haible
Subject: new module 'sigsegv'
Date: Sun, 16 May 2021 19:01:45 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-206-generic; KDE/5.18.0; x86_64; ; )

For a long time, I've been dissatisfied with the 'c-stack' module:

  * It supports only Solaris, and even the Solaris support costs maintenance
    effort (seen this week: Paul needed to borrow a trick from GNU libsigsegv,
    in order to support Solaris 11/SPARC).

  * For the few platforms that it supports, it needs a significant amount of
    complexity in m4/c-stack.m4 and lib/c-stack.c.

  * Without additional library, it supports proprietary platforms better than
    glibc systems. This is something that we should not do, RMS emphasized
    on gnu-prog-discuss on 2021-01-03 (message "Features that are not supported
    on GNU wrap-up").

So, GNU libsigsegv should be the natural replacement. But I'm dissatisfied
with GNU libsigsegv as well:

  * It is an extra library. Although it produce less than 10 KB of compiled
    code, the maintainer of a package needs to pay the price of an
    external library (in terms of build system cost).

  * It is an extra library, although it is merely a "normal" application of the
    sigaltstack() system call.

  * It has way too many configure tests. This introduces bugs: E.g. When I
    did the port to OpenIndiana, OpenIndiana was not treated like Solaris 11
    due to a mistake in the autoconf test, and the result was a suboptimal
    port. A compilation error would have been better. In other words,
    sometimes writing explicit #ifdefs for platforms is better, because it
    clarifies the expectations.

  * Part of its API (the dispatcher) is not multithread-safe [so far].

RMS's guidance is to make things easy for applications on glibc systems.
GNU libsigsegv exists as a separate library mostly because of Windows platforms
and older platforms.

To fix this problem, I'm adding a module 'sigsegv'.

It's a simplified variant of GNU libsigsegv, as a Gnulib module.

It implements the most important features of GNU libsigsegv: catching SIGSEGV
and catching stack overflow. It does *not* implement the 'sigsegv_dispatcher'
type (which is not multithread-safe, see above).

It supports all modern Unix-like platforms: Linux, Hurd, FreeBSD, NetBSD,
OpenBSD, macOS, AIX, Solaris, Cygwin, Haiku, even IRIX. It does *not* support
HP-UX, Minix, native Windows; on these platforms the module compiles and
provides a <sigsegv.h> header file, but it does not define HAVE_SIGSEGV_RECOVERY

Unlike GNU libsigsegv, which consists of many .h and .c files, this module
compiles to just two object files, rather than a library. I bet that two
.c files, with total size of 100 KB, is more acceptable to the Gnulib users
than a wealth of 70 include files.

It's kind of a "mini-libsigsegv". (I considered calling the module
'mini-libsigsegv', but the .h file is called <sigsegv.h>, and I think the
module name should better be consistent with that.)

The module is analogous to the many "mini-libunistring" modules (uni*/*) and
the "mini-gmp" that was added a year ago.

The copyright is currently still mine with a few contributors (notably
Eric Blake and Paolo Bonzini). We have other files not copyrighted by the
FSF in Gnulib: atanl.c, filevercmp.c, logl.c. If you think the stuff should
better be (C) FSF, I have no problem assigning my copyrights on that, as
I do with all other Gnulib contributions.

The module accepts an option '--with-libsigsegv', so as to force the use
of an installed GNU libsigsegv. This is needed e.g. on old Mac OS X 10.5
in 64-bit mode (because the new module uses sigaltstack(), whereas GNU
libsigsegv still uses the Mach API.)


2021-05-16  Bruno Haible  <bruno@clisp.org>

        sigsegv: Add tests.
        * tests/test-sigsegv-catch-segv1.c: New file, from GNU libsigsegv with
        * tests/test-sigsegv-catch-segv2.c: Likewise.
        * tests/test-sigsegv-catch-stackoverflow1.c: Likewise.
        * tests/test-sigsegv-catch-stackoverflow2.c: Likewise.
        * tests/altstack-util.h: Likewise.
        * tests/mmap-anon-util.h: Likewise.
        * modules/sigsegv-tests: New file.

        sigsegv: New module.
        * lib/sigsegv.in.h: New file, from GNU libsigsegv with modifications.
        * lib/sigsegv.c: Likewise.
        * lib/stackvma.h: Likewise.
        * lib/stackvma.c: Likewise.
        * m4/sigaltstack.m4: Likewise.
        * m4/stack-direction.m4: Likewise.
        * modules/sigsegv: New file.

Attachment: 0001-sigsegv-New-module.patch
Description: Text Data

Attachment: 0002-sigsegv-Add-tests.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]