[go] runtime: adjust frame pointer of dead frames interrupted by sigpanic

3 views
Skip to first unread message

Nick Ripley (Gerrit)

unread,
Dec 17, 2025, 11:01:00 AM (2 days ago) Dec 17
to goph...@pubsubhelper.golang.org, Cherry Mui, Keith Randall, Go LUCI, golang-co...@googlegroups.com
Attention needed from Cherry Mui and Keith Randall

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Keith Randall
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I600d7942521e90852c67e379679b07e96a6a6964
Gerrit-Change-Number: 730200
Gerrit-PatchSet: 2
Gerrit-Owner: Nick Ripley <nick....@datadoghq.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Nick Ripley <nick....@datadoghq.com>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Comment-Date: Wed, 17 Dec 2025 16:00:51 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
unsatisfied_requirement
satisfied_requirement
open
diffy

Keith Randall (Gerrit)

unread,
Dec 18, 2025, 11:15:54 AM (23 hours ago) Dec 18
to Nick Ripley, goph...@pubsubhelper.golang.org, Cherry Mui, Keith Randall, Go LUCI, golang-co...@googlegroups.com
Attention needed from Cherry Mui and Nick Ripley

Keith Randall added 2 comments

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Keith Randall . resolved

Seems reasonable.

I have one question - can we just get rid of the continpc==0 special case? Does that also fix this issue?
If it is just an optimization, I'm happy to get rid of it.

File src/runtime/callers_test.go
Line 494, Patchset 2 (Latest): runtime.KeepAlive(&i)
Keith Randall . unresolved

Is there a point to this KeepAlive call?
(Maybe making sure deref gets a frame?)

Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Nick Ripley
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I600d7942521e90852c67e379679b07e96a6a6964
    Gerrit-Change-Number: 730200
    Gerrit-PatchSet: 2
    Gerrit-Owner: Nick Ripley <nick....@datadoghq.com>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Nick Ripley <nick....@datadoghq.com>
    Gerrit-Attention: Cherry Mui <cher...@google.com>
    Gerrit-Attention: Nick Ripley <nick....@datadoghq.com>
    Gerrit-Comment-Date: Thu, 18 Dec 2025 16:15:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Cherry Mui (Gerrit)

    unread,
    Dec 18, 2025, 11:36:37 AM (23 hours ago) Dec 18
    to Nick Ripley, goph...@pubsubhelper.golang.org, Keith Randall, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Nick Ripley

    Cherry Mui voted and added 2 comments

    Votes added by Cherry Mui

    Code-Review+1

    2 comments

    File src/runtime/stack.go
    Line 730, Patchset 1: f := frame.fn
    if stackDebug >= 2 {
    print(" adjusting ", funcname(f), " frame=[", hex(frame.sp), ",", hex(frame.fp), "] pc=", hex(frame.pc), " continpc=", hex(frame.continpc), "\n")
    }
    Cherry Mui . unresolved

    We probably should keep the debug print at the top. Otherwise the print of "saved bp" above would be weird.

    Line 733, Patchset 2 (Latest): // saved. See the diagram. Note that preparePanic also saves a
    // "frame pointer" in sigpanic's frame, but this frame pointer
    // is not linked in to the frame pointer sequence since sigpanic
    // will see the frame pointer register value as of the panicking
    // function call.
    Cherry Mui . unresolved

    Should preparePanic just update the FP register (R29) in the signal context, so it is linked?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Nick Ripley
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I600d7942521e90852c67e379679b07e96a6a6964
    Gerrit-Change-Number: 730200
    Gerrit-PatchSet: 2
    Gerrit-Owner: Nick Ripley <nick....@datadoghq.com>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Nick Ripley <nick....@datadoghq.com>
    Gerrit-Attention: Nick Ripley <nick....@datadoghq.com>
    Gerrit-Comment-Date: Thu, 18 Dec 2025 16:36:32 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Nick Ripley (Gerrit)

    unread,
    Dec 18, 2025, 3:33:14 PM (19 hours ago) Dec 18
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Nick Ripley

    Nick Ripley uploaded new patchset

    Nick Ripley uploaded patch set #3 to this change.
    Following approvals got outdated and were removed:
    • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Nick Ripley
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: newpatchset
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I600d7942521e90852c67e379679b07e96a6a6964
      Gerrit-Change-Number: 730200
      Gerrit-PatchSet: 3
      unsatisfied_requirement
      open
      diffy

      Nick Ripley (Gerrit)

      unread,
      Dec 18, 2025, 3:53:52 PM (19 hours ago) Dec 18
      to goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Keith Randall, golang-co...@googlegroups.com
      Attention needed from Cherry Mui and Keith Randall

      Nick Ripley voted and added 4 comments

      Votes added by Nick Ripley

      Commit-Queue+1

      4 comments

      Patchset-level comments
      Keith Randall . resolved

      Seems reasonable.

      I have one question - can we just get rid of the continpc==0 special case? Does that also fix this issue?
      If it is just an optimization, I'm happy to get rid of it.

      Nick Ripley

      It's just an optimization, yeah. The frame.getStackMap function already returns empty values if continpc is 0. In that case rest of adjustframe does very little since the rest of the function is just using those empty values. I went ahead and dropped the check instead.

      We'll still need additional the fixup for arm64, though.

      File src/runtime/callers_test.go
      Line 494, Patchset 2: runtime.KeepAlive(&i)
      Keith Randall . resolved

      Is there a point to this KeepAlive call?
      (Maybe making sure deref gets a frame?)

      Nick Ripley

      Just making sure deref gets a frame. I added a comment.

      File src/runtime/stack.go
      Line 730, Patchset 1: f := frame.fn
      if stackDebug >= 2 {
      print(" adjusting ", funcname(f), " frame=[", hex(frame.sp), ",", hex(frame.fp), "] pc=", hex(frame.pc), " continpc=", hex(frame.continpc), "\n")
      }
      Cherry Mui . resolved

      We probably should keep the debug print at the top. Otherwise the print of "saved bp" above would be weird.

      Nick Ripley

      Done as part of responding to Keith's comment about removing the continpc == 0 special case.

      Line 733, Patchset 2: // saved. See the diagram. Note that preparePanic also saves a

      // "frame pointer" in sigpanic's frame, but this frame pointer
      // is not linked in to the frame pointer sequence since sigpanic
      // will see the frame pointer register value as of the panicking
      // function call.
      Cherry Mui . unresolved

      Should preparePanic just update the FP register (R29) in the signal context, so it is linked?

      Nick Ripley

      We could update R29 to link in what preparePanic saves, but we would still need to fix the frame pointer saved below the panicking function's call frame since we'd still visit it.

      Also, if we link in the frame pointer that preparePanic saves, we can end up with duplicate frames in the traceback. preparePanic saves the LR value from the panicking function onto the call stack. That will be the same LR value that the panicking function saved, if it has not updated LR. If I understand the internal ABI correctly, LR can be used as a scratch register in a function body. So the LR that prepare panic saves onto the stack might not even be a valid PC.

      My inclination would be to skip it. In CL 481635 I made preparePanic save a valid frame pointer so that debugCheckBP is happy when it sees the frame pointer saved by preparePanic at the top of the sigpanic frame. But if we don't link it, perhaps preparePanic can just put 0 there. WDYT?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Cherry Mui
      • Keith Randall
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I600d7942521e90852c67e379679b07e96a6a6964
        Gerrit-Change-Number: 730200
        Gerrit-PatchSet: 3
        Gerrit-Owner: Nick Ripley <nick....@datadoghq.com>
        Gerrit-Reviewer: Cherry Mui <cher...@google.com>
        Gerrit-Reviewer: Keith Randall <k...@golang.org>
        Gerrit-Reviewer: Nick Ripley <nick....@datadoghq.com>
        Gerrit-Attention: Keith Randall <k...@golang.org>
        Gerrit-Attention: Cherry Mui <cher...@google.com>
        Gerrit-Comment-Date: Thu, 18 Dec 2025 20:53:48 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Keith Randall <k...@golang.org>
        Comment-In-Reply-To: Cherry Mui <cher...@google.com>
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages