You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ze...@apache.org on 2023/04/21 18:16:22 UTC
[arrow] branch main updated: GH-35234: [Go] Fix skip argument to Callers (#35231)
This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new c48916a537 GH-35234: [Go] Fix skip argument to Callers (#35231)
c48916a537 is described below
commit c48916a537d8279485c5e30cb85af7451383e39d
Author: Herman Schaaf <he...@gmail.com>
AuthorDate: Fri Apr 21 19:16:12 2023 +0100
GH-35234: [Go] Fix skip argument to Callers (#35231)
Follow-up to https://github.com/apache/arrow/pull/35215. It's mostly cosmetic, but without the additional 2 skips passed in to `Callers`, the Caller frame is repeated in the stack trace, and one frame below it is added as well. With this change, the checked allocator stack trace contains no duplicates.
I had this change locally but didn't realize it wasn't pushed to the PR branch, sorry about that :bow:
* Closes: #35234
Authored-by: Herman Schaaf <he...@gmail.com>
Signed-off-by: Matt Topol <zo...@gmail.com>
---
go/arrow/memory/checked_allocator.go | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/go/arrow/memory/checked_allocator.go b/go/arrow/memory/checked_allocator.go
index 12f92912bb..31a5ca2420 100644
--- a/go/arrow/memory/checked_allocator.go
+++ b/go/arrow/memory/checked_allocator.go
@@ -49,7 +49,12 @@ func (a *CheckedAllocator) Allocate(size int) []byte {
ptr := uintptr(unsafe.Pointer(&out[0]))
pcs := make([]uintptr, maxRetainedFrames)
- runtime.Callers(allocFrames, pcs)
+
+ // For historical reasons the meaning of the skip argument
+ // differs between Caller and Callers. For Callers, 0 identifies
+ // the frame for the caller itself. We skip 2 additional frames
+ // here to get to the caller right before the call to Allocate.
+ runtime.Callers(allocFrames+2, pcs)
callersFrames := runtime.CallersFrames(pcs)
if pc, _, l, ok := runtime.Caller(allocFrames); ok {
a.allocs.Store(ptr, &dalloc{pc: pc, line: l, sz: size, callersFrames: callersFrames})
@@ -69,7 +74,12 @@ func (a *CheckedAllocator) Reallocate(size int, b []byte) []byte {
newptr := uintptr(unsafe.Pointer(&out[0]))
a.allocs.Delete(oldptr)
pcs := make([]uintptr, maxRetainedFrames)
- runtime.Callers(reallocFrames, pcs)
+
+ // For historical reasons the meaning of the skip argument
+ // differs between Caller and Callers. For Callers, 0 identifies
+ // the frame for the caller itself. We skip 2 additional frames
+ // here to get to the caller right before the call to Reallocate.
+ runtime.Callers(reallocFrames+2, pcs)
callersFrames := runtime.CallersFrames(pcs)
if pc, _, l, ok := runtime.Caller(reallocFrames); ok {
a.allocs.Store(newptr, &dalloc{pc: pc, line: l, sz: size, callersFrames: callersFrames})