Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |  

This web mail archive is frozen.

This page is part of a frozen web archive of this mailing list.

You can still navigate around this archive, but know that no new mails have been added to it since July of 2016.

Click here to be taken to the new web archives of this list; it includes all the mails that are in this frozen archive plus all new mails that have been sent to the list since it was migrated to the new archives.

From: Brooks Davis (brooks_at_[hidden])
Date: 2005-10-12 15:20:57

On Wed, Oct 12, 2005 at 11:07:51AM -0700, Brooks Davis wrote:
> On Wed, Oct 12, 2005 at 08:58:30AM -0400, Jeff Squyres wrote:
> > On Oct 12, 2005, at 12:54 AM, Brooks Davis wrote:
> >
> > >> Can you elaborate on why you needed that? If there's a problem with
> > >> the stacktrace stuff on BSD, I'd like to make it either disable by
> > >> default or fix whatever is required to work properly on BSD.
> > >
> > > There were a bunch of undefined symbols that I didn't track down.
> > > Hopefully there's just a missing header file. I need to dig into it
> > > more. I just disabled it because I was hoping that would be the only
> > > issue. It wasn't but, I had stop working before I could try again
> > > with stack traces enabled.
> >
> > Ok. Right now, that section is only protected with #ifdef __GLIBC__,
> > so let us know what you find. The sooner, the better. :-)
> After some investigation I've discovered there are two parts to this.
> First, the failure to compile is due to FreeBSD not defining a large
> portion of the si_code values in the decoding table. Overall the state
> of documentation of the FreeBSD si_code values is rather crappy so I've
> added #ifdef's around the ones that fail, but not attempted to add more
> values except SI_UNDEFINED. I've attached this bit (with this the
> system compiles with ./configure).
> Second, is actually supporting backtraces. It turns out there's a
> library to provide the glibc backtrace* API on BSD systems. I don't
> know which ones it works on or how good it is, but it's probably worth a
> short. The big change will be switching from __GLIBC__ to probing for
> libexecinfo, and the necessicary symbols. I'm taking a look at this
> now.

No testing yet, but I've modified and
opal/util/stacktrace.c to work by probing for backtrace() and
libexecinfo. The configure code is cribbed from the sched_yeild and -lrt
code for Solaris. The diff below includes that, some changes to
detect libutil.h and it include as needed and the added ifdef from my
last message in stacktrace.c.

Now to see if it runs. :)

-- Brooks

Index: opal/util/stacktrace.c
--- opal/util/stacktrace.c (revision 7735)
+++ opal/util/stacktrace.c (working copy)
@@ -46,6 +46,8 @@
  * to a user-specified signal (e.g. SIGFPE or SIGSEGV).
  * For Linux/Glibc, it then uses backtrace and backtrace_symbols
  * to figure the current stack and then prints that out to stdout.
+ * Where available, the BSD libexecinfo is used to provide Linux/Glibc
+ * compatable backtrace and backtrace_symbols functions.
  * Yes, printf and malloc are not signal-safe per se, but should be
  * on Linux?
@@ -58,7 +60,7 @@
 static void opal_show_stackframe (int signo, siginfo_t * info, void * p)
-#ifdef __GLIBC__
     int i;
     int trace_size;
     void * trace[32];
@@ -87,15 +89,21 @@
       case SIGILL:
         switch (info->si_code)
+#ifdef ILL_ILLOPC
             case ILL_ILLOPC: str = "ILL_ILLOPC"; break;
 #ifdef ILL_ILLOPN
             case ILL_ILLOPN: str = "ILL_ILLOPN"; break;
 #ifdef ILL_ILLADR
             case ILL_ILLADR: str = "ILL_ILLADR"; break;
+#ifdef ILL_ILLTRP
             case ILL_ILLTRP: str = "ILL_ILLTRP"; break;
+#ifdef ILL_PRVOPC
             case ILL_PRVOPC: str = "ILL_PRVOPC"; break;
 #ifdef ILL_PRVREG
             case ILL_PRVREG: str = "ILL_PRVREG"; break;
@@ -129,14 +137,20 @@
       case SIGSEGV:
         switch (info->si_code)
             case SEGV_MAPERR: str = "SEGV_MAPERR"; break;
             case SEGV_ACCERR: str = "SEGV_ACCERR"; break;
       case SIGBUS:
         switch (info->si_code)
+#ifdef BUS_ADRALN
             case BUS_ADRALN: str = "BUS_ADRALN"; break;
             case BUS_ADRERR: str = "BUS_ADRERR"; break;
@@ -159,12 +173,24 @@
       case SIGCHLD:
         switch (info->si_code)
+#ifdef CLD_EXITED
             case CLD_EXITED: str = "CLD_EXITED"; break;
+#ifdef CLD_KILLED
             case CLD_KILLED: str = "CLD_KILLED"; break;
+#ifdef CLD_DUMPED
             case CLD_DUMPED: str = "CLD_DUMPED"; break;
             case CLD_TRAPPED: str = "CLD_TRAPPED"; break;
             case CLD_STOPPED: str = "CLD_STOPPED"; break;
             case CLD_CONTINUED: str = "CLD_CONTINUED"; break;
 #ifdef SIGPOLL
@@ -197,6 +223,9 @@
 #ifdef SI_KERNEL
             case SI_KERNEL: str = "SI_KERNEL"; break;
+ case SI_UNDEFINED: str = "SI_UNDEFINED"; break;
@@ -245,7 +274,7 @@
     write(1, print_buffer, size);
-#ifdef __GLIBC__
     trace_size = backtrace (trace, 32);
     messages = backtrace_symbols (trace, trace_size);
--- (revision 7735)
+++ (working copy)
@@ -1043,7 +1043,7 @@
 ompi_show_title "Header file tests"
 AC_CHECK_HEADERS([alloca.h aio.h arpa/inet.h dirent.h \
- dlfcn.h execinfo.h err.h fcntl.h inttypes.h libgen.h \
+ dlfcn.h execinfo.h err.h fcntl.h inttypes.h libgen.h libutil.h \
     net/if.h netdb.h netinet/in.h netinet/tcp.h \
     poll.h pthread.h pty.h pwd.h sched.h stdint.h \
     string.h strings.h stropts.h sys/fcntl.h sys/ipc.h \
@@ -1202,6 +1202,35 @@
+# FreeBSD has backtrace in -lexecinfo. Can't use a simple AC_CHECK_LIB,
+# though, because Linux has backtrace in glic (so linking in libexecinfo
+# will "find" backtrace, even though it would have been found anyway
+# -- so -lexecinfo would be useless [and potentially harmful?] in this
+# case).
+AC_MSG_CHECKING([if we need -lexecinfo for backtrace])
+AC_LINK_IFELSE(AC_LANG_PROGRAM([[extern char *backtrace;]],
+[[char *bar = backtrace;]]),
+if test "$MSG" = "not_found"; then
+ LIBS_save="$LIBS"
+ LIBS="$LIBS -lexecinfo"
+ AC_LINK_IFELSE(AC_LANG_PROGRAM([[extern char *backtrace;]],
+[[char *bar = backtrace;]]),
+ if test "$MSG" = "not_found"; then
+ LIBS="$LIBS_save"
+ fi
+# see if we actually have backtrace. Use AC_CHECK_FUNCS so that it
+# does the glibs "not implemented" check. Will use the current LIBS,
+# so will check in -lexecinfo if we decided we needed it above
 # See if we need the math library explicitly linked in
Index: orte/mca/iof/base/iof_base_setup.c
--- orte/mca/iof/base/iof_base_setup.c (revision 7735)
+++ orte/mca/iof/base/iof_base_setup.c (working copy)
@@ -47,6 +47,9 @@
 # include <termio.h>
 # endif
+#include <libutil.h>
 #include "mca/iof/base/iof_base_setup.h"

Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

  • application/pgp-signature attachment: stored