Patchwork libgo patch committed: Tweak runtime.Callers for Go 1 compatibility

login
register
mail settings
Submitter Ian Taylor
Date May 22, 2012, 9:53 p.m.
Message ID <mcraa0zzxv4.fsf@dhcp-172-18-216-180.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/160744/
State New
Headers show

Comments

Ian Taylor - May 22, 2012, 9:53 p.m.
In the Go 1 release of the other Go compiler, runtime.Callers had what I
would describe as an off-by-one error.  We can't change it now, because
that would break Go 1 backward compatibility.  This patch changes libgo
to have the same off-by-one error.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline and 4.7  branch.

Ian

Patch

diff -r d99f020243e7 libgo/runtime/go-callers.c
--- a/libgo/runtime/go-callers.c	Tue May 22 09:54:14 2012 -0700
+++ b/libgo/runtime/go-callers.c	Tue May 22 14:50:06 2012 -0700
@@ -72,5 +72,8 @@ 
 int
 Callers (int skip, struct __go_open_array pc)
 {
-  return runtime_callers (skip, (uintptr *) pc.__values, pc.__count);
+  /* In the Go 1 release runtime.Callers has an off-by-one error,
+     which we can not correct because it would break backward
+     compatibility.  Adjust SKIP here to be compatible.  */
+  return runtime_callers (skip - 1, (uintptr *) pc.__values, pc.__count);
 }