-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
Go version
go1.25+ and master
Output of go env
in your module/workspace:
.
What did you do?
I copied program from: 52eaed6
package main
import (
"fmt"
"log"
"os"
)
/*
#include <stdlib.h>
void f(void)
{
(void)malloc(1024*1024*1024);
}
*/
import "C"
func main() {
C.f()
data, err := os.ReadFile("/proc/self/maps")
if err != nil {
log.Fatal(err)
}
fmt.Println(string(data))
}
What did you see happen?
When I run this program on go1.25
I see only single named memory mapping [anon: Go: immortal metadata]
patryk@patryk:~$ GLIBC_TUNABLES=glibc.mem.decorate_maps=1 go run a.go
# command-line-arguments
./a.go: In function \u2018f\u2019:
./a.go:13:9: warning: ignoring return value of \u2018malloc\u2019 declared with attribute \u2018warn_unused_result\u2019 [-Wunused-result]
13 | (void)malloc(1024*1024*1024);
| ^~~~~~~~~~~~~~~~~~~~~~
00400000-00577000 r-xp 00000000 fd:02 16384750 /home/patryk/.cache/go-build/bb/bbe5287252af91f0dcae2fc8323a2bafe87257c1b844db57cd3c7711fb5abed7-d/a
0058f000-00590000 r--p 0017f000 fd:02 16384750 /home/patryk/.cache/go-build/bb/bbe5287252af91f0dcae2fc8323a2bafe87257c1b844db57cd3c7711fb5abed7-d/a
00590000-0059b000 rw-p 00180000 fd:02 16384750 /home/patryk/.cache/go-build/bb/bbe5287252af91f0dcae2fc8323a2bafe87257c1b844db57cd3c7711fb5abed7-d/a
0059b000-005d7000 rw-p 00000000 00:00 0
00ece000-00eef000 rw-p 00000000 00:00 0 [heap]
4000000000-4000400000 rw-p 00000000 00:00 0
4000400000-4004000000 ---p 00000000 00:00 0
f71a54000000-f71a54021000 rw-p 00000000 00:00 0 [anon: glibc: malloc arena]
f71a54021000-f71a58000000 ---p 00000000 00:00 0
f71a58000000-f71a58021000 rw-p 00000000 00:00 0 [anon: glibc: malloc arena]
f71a58021000-f71a5c000000 ---p 00000000 00:00 0
f71a5c000000-f71a5c021000 rw-p 00000000 00:00 0 [anon: glibc: malloc arena]
f71a5c021000-f71a60000000 ---p 00000000 00:00 0
f71a60000000-f71a60021000 rw-p 00000000 00:00 0 [anon: glibc: malloc arena]
f71a60021000-f71a64000000 ---p 00000000 00:00 0
f71a64000000-f71a64021000 rw-p 00000000 00:00 0 [anon: glibc: malloc arena]
f71a64021000-f71a68000000 ---p 00000000 00:00 0
f71a68230000-f71a68240000 ---p 00000000 00:00 0
f71a68240000-f71a68a40000 rw-p 00000000 00:00 0 [anon: glibc: pthread stack: 608584]
f71a68a40000-f71a68a50000 ---p 00000000 00:00 0
f71a68a50000-f71a69250000 rw-p 00000000 00:00 0 [anon: glibc: pthread stack: 608583]
f71a69250000-f71a69290000 rw-p 00000000 00:00 0 [anon: Go: immortal metadata]
f71a69290000-f71a692a0000 ---p 00000000 00:00 0
f71a692a0000-f71a69aa0000 rw-p 00000000 00:00 0 [anon: glibc: pthread stack: 608582]
f71a69aa0000-f71a69ab0000 ---p 00000000 00:00 0
f71a69ab0000-f71a6a2b0000 rw-p 00000000 00:00 0 [anon: glibc: pthread stack: 608581]
f71a6a2b0000-f71a6a2f0000 rw-p 00000000 00:00 0 [anon: Go: immortal metadata]
f71a6a2f0000-f71a6a300000 ---p 00000000 00:00 0
f71a6a300000-f71a6ab00000 rw-p 00000000 00:00 0 [anon: glibc: pthread stack: 608580]
f71a6ab00000-f71a6cc00000 rw-p 00000000 00:00 0
f71a6cc00000-f71a6cc80000 ---p 00000000 00:00 0
f71a6cc80000-f71a6cc81000 rw-p 00000000 00:00 0
f71a6cc81000-f71a8cc80000 ---p 00000000 00:00 0
f71a8cc80000-f71a8cc81000 rw-p 00000000 00:00 0
f71a8cc81000-f71aacc10000 ---p 00000000 00:00 0
f71aacc10000-f71aacc11000 rw-p 00000000 00:00 0
f71aacc11000-f71ab0c02000 ---p 00000000 00:00 0
f71ab0c02000-f71ab0c03000 rw-p 00000000 00:00 0
f71ab0c03000-f71ab1400000 ---p 00000000 00:00 0
f71ab142e000-f71ab1461000 rw-p 00000000 00:00 0
f71ab1461000-f71ab1560000 ---p 00000000 00:00 0
f71ab1560000-f71ab15c0000 rw-p 00000000 00:00 0
f71ab15c0000-f71ab176a000 r-xp 00000000 fd:02 18747670 /usr/lib/aarch64-linux-gnu/libc.so.6
f71ab176a000-f71ab177d000 ---p 001aa000 fd:02 18747670 /usr/lib/aarch64-linux-gnu/libc.so.6
f71ab177d000-f71ab1780000 r--p 001ad000 fd:02 18747670 /usr/lib/aarch64-linux-gnu/libc.so.6
f71ab1780000-f71ab1782000 rw-p 001b0000 fd:02 18747670 /usr/lib/aarch64-linux-gnu/libc.so.6
f71ab1782000-f71ab178f000 rw-p 00000000 00:00 0
f71ab179e000-f71ab17c7000 r-xp 00000000 fd:02 18747364 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
f71ab17d6000-f71ab17d8000 rw-p 00000000 00:00 0 [anon: glibc: loader malloc]
f71ab17d8000-f71ab17da000 r--p 00000000 00:00 0 [vvar]
f71ab17da000-f71ab17dc000 r-xp 00000000 00:00 0 [vdso]
f71ab17dc000-f71ab17de000 r--p 0002e000 fd:02 18747364 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
f71ab17de000-f71ab17df000 rw-p 00030000 fd:02 18747364 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
f71ab17df000-f71ab17e0000 rw-p 00000000 00:00 0
ffffe0934000-ffffe0956000 rw-p 00000000 00:00 0 [stack]
What did you expect to see?
Fix should be backported to go1.25.
I think the main issue is that debug.decoratemappings
is initialized with 0
, and only later at runtime it changes to 1
- too late to take effect.
After applying my fix:
patryk@patryk:~/goroot/src$ git diff
diff --git a/src/runtime/set_vma_name_linux.go b/src/runtime/set_vma_name_linux.go
index 9b6654f332..d6b1a3c5a7 100644
--- a/src/runtime/set_vma_name_linux.go
+++ b/src/runtime/set_vma_name_linux.go
@@ -16,7 +16,7 @@ var prSetVMAUnsupported atomic.Bool
// setVMAName calls prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, start, len, name)
func setVMAName(start unsafe.Pointer, length uintptr, name string) {
- if debug.decoratemappings == 0 || prSetVMAUnsupported.Load() {
+ if prSetVMAUnsupported.Load() {
return
}
I see this:
patryk@patryk:~$ GLIBC_TUNABLES=glibc.mem.decorate_maps=1 go run a.go
# command-line-arguments
./a.go: In function \u2018f\u2019:
./a.go:13:9: warning: ignoring return value of \u2018malloc\u2019 declared with attribute \u2018warn_unused_result\u2019 [-Wunused-result]
13 | (void)malloc(1024*1024*1024);
| ^~~~~~~~~~~~~~~~~~~~~~
00400000-00574000 r-xp 00000000 00:2d 441968 /tmp/go-build4081026567/b001/exe/a
0058f000-00590000 r--p 0017f000 00:2d 441968 /tmp/go-build4081026567/b001/exe/a
00590000-0059b000 rw-p 00180000 00:2d 441968 /tmp/go-build4081026567/b001/exe/a
0059b000-005d7000 rw-p 00000000 00:00 0
3f99c000-3f9bd000 rw-p 00000000 00:00 0 [heap]
4000000000-4000400000 rw-p 00000000 00:00 0 [anon: Go: heap]
4000400000-4004000000 ---p 00000000 00:00 0 [anon: Go: heap reservation]
f856a0000000-f856a0021000 rw-p 00000000 00:00 0 [anon: glibc: malloc arena]
f856a0021000-f856a4000000 ---p 00000000 00:00 0
f856a8000000-f856a8021000 rw-p 00000000 00:00 0 [anon: glibc: malloc arena]
f856a8021000-f856ac000000 ---p 00000000 00:00 0
f856ac000000-f856ac021000 rw-p 00000000 00:00 0 [anon: glibc: malloc arena]
f856ac021000-f856b0000000 ---p 00000000 00:00 0
f856b0000000-f856b0021000 rw-p 00000000 00:00 0 [anon: glibc: malloc arena]
f856b0021000-f856b4000000 ---p 00000000 00:00 0
f856b4630000-f856b4640000 ---p 00000000 00:00 0
f856b4640000-f856b4e40000 rw-p 00000000 00:00 0
f856b4e40000-f856b4e50000 ---p 00000000 00:00 0
f856b4e50000-f856b5650000 rw-p 00000000 00:00 0 [anon: glibc: pthread stack: 608452]
f856b5650000-f856b5690000 rw-p 00000000 00:00 0 [anon: Go: immortal metadata]
f856b5690000-f856b56a0000 ---p 00000000 00:00 0
f856b56a0000-f856b5ea0000 rw-p 00000000 00:00 0 [anon: glibc: pthread stack: 608451]
f856b5ea0000-f856b5eb0000 ---p 00000000 00:00 0
f856b5eb0000-f856b66b0000 rw-p 00000000 00:00 0 [anon: glibc: pthread stack: 608450]
f856b66b0000-f856b66f0000 rw-p 00000000 00:00 0 [anon: Go: immortal metadata]
f856b66f0000-f856b6700000 ---p 00000000 00:00 0
f856b6700000-f856b6f00000 rw-p 00000000 00:00 0 [anon: glibc: pthread stack: 608449]
f856b6f00000-f856b7000000 rw-p 00000000 00:00 0 [anon: Go: page alloc index]
f856b7000000-f856b9000000 rw-p 00000000 00:00 0 [anon: Go: heap index]
f856b9000000-f856b9080000 ---p 00000000 00:00 0 [anon: Go: scavenge index]
f856b9080000-f856b9081000 rw-p 00000000 00:00 0 [anon: Go: scavenge index]
f856b9081000-f856d9000000 ---p 00000000 00:00 0 [anon: Go: scavenge index]
f856d9000000-f856d9080000 ---p 00000000 00:00 0 [anon: Go: page summary]
f856d9080000-f856d9081000 rw-p 00000000 00:00 0 [anon: Go: page alloc]
f856d9081000-f856f9010000 ---p 00000000 00:00 0 [anon: Go: page summary]
f856f9010000-f856f9011000 rw-p 00000000 00:00 0 [anon: Go: page alloc]
f856f9011000-f856fd002000 ---p 00000000 00:00 0 [anon: Go: page summary]
f856fd002000-f856fd003000 rw-p 00000000 00:00 0 [anon: Go: page alloc]
f856fd003000-f856fd800000 ---p 00000000 00:00 0 [anon: Go: page summary]
f856fd80e000-f856fd81e000 rw-p 00000000 00:00 0 [anon: Go: gc bits]
f856fd81e000-f856fd82e000 rw-p 00000000 00:00 0 [anon: Go: allspans array]
f856fd82e000-f856fd840000 rw-p 00000000 00:00 0 [anon: Go: immortal metadata]
f856fd840000-f856fd841000 rw-p 00000000 00:00 0 [anon: Go: page alloc]
f856fd841000-f856fd940000 ---p 00000000 00:00 0 [anon: Go: page summary]
f856fd940000-f856fd960000 rw-p 00000000 00:00 0 [anon: Go: page alloc]
f856fd960000-f856fd9a0000 rw-p 00000000 00:00 0 [anon: Go: immortal metadata]
f856fd9a0000-f856fdb4a000 r-xp 00000000 fd:02 18747670 /usr/lib/aarch64-linux-gnu/libc.so.6
f856fdb4a000-f856fdb5d000 ---p 001aa000 fd:02 18747670 /usr/lib/aarch64-linux-gnu/libc.so.6
f856fdb5d000-f856fdb60000 r--p 001ad000 fd:02 18747670 /usr/lib/aarch64-linux-gnu/libc.so.6
f856fdb60000-f856fdb62000 rw-p 001b0000 fd:02 18747670 /usr/lib/aarch64-linux-gnu/libc.so.6
f856fdb62000-f856fdb6f000 rw-p 00000000 00:00 0
f856fdb79000-f856fdba2000 r-xp 00000000 fd:02 18747364 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
f856fdbb1000-f856fdbb3000 rw-p 00000000 00:00 0 [anon: glibc: loader malloc]
f856fdbb3000-f856fdbb5000 r--p 00000000 00:00 0 [vvar]
f856fdbb5000-f856fdbb7000 r-xp 00000000 00:00 0 [vdso]
f856fdbb7000-f856fdbb9000 r--p 0002e000 fd:02 18747364 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
f856fdbb9000-f856fdbba000 rw-p 00030000 fd:02 18747364 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
f856fdbba000-f856fdbbb000 rw-p 00000000 00:00 0
fffff27de000-fffff27ff000 rw-p 00000000 00:00 0 [stack]
Metadata
Metadata
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
Status
Done