[go] runtime: support runtime.free in noscan size-specialized mallocs

10 views
Skip to first unread message

t hepudds (Gerrit)

unread,
Oct 28, 2025, 3:25:55 PM (9 days ago) Oct 28
to goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com

New activity on the change

Open in Gerrit

Related details

Attention set is empty
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: I2657622601a27211554ee862fce057e101767a70
Gerrit-Change-Number: 715761
Gerrit-PatchSet: 2
Gerrit-Owner: t hepudds <thepud...@gmail.com>
Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
Gerrit-Comment-Date: Tue, 28 Oct 2025 19:25:51 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
unsatisfied_requirement
satisfied_requirement
open
diffy

t hepudds (Gerrit)

unread,
Oct 28, 2025, 3:27:02 PM (9 days ago) Oct 28
to goph...@pubsubhelper.golang.org, Michael Matloob, Michael Knyszek, Go LUCI, golang-co...@googlegroups.com
Attention needed from Michael Knyszek and Michael Matloob

t hepudds added 1 comment

Patchset-level comments
File-level comment, Patchset 2 (Latest):
t hepudds . resolved

PTAL when convenient.

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Knyszek
  • Michael Matloob
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: I2657622601a27211554ee862fce057e101767a70
Gerrit-Change-Number: 715761
Gerrit-PatchSet: 2
Gerrit-Owner: t hepudds <thepud...@gmail.com>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
Gerrit-Attention: Michael Matloob <mat...@golang.org>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Tue, 28 Oct 2025 19:26:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
satisfied_requirement
open
diffy

Michael Knyszek (Gerrit)

unread,
Oct 31, 2025, 12:45:48 PM (6 days ago) Oct 31
to t hepudds, goph...@pubsubhelper.golang.org, Michael Matloob, Go LUCI, golang-co...@googlegroups.com
Attention needed from Michael Matloob and t hepudds

Michael Knyszek added 3 comments

File src/runtime/malloc_generated.go
Line 6412, Patchset 2 (Latest): if valgrindenabled {
valgrindMalloc(x, size)
}
Michael Knyszek . unresolved

I think this is technically incorrect, since we don't do a valgrindFree in freeSized. maybe we should?

Line 6416, Patchset 2 (Latest): if gcBlackenEnabled != 0 && elemsize != 0 {
if assistG := getg().m.curg; assistG != nil {
assistG.gcAssistBytes -= int64(elemsize - size)
}
}
Michael Knyszek . unresolved

I think this part might be incorrect. we don't want to subtract anything in this path.

Line 6422, Patchset 2 (Latest): if debug.malloc {
postMallocgcDebug(x, elemsize, typ)
}
Michael Knyszek . unresolved

this is another "maybe we should do this" in the regular code path too. I think it's also fine to just drop from here.

this code is probably automatically added by the generator, so the generator may need some tweaks.

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Matloob
  • t hepudds
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: I2657622601a27211554ee862fce057e101767a70
    Gerrit-Change-Number: 715761
    Gerrit-PatchSet: 2
    Gerrit-Owner: t hepudds <thepud...@gmail.com>
    Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Attention: t hepudds <thepud...@gmail.com>
    Gerrit-Comment-Date: Fri, 31 Oct 2025 16:45:41 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Michael Knyszek (Gerrit)

    unread,
    Oct 31, 2025, 12:49:54 PM (6 days ago) Oct 31
    to t hepudds, goph...@pubsubhelper.golang.org, Michael Matloob, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Michael Matloob and t hepudds

    Michael Knyszek added 2 comments

    File src/runtime/malloc_generated.go
    Line 6416, Patchset 2 (Latest): if gcBlackenEnabled != 0 && elemsize != 0 {
    if assistG := getg().m.curg; assistG != nil {
    assistG.gcAssistBytes -= int64(elemsize - size)
    }
    }
    Michael Knyszek . resolved

    I think this part might be incorrect. we don't want to subtract anything in this path.

    Michael Knyszek

    just kidding, this is correct.

    Line 6422, Patchset 2 (Latest): if debug.malloc {
    postMallocgcDebug(x, elemsize, typ)
    }
    Michael Knyszek . resolved

    this is another "maybe we should do this" in the regular code path too. I think it's also fine to just drop from here.

    this code is probably automatically added by the generator, so the generator may need some tweaks.

    Michael Knyszek

    just kidding, this is also correct.

    Gerrit-Comment-Date: Fri, 31 Oct 2025 16:49:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Michael Knyszek <mkny...@google.com>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    t hepudds (Gerrit)

    unread,
    Nov 3, 2025, 5:19:53 PM (3 days ago) Nov 3
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Michael Matloob and t hepudds

    t hepudds uploaded new patchset

    t hepudds 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:
    • Michael Matloob
    • t hepudds
    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: I2657622601a27211554ee862fce057e101767a70
      Gerrit-Change-Number: 715761
      Gerrit-PatchSet: 3
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 3, 2025, 6:40:24 PM (2 days ago) Nov 3
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Michael Matloob and t hepudds

      t hepudds uploaded new patchset

      t hepudds uploaded patch set #4 to this change.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Matloob
      • t hepudds
      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: I2657622601a27211554ee862fce057e101767a70
      Gerrit-Change-Number: 715761
      Gerrit-PatchSet: 4
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 4, 2025, 1:24:41 AM (2 days ago) Nov 4
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Michael Matloob and t hepudds

      t hepudds uploaded new patchset

      t hepudds uploaded patch set #6 to this change.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Matloob
      • t hepudds
      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: I2657622601a27211554ee862fce057e101767a70
      Gerrit-Change-Number: 715761
      Gerrit-PatchSet: 6
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 4, 2025, 1:08:37 PM (2 days ago) Nov 4
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Michael Matloob and t hepudds

      t hepudds uploaded new patchset

      t hepudds uploaded patch set #7 to this change.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Matloob
      • t hepudds
      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: I2657622601a27211554ee862fce057e101767a70
      Gerrit-Change-Number: 715761
      Gerrit-PatchSet: 7
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 4, 2025, 2:59:38 PM (2 days ago) Nov 4
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Michael Matloob and t hepudds

      t hepudds uploaded new patchset

      t hepudds uploaded patch set #8 to this change.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Matloob
      • t hepudds
      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: I2657622601a27211554ee862fce057e101767a70
      Gerrit-Change-Number: 715761
      Gerrit-PatchSet: 8
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 4, 2025, 5:10:49 PM (2 days ago) Nov 4
      to goph...@pubsubhelper.golang.org, Michael Matloob, Michael Knyszek, Go LUCI, golang-co...@googlegroups.com
      Attention needed from Michael Knyszek and Michael Matloob

      t hepudds added 1 comment

      File src/runtime/malloc_generated.go
      Line 6412, Patchset 2: if valgrindenabled {
      valgrindMalloc(x, size)
      }
      Michael Knyszek . unresolved

      I think this is technically incorrect, since we don't do a valgrindFree in freeSized. maybe we should?

      t hepudds

      This is now more explicitly guarded by `runtimeFreegcEnabled`, and `runtimeFreegcEnabled` is now defined in malloc.go to be false when `valgrindenabled` is true, so hopefully that `valgrindMalloc` call never happens.

      That said, looking over CL 674077 (which added valgrind support) and grepping the source code, it's not immediately obvious to me how valgrind support in Go is typically tested, and I don't immediately see something like a valgrind builder.

      My imprecise sense is that valgrind support is still somewhat best effort.

      For now, I'll leave this comment as unresolved to see if there is some way to test this under valgrind.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Knyszek
      • Michael Matloob
      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: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I2657622601a27211554ee862fce057e101767a70
      Gerrit-Change-Number: 715761
      Gerrit-PatchSet: 10
      Gerrit-Owner: t hepudds <thepud...@gmail.com>
      Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
      Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
      Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
      Gerrit-Attention: Michael Matloob <mat...@golang.org>
      Gerrit-Attention: Michael Knyszek <mkny...@google.com>
      Gerrit-Comment-Date: Tue, 04 Nov 2025 22:10:44 +0000
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 4, 2025, 5:54:13 PM (2 days ago) Nov 4
      to goph...@pubsubhelper.golang.org, Michael Matloob, Michael Knyszek, Go LUCI, golang-co...@googlegroups.com
      Attention needed from Michael Knyszek and Michael Matloob

      t hepudds voted Commit-Queue+1

      Commit-Queue+1
      Gerrit-Comment-Date: Tue, 04 Nov 2025 22:54:08 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 4, 2025, 8:52:19 PM (2 days ago) Nov 4
      to goph...@pubsubhelper.golang.org, Go LUCI, Michael Matloob, Michael Knyszek, golang-co...@googlegroups.com
      Attention needed from Michael Knyszek and Michael Matloob

      t hepudds voted Commit-Queue+1

      Commit-Queue+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Knyszek
      • Michael Matloob
      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: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I2657622601a27211554ee862fce057e101767a70
      Gerrit-Change-Number: 715761
      Gerrit-PatchSet: 11
      Gerrit-Owner: t hepudds <thepud...@gmail.com>
      Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
      Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
      Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
      Gerrit-Attention: Michael Matloob <mat...@golang.org>
      Gerrit-Attention: Michael Knyszek <mkny...@google.com>
      Gerrit-Comment-Date: Wed, 05 Nov 2025 01:52:16 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 5, 2025, 10:03:01 AM (20 hours ago) Nov 5
      to goph...@pubsubhelper.golang.org, Go LUCI, Michael Matloob, Michael Knyszek, golang-co...@googlegroups.com
      Gerrit-Comment-Date: Wed, 05 Nov 2025 15:02:55 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 5, 2025, 12:52:30 PM (17 hours ago) Nov 5
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Michael Knyszek and Michael Matloob

      t hepudds uploaded new patchset

      t hepudds uploaded patch set #12 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:
      • Michael Knyszek
      • Michael Matloob
      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: I2657622601a27211554ee862fce057e101767a70
      Gerrit-Change-Number: 715761
      Gerrit-PatchSet: 12
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 5, 2025, 1:50:02 PM (16 hours ago) Nov 5
      to goph...@pubsubhelper.golang.org, Go LUCI, Michael Matloob, Michael Knyszek, golang-co...@googlegroups.com
      Attention needed from Michael Knyszek and Michael Matloob

      t hepudds voted Commit-Queue+1

      Commit-Queue+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Knyszek
      • Michael Matloob
      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: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I2657622601a27211554ee862fce057e101767a70
      Gerrit-Change-Number: 715761
      Gerrit-PatchSet: 12
      Gerrit-Owner: t hepudds <thepud...@gmail.com>
      Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
      Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
      Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
      Gerrit-Attention: Michael Matloob <mat...@golang.org>
      Gerrit-Attention: Michael Knyszek <mkny...@google.com>
      Gerrit-Comment-Date: Wed, 05 Nov 2025 18:49:57 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      unsatisfied_requirement
      open
      diffy

      t hepudds (Gerrit)

      unread,
      Nov 5, 2025, 3:42:19 PM (14 hours ago) Nov 5
      to goph...@pubsubhelper.golang.org, Go LUCI, Michael Matloob, Michael Knyszek, golang-co...@googlegroups.com
      Attention needed from Michael Knyszek and Michael Matloob

      t hepudds added 1 comment

      File src/runtime/malloc_generated.go
      Line 6412, Patchset 2: if valgrindenabled {
      valgrindMalloc(x, size)
      }
      Michael Knyszek . resolved

      I think this is technically incorrect, since we don't do a valgrindFree in freeSized. maybe we should?

      t hepudds

      This is now more explicitly guarded by `runtimeFreegcEnabled`, and `runtimeFreegcEnabled` is now defined in malloc.go to be false when `valgrindenabled` is true, so hopefully that `valgrindMalloc` call never happens.

      That said, looking over CL 674077 (which added valgrind support) and grepping the source code, it's not immediately obvious to me how valgrind support in Go is typically tested, and I don't immediately see something like a valgrind builder.

      My imprecise sense is that valgrind support is still somewhat best effort.

      For now, I'll leave this comment as unresolved to see if there is some way to test this under valgrind.

      t hepudds

      I took a quick look at the compiler IR for this `mallocgcSmallNoScanSC2` function on Linux with and without `-tags=valgrind`, which is my understanding of how valgrind support is enabled.

      When `-tags=valgrind` is _not_ set, I do not see any calls to `valgrindMalloc`.

      When `-tags=valgrind` is set, I can see _other_ calls to `valgrindMalloc` in this function but not the call here guarded by `runtimeFreegcEnabled`, so that is hopefully some confirmation this is working as expected -- `runtimeFreegcEnabled` is false when `valgrindenabled` is true.

      So I think I am going to mark this comment as resolved.

      I also added a TODO in malloc.go saying it would be nice to check the valgrind integration (though I haven't mailed that updated comment yet).

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Knyszek
      • Michael Matloob
      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: I2657622601a27211554ee862fce057e101767a70
        Gerrit-Change-Number: 715761
        Gerrit-PatchSet: 12
        Gerrit-Owner: t hepudds <thepud...@gmail.com>
        Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
        Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
        Gerrit-Reviewer: t hepudds <thepud...@gmail.com>
        Gerrit-Attention: Michael Matloob <mat...@golang.org>
        Gerrit-Attention: Michael Knyszek <mkny...@google.com>
        Gerrit-Comment-Date: Wed, 05 Nov 2025 20:42:15 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: t hepudds <thepud...@gmail.com>
        Comment-In-Reply-To: Michael Knyszek <mkny...@google.com>
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        t hepudds (Gerrit)

        unread,
        Nov 5, 2025, 4:09:56 PM (14 hours ago) Nov 5
        to goph...@pubsubhelper.golang.org, Go LUCI, Michael Matloob, Michael Knyszek, golang-co...@googlegroups.com
        Attention needed from Michael Knyszek and Michael Matloob

        t hepudds added 1 comment

        Patchset-level comments
        File-level comment, Patchset 12 (Latest):
        t hepudds . resolved

        This CL is also ready for review (though probably also less important than CL 673695 at this point).

        Gerrit-Comment-Date: Wed, 05 Nov 2025 21:09:52 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        t hepudds (Gerrit)

        unread,
        Nov 5, 2025, 4:19:10 PM (14 hours ago) Nov 5
        to goph...@pubsubhelper.golang.org, Go LUCI, Michael Matloob, Michael Knyszek, golang-co...@googlegroups.com
        Attention needed from Michael Knyszek and Michael Matloob

        t hepudds added 1 comment

        File src/runtime/malloc_generated.go
        Line 6412, Patchset 2: if valgrindenabled {
        valgrindMalloc(x, size)
        }
        Michael Knyszek . resolved

        I think this is technically incorrect, since we don't do a valgrindFree in freeSized. maybe we should?

        t hepudds

        This is now more explicitly guarded by `runtimeFreegcEnabled`, and `runtimeFreegcEnabled` is now defined in malloc.go to be false when `valgrindenabled` is true, so hopefully that `valgrindMalloc` call never happens.

        That said, looking over CL 674077 (which added valgrind support) and grepping the source code, it's not immediately obvious to me how valgrind support in Go is typically tested, and I don't immediately see something like a valgrind builder.

        My imprecise sense is that valgrind support is still somewhat best effort.

        For now, I'll leave this comment as unresolved to see if there is some way to test this under valgrind.

        t hepudds

        I took a quick look at the compiler IR for this `mallocgcSmallNoScanSC2` function on Linux with and without `-tags=valgrind`, which is my understanding of how valgrind support is enabled.

        When `-tags=valgrind` is _not_ set, I do not see any calls to `valgrindMalloc`.

        When `-tags=valgrind` is set, I can see _other_ calls to `valgrindMalloc` in this function but not the call here guarded by `runtimeFreegcEnabled`, so that is hopefully some confirmation this is working as expected -- `runtimeFreegcEnabled` is false when `valgrindenabled` is true.

        So I think I am going to mark this comment as resolved.

        I also added a TODO in malloc.go saying it would be nice to check the valgrind integration (though I haven't mailed that updated comment yet).

        t hepudds

        (I guess I should add that I looked at the IR just before escape analysis, which is after the early dead code elimination done by unified IR, which is probably where the code was eliminated based on the const values, though maybe it was something else that eliminated it.)

        Gerrit-Comment-Date: Wed, 05 Nov 2025 21:19:07 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages