Reportedly in some cases Docker starts processes with argv[0] pointing to an empty file. That would cause libgo to pass that empty file to libbacktrace, which would then fail to do any backtraces. Everything should work fine if libbacktrace falls back to /proc/self/exe.
This patch to libgo works around the problem by ignoring argv[0] if it is a small file, or if stat fails. This is not a perfect fix but it's an unusual problem. This is PR 61895. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.9 branch. Ian
diff -r 3674ebeb1d40 libgo/runtime/go-caller.c --- a/libgo/runtime/go-caller.c Sun Jul 20 12:24:14 2014 -0700 +++ b/libgo/runtime/go-caller.c Fri Aug 01 17:41:05 2014 -0700 @@ -7,6 +7,9 @@ /* Implement runtime.Caller. */ #include <stdint.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include "backtrace.h" @@ -99,6 +102,7 @@ if (back_state == NULL) { const char *filename; + struct stat s; filename = (const char *) runtime_progname (); @@ -108,6 +112,14 @@ if (__builtin_strchr (filename, '/') == NULL) filename = NULL; + /* If the file is small, then it's not the real executable. + This is specifically to deal with Docker, which uses a bogus + argv[0] (http://gcc.gnu.org/PR61895). It would be nice to + have a better check for whether this file is the real + executable. */ + if (stat (filename, &s) < 0 || s.st_size < 1024) + filename = NULL; + back_state = backtrace_create_state (filename, 1, error_callback, NULL); } runtime_unlock (&back_state_lock);