From 14d2ee1d00b4fcaef569a84cb84888603405ca31 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 31 May 2014 10:10:12 -0400 Subject: runtime: make continuation pc available to stack walk The 'continuation pc' is where the frame will continue execution, if anywhere. For a frame that stopped execution due to a CALL instruction, the continuation pc is immediately after the CALL. But for a frame that stopped execution due to a fault, the continuation pc is the pc after the most recent CALL to deferproc in that frame, or else 0. That is where execution will continue, if anywhere. The liveness information is only recorded for CALL instructions. This change makes sure that we never look for liveness information except for CALL instructions. Using a valid PC fixes crashes when a garbage collection or stack copying tries to process a stack frame that has faulted. Record continuation pc in heapdump (format change). Fixes #8048. LGTM=iant, khr R=khr, iant, dvyukov CC=golang-codereviews, r https://golang.org/cl/100870044 --- src/pkg/runtime/runtime.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/pkg/runtime/runtime.h') diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h index fa6b6ffa04..5115503789 100644 --- a/src/pkg/runtime/runtime.h +++ b/src/pkg/runtime/runtime.h @@ -703,6 +703,11 @@ struct Defer void* args[1]; // padded to actual size }; +// argp used in Defer structs when there is no argp. +// TODO(rsc): Maybe we could use nil instead, but we've always used -1 +// and I don't want to change this days before the Go 1.3 release. +#define NoArgs ((byte*)-1) + /* * panics */ @@ -724,6 +729,7 @@ struct Stkframe { Func* fn; // function being run uintptr pc; // program counter within fn + uintptr continpc; // program counter where execution can continue, or 0 if not uintptr lr; // program counter at caller aka link register uintptr sp; // stack pointer at pc uintptr fp; // stack pointer at caller aka frame pointer -- cgit v1.3-5-g9baa