aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libgo/runtime/go-caller.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/libgo/runtime/go-caller.c')
-rw-r--r--gcc-4.9/libgo/runtime/go-caller.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc-4.9/libgo/runtime/go-caller.c b/gcc-4.9/libgo/runtime/go-caller.c
index e97b85097..a3e04240d 100644
--- a/gcc-4.9/libgo/runtime/go-caller.c
+++ b/gcc-4.9/libgo/runtime/go-caller.c
@@ -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 @@ __go_get_backtrace_state ()
if (back_state == NULL)
{
const char *filename;
+ struct stat s;
filename = (const char *) runtime_progname ();
@@ -108,6 +112,14 @@ __go_get_backtrace_state ()
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);