diff mbox

libgo patch RFA: Fix printing of names in stack dumps

Message ID mcrr4troci5.fsf@dhcp-172-18-216-180.mtv.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor June 7, 2012, 6:35 a.m. UTC
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

Comments

Richard Biener June 7, 2012, 9:23 a.m. UTC | #1
On Thu, Jun 7, 2012 at 8:35 AM, Ian Lance Taylor <iant@google.com> wrote:
> 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.

Please wait until after 4.7.1 is released for this and all further patches
that are not fixes for bootstrap/build issues.

Thanks,
Richard.

> Ian
>
diff mbox

Patch

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);
 	}
     }
 }