Go strings are not necessarily NUL terminated.  The stack dump code was
erroneously using %s to print the contents of a Go string.  The
runtime_printf function that it uses supports %S to print a Go string.
This patch fixes the code to use %S.  Without this a stack dump
sometimes prints random junk characters at the end of a function or file
name in a stack dump.

Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.

Committed to mainline.  OK for 4.7 branch?  It's nice to have, since it
avoids printing garbage, but it's not critical.

Ian

diff -r f39a1e7cce67 libgo/runtime/go-traceback.c
--- a/libgo/runtime/go-traceback.c	Wed Jun 06 22:48:14 2012 -0700
+++ b/libgo/runtime/go-traceback.c	Wed Jun 06 23:24:37 2012 -0700
@@ -35,8 +35,8 @@
       if (__go_file_line (pcbuf[i], &fn, &file, &line)
 	  && runtime_showframe (fn.__data))
 	{
-	  runtime_printf ("%s\n", fn.__data);
-	  runtime_printf ("\t%s:%d\n", file.__data, line);
+	  runtime_printf ("%S\n", fn);
+	  runtime_printf ("\t%S:%d\n", file, line);
 	}
     }
 }

Reply via email to