bug-gnulib
[Top][All Lists]
Advanced

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

abort bugs


From: Eric Blake
Subject: abort bugs
Date: Fri, 6 Jun 2008 17:28:04 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

I wanted to add a SIGABRT handler to m4, to make it more obvious how to report 
internal errors back to the developers.  But in the process, I discovered that 
Cygwin abort() mistakenly closes stdio before raising SIGABRT, instead of 
after: 
http://cygwin.com/ml/cygwin/2008-06/msg00122.html

Meanwhile, mingw abort() blindly prints a message, even if you plan on handling 
the details yourself:

$ cat foo.c
#include <signal.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <setjmp.h>

jmp_buf j;

void abort_handler (int i)
{
   puts ("goodbye, cruel world");
   longjmp (j, 1);
   exit (1);
}

int main (int argc, char **argv)
{
   if (setjmp (j))
   {
      puts ("never mind");
      exit (0);
   }
   if (argc == 1)
      signal (SIGABRT, abort_handler);
   assert (0);
   abort ();
}
$ ./foo
Assertion failed: 0, file foo.c, line 25

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
goodbye, cruel world
never mind
$ echo $?
0

Should we could create an rpl_abort that works around these two issues?  
There's already been talk about providing an rpl_assert (working around 
platforms that omit __func__ information); providing rpl_abort is yet another 
reason to provide rpl_assert.  Meanwhile, I'm committing this (POSIX states 
that the various *setjmp are allowed to be only a macro; but *longjmp must be 
linkable functions):

>From d432e0c6ad23d6addc8e77ff082ae87f039e4509 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 6 Jun 2008 10:50:17 -0600
Subject: [PATCH] Document abort() bugs.

* doc/posix-functions/abort.texi (abort): Mention anomalies.
* doc/posix-functions/setjmp.texi (setjmp): Mingw has setjmp.
* doc/posix-functions/sigsetjmp.texi (sigsetjmp): Cygwin has
sigsetjmp.
* doc/posix-functions/siglongjmp.texi (siglongjmp): Cygwin has
siglongjmp, but only as a macro.
* doc/posix-functions/_longjmp.texi (_longjmp): Mention that this
is obsolete.
* doc/posix-functions/_setjmp.texi (_setjmp): Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog                           |   11 +++++++++++
 doc/posix-functions/_longjmp.texi   |    3 +++
 doc/posix-functions/_setjmp.texi    |    3 +++
 doc/posix-functions/abort.texi      |    9 +++++++++
 doc/posix-functions/setjmp.texi     |    3 ---
 doc/posix-functions/siglongjmp.texi |    6 +++++-
 doc/posix-functions/sigsetjmp.texi  |    2 +-
 7 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b73cf23..2c4297f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2008-06-06  Eric Blake  <address@hidden>
 
+       Document abort() bugs.
+       * doc/posix-functions/abort.texi (abort): Mention anomalies.
+       * doc/posix-functions/setjmp.texi (setjmp): Mingw has setjmp.
+       * doc/posix-functions/sigsetjmp.texi (sigsetjmp): Cygwin has
+       sigsetjmp.
+       * doc/posix-functions/siglongjmp.texi (siglongjmp): Cygwin has
+       siglongjmp, but only as a macro.
+       * doc/posix-functions/_longjmp.texi (_longjmp): Mention that this
+       is obsolete.
+       * doc/posix-functions/_setjmp.texi (_setjmp): Likewise.
+
        Tweak documentation to cover cygwin argz bugs.
        * m4/argz.m4 (gl_FUNC_ARGZ): Mention date of last known cygwin
        argz bug fix; no code change needed since no cygwin releases
diff --git a/doc/posix-functions/_longjmp.texi b/doc/posix-
functions/_longjmp.texi
index 8f1dcc0..7d571f8 100644
--- a/doc/posix-functions/_longjmp.texi
+++ b/doc/posix-functions/_longjmp.texi
@@ -15,4 +15,7 @@ Portability problems not fixed by Gnulib:
 @item
 This function is missing on some platforms:
 Solaris 2.5.1, mingw.
+
address@hidden
+This function is obsolete; use @code{siglongjmp} instead.
 @end itemize
diff --git a/doc/posix-functions/_setjmp.texi b/doc/posix-functions/_setjmp.texi
index ab69ca6..7c1dc32 100644
--- a/doc/posix-functions/_setjmp.texi
+++ b/doc/posix-functions/_setjmp.texi
@@ -15,4 +15,7 @@ Portability problems not fixed by Gnulib:
 @item
 This function is missing on some platforms:
 Solaris 2.5.1.
+
address@hidden
+This function is obsolete; use @code{sigsetjmp} instead.
 @end itemize
diff --git a/doc/posix-functions/abort.texi b/doc/posix-functions/abort.texi
index 249b037..90e0e3e 100644
--- a/doc/posix-functions/abort.texi
+++ b/doc/posix-functions/abort.texi
@@ -12,4 +12,13 @@ Portability problems fixed by Gnulib:
 
 Portability problems not fixed by Gnulib:
 @itemize
address@hidden
+Some platforms mistakenly close all stdio streams prior to raising
+SIGABRT:
+Cygwin.
+
address@hidden
+Some platforms always print a message to stderr, even if a SIGABRT handler
+resumes execution at a safe point:
+mingw.
 @end itemize
diff --git a/doc/posix-functions/setjmp.texi b/doc/posix-functions/setjmp.texi
index eb012ae..f6ecc00 100644
--- a/doc/posix-functions/setjmp.texi
+++ b/doc/posix-functions/setjmp.texi
@@ -13,9 +13,6 @@ Portability problems fixed by Gnulib:
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-mingw.
address@hidden
 POSIX does not specify whether @code{setjmp} saves the signal mask in the
 @code{jmp_buf}.  It does on BSD platforms, and on glibc platforms when
 @code{_BSD_SOURCE} is defined; in this case @code{setjmp} behaves like
diff --git a/doc/posix-functions/siglongjmp.texi b/doc/posix-
functions/siglongjmp.texi
index 2eb34de..6d7adf5 100644
--- a/doc/posix-functions/siglongjmp.texi
+++ b/doc/posix-functions/siglongjmp.texi
@@ -14,5 +14,9 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Cygwin, mingw.
+mingw.
+
address@hidden
+This is only provided as a macro on some platforms:
+Cygwin.
 @end itemize
diff --git a/doc/posix-functions/sigsetjmp.texi b/doc/posix-
functions/sigsetjmp.texi
index 4b1aa10..3e6fe44 100644
--- a/doc/posix-functions/sigsetjmp.texi
+++ b/doc/posix-functions/sigsetjmp.texi
@@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Cygwin, mingw.
+mingw.
 @end itemize
-- 
1.5.5.1








reply via email to

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