diff mbox

libgo patch committed: Don't use filename without '/' for backtrace

Message ID mcr61ruipj0.fsf@iant-glaptop.roam.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor Nov. 14, 2013, 10:31 p.m. UTC
This patch changes libgo so that if the executable filename does not
have a '/', it does not use that name for the backtrace library.  This
is the case when an executable is found on PATH.  In that case, there is
no particular reason to believe that a file with that name in the
current directory is the same as the executable itself.  This is
http://golang.org/issue/6715.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 87729ea100b9 libgo/runtime/go-caller.c
--- a/libgo/runtime/go-caller.c	Thu Nov 14 14:12:12 2013 -0800
+++ b/libgo/runtime/go-caller.c	Thu Nov 14 14:28:40 2013 -0800
@@ -101,6 +101,13 @@ 
       const char *filename;
 
       filename = (const char *) runtime_progname ();
+
+      /* If there is no '/' in FILENAME, it was found on PATH, and
+	 might not be the same as the file with the same name in the
+	 current directory.  */
+      if (__builtin_strchr (filename, '/') == NULL)
+	filename = NULL;
+
       back_state = backtrace_create_state (filename, 1, error_callback, NULL);
     }
   runtime_unlock (&back_state_lock);