With the strnlen-related Go failures now gone on Solaris, another issue crept up: several tests were failing like this:
throw: /proc/self/exe goroutine 4 [running]: panic during panic FAIL: log This is due to the hardcoded use of /proc/self/exe in libbacktrace, which doesn't exist on Solaris, and probably is also missing on other non-Linux OSes. Solaris (since 2.6, it seems) provides getexecname() instead, which this patch uses. I haven't touched the other hardcoded use in print.c since it isn't obvious to me how best to handle it. Tested by rebuilding libbacktrace and libgo and rerunning the libgo tests on i386-pc-solaris2.11. All the /proc/self/exe-related failures are now gone as expected. Ok for mainline? Rainer 2012-10-05 Rainer Orth <r...@cebitec.uni-bielefeld.de> * configure.ac: Check for getexecname. * configure: Regenerate. * config.h.in: Regenerate. * fileline.c (fileline_initialize) [HAVE_GETEXECNAME]: Use getexecname if available.
# HG changeset patch # Parent 73da06114bd60792e31b30c4fd95ee5fe340167b Use getexecname() on Solaris diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac --- a/libbacktrace/configure.ac +++ b/libbacktrace/configure.ac @@ -242,6 +242,19 @@ fi AC_CHECK_DECLS(strnlen) +# Check for getexecname function. +if test -n "${with_target_subdir}"; then + case "${host}" in + *-*-solaris2*) have_getexecname=yes ;; + *) have_getexecname=no ;; + esac +else + AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexename=no]) +fi +if test "$have_getexecname" = "yes"; then + AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.]) +fi + AC_CACHE_CHECK([whether tests can run], [libbacktrace_cv_sys_native], [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])], diff --git a/libbacktrace/fileline.c b/libbacktrace/fileline.c --- a/libbacktrace/fileline.c +++ b/libbacktrace/fileline.c @@ -49,6 +49,7 @@ fileline_initialize (struct backtrace_st { int failed; fileline fileline_fn; + const char *execname; int descriptor; failed = state->fileline_initialization_failed; @@ -82,7 +83,14 @@ fileline_initialize (struct backtrace_st if (state->filename != NULL) descriptor = backtrace_open (state->filename, error_callback, data); else - descriptor = backtrace_open ("/proc/self/exe", error_callback, data); + { +#ifdef HAVE_GETEXECNAME + execname = getexecname (); +#else + execname = "/proc/self/exe"; +#endif + descriptor = backtrace_open (execname, error_callback, data); + } if (descriptor < 0) failed = 1;
-- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University