Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime,cmd/go: runtime: out of memory in runtime.sysMapOS #53576

Open
bcmills opened this issue Jun 27, 2022 · 10 comments
Open

runtime,cmd/go: runtime: out of memory in runtime.sysMapOS #53576

bcmills opened this issue Jun 27, 2022 · 10 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Jun 27, 2022

#!watchflakes
post <- `runtime: out of memory` && `^\s*runtime\.sysMapOS`
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0xa25205?, 0x20000?})
	/tmp/workdir/go/src/runtime/panic.go:1047 +0x5d fp=0x243c4b248 sp=0x243c4b218 pc=0x43621d
runtime.sysMapOS(0xc001400000, 0xc000800000?)
	/tmp/workdir/go/src/runtime/mem_bsd.go:71 +0x11b fp=0x243c4b290 sp=0x243c4b248 pc=0x41975b
runtime.sysMap(0xe46c80?, 0x21b3a8000?, 0x42cb80?)
	/tmp/workdir/go/src/runtime/mem.go:142 +0x35 fp=0x243c4b2c0 sp=0x243c4b290 pc=0x419595
runtime.(*mheap).grow(0xe46c80, 0x6000292?)
	/tmp/workdir/go/src/runtime/mheap.go:1459 +0x23d fp=0x243c4b330 sp=0x243c4b2c0 pc=0x429c3d
runtime.(*mheap).allocSpan(0xe46c80, 0x6000292, 0x0, 0x1)
	/tmp/workdir/go/src/runtime/mheap.go:1191 +0x2e6 fp=0x243c4b3e0 sp=0x243c4b330 pc=0x4293c6
runtime.(*mheap).alloc.func1()
	/tmp/workdir/go/src/runtime/mheap.go:910 +0x65 fp=0x243c4b428 sp=0x243c4b3e0 pc=0x428d25
runtime.systemstack()
	/tmp/workdir/go/src/runtime/asm_amd64.s:492 +0x49 fp=0x243c4b430 sp=0x243c4b428 pc=0x464729

I notice that sysMapOS and sysReserveOS on BSD both invoke mmap, and cmd/go has recently started using syscall.Mmap to access cached metadata during package loading.

I can think of the following possible explanations, but I'm not sure which (if any) is correct.

  1. Perhaps a bug in cmd/go (perhaps on the indexing path) is causing it to use more memory than expected?
  2. Perhaps a bug in the OpenBSD mmap implementation causes the cmd/go call to syscall.Mmap to steal an address that was supposed to be reserved for the runtime?
  3. Perhaps a bug somewhere in the runtime causes it to drastically overshoot the heap target? (But I would expect the syscall.Mmap usage to instead cause it to undershoot, since the heap size used to compute GOGC will not include the Mmap'd data.)

This is another case where it would be really helpful to have some heap stats from the runtime when the process OOMs (#52546)...

(CC @golang/openbsd @golang/runtime)

@bcmills bcmills added OS-OpenBSD NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 27, 2022
@bcmills bcmills added this to the Backlog milestone Jun 27, 2022
@bcmills
Copy link
Contributor Author

bcmills commented Jun 27, 2022

Leaving on the backlog for now to see whether a pattern emerges. (Would be useful to know whether this failure mode is GOOS-specific.)

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
@costela
Copy link
Contributor

costela commented Feb 18, 2023

I'm experiencing a similar issue while running go mod tidy in a project, which I suspect may be related:

fatal error: runtime: out of memory

runtime stack:
runtime.throw({0xa4885c?, 0x0?})
        /usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0x7f371dffac80 sp=0x7f371dffac50 pc=0x436b7d
runtime.sysMapOS(0xc005000000, 0x400000?)
        /usr/local/go/src/runtime/mem_linux.go:187 +0x11b fp=0x7f371dffacc8 sp=0x7f371dffac80 pc=0x41999b
runtime.sysMap(0xc000000000?, 0xc3ffffffff?, 0x7f374d569000?)
        /usr/local/go/src/runtime/mem.go:142 +0x35 fp=0x7f371dffacf8 sp=0x7f371dffacc8 pc=0x419375
runtime.(*mheap).grow(0xe76b00, 0x4?)
        /usr/local/go/src/runtime/mheap.go:1522 +0x245 fp=0x7f371dffad70 sp=0x7f371dffacf8 pc=0x429aa5
runtime.(*mheap).allocSpan(0xe76b00, 0x4, 0x0, 0xef?)
        /usr/local/go/src/runtime/mheap.go:1243 +0x1b7 fp=0x7f371dffae08 sp=0x7f371dffad70 pc=0x4291f7
runtime.(*mheap).alloc.func1()
        /usr/local/go/src/runtime/mheap.go:961 +0x65 fp=0x7f371dffae50 sp=0x7f371dffae08 pc=0x428ca5
runtime.systemstack()
        /usr/local/go/src/runtime/asm_amd64.s:496 +0x49 fp=0x7f371dffae58 sp=0x7f371dffae50 pc=0x466dc9

Of note: this is on linux, not BSD.

I haven't been able to find a minimal example yet (the project in question is unfortunately not small), but one interesting detail that might be interesting: cleaning the cache via go clean -cache allows the next go mod tidy to run normally.

This affected at least 1.19 and 1.20.

@pazof
Copy link

pazof commented Apr 10, 2023

I'm experimenting a SIGSEGV, launching woodpecker server 1.15.7 from my Debian 11.6,
at the same source line : /usr/local/go/src/runtime/panic.go:1047 (having configured a Postgresql connection).

@gopherbot
Copy link

Found new dashboard test flakes for:

#!watchflakes
post <- `runtime: out of memory` && `^\s*runtime\.sysMapOS`
2023-11-16 19:26 openbsd-386-72 go@d573a8a8 runtime/trace.TestTraceCPUProfile (log)
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0x81ffb4e, 0x16})
	/tmp/workdir/go/src/runtime/panic.go:1023 +0x4d fp=0x12e44704 sp=0x12e446f0 pc=0x8082ddd
runtime.sysMapOS(0xad000000, 0x800000)
	/tmp/workdir/go/src/runtime/mem_bsd.go:81 +0x142 fp=0x12e44730 sp=0x12e44704 pc=0x805ef32
runtime.sysMap(0xad000000, 0x800000, 0x834b118)
	/tmp/workdir/go/src/runtime/mem.go:155 +0x3f fp=0x12e44740 sp=0x12e44730 pc=0x805ed0f
runtime.(*mheap).grow(0x833dde0, 0x375)
...
	/tmp/workdir/go/src/internal/trace/parser.go:269 +0x152b fp=0x6dcd8ba0 sp=0x6dcd8a6c pc=0x816775b
internal/trace.parse({0x8239b70, 0x6dde00f0}, {0x0, 0x0})
	/tmp/workdir/go/src/internal/trace/parser.go:104 +0x27 fp=0x6dcd8bec sp=0x6dcd8ba0 pc=0x8165f87
internal/trace.Parse({0x8239b70, 0x6dde00f0}, {0x0, 0x0})
	/tmp/workdir/go/src/internal/trace/parser.go:91 +0x37 fp=0x6dcd8c1c sp=0x6dcd8bec pc=0x8165e67
runtime/trace_test.parseTrace(0x6dca8300, {0x8239b70, 0x6dde00f0})
	/tmp/workdir/go/src/runtime/trace/trace_test.go:154 +0x47 fp=0x6dcd8d54 sp=0x6dcd8c1c pc=0x81b11c7
runtime/trace_test.TestTraceCPUProfile(0x6dca8300)
	/tmp/workdir/go/src/runtime/trace/trace_test.go:699 +0x461 fp=0x6dcd8f98 sp=0x6dcd8d54 pc=0x81b4361
testing.tRunner(0x6dca8300, 0x820a06c)

watchflakes

@gopherbot
Copy link

Found new dashboard test flakes for:

#!watchflakes
post <- `runtime: out of memory` && `^\s*runtime\.sysMapOS`
2023-11-20 15:56 openbsd-386-72 go@1d187fd0 runtime/trace (log)
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0x8201b63, 0x16})
	/tmp/workdir/go/src/runtime/panic.go:1023 +0x4d fp=0x21321c84 sp=0x21321c70 pc=0x8082dfd
runtime.sysMapOS(0xae400000, 0x800000)
	/tmp/workdir/go/src/runtime/mem_bsd.go:81 +0x142 fp=0x21321cb0 sp=0x21321c84 pc=0x805ef12
runtime.sysMap(0xae400000, 0x800000, 0x834f118)
	/tmp/workdir/go/src/runtime/mem.go:155 +0x3f fp=0x21321cc0 sp=0x21321cb0 pc=0x805ecef
runtime.(*mheap).grow(0x8341de0, 0x375)
...
runtime.gopark(0x0, 0x0, 0xa, 0x10, 0x1)
	/tmp/workdir/go/src/runtime/proc.go:402 +0xfa fp=0x6f4c2fd4 sp=0x6f4c2fc0 pc=0x8085dba
runtime.block()
	/tmp/workdir/go/src/runtime/select.go:103 +0x32 fp=0x6f4c2fe8 sp=0x6f4c2fd4 pc=0x80968b2
runtime/trace_test.TestTraceStressStartStop.func1.10()
	/tmp/workdir/go/src/runtime/trace/trace_test.go:496 +0x23 fp=0x6f4c2ff0 sp=0x6f4c2fe8 pc=0x81b6b73
runtime.goexit({})
	/tmp/workdir/go/src/runtime/asm_386.s:1363 +0x1 fp=0x6f4c2ff4 sp=0x6f4c2ff0 pc=0x80b77b1
created by runtime/trace_test.TestTraceStressStartStop.func1 in goroutine 35
	/tmp/workdir/go/src/runtime/trace/trace_test.go:494 +0x6c8

watchflakes

@gopherbot
Copy link

Found new dashboard test flakes for:

#!watchflakes
post <- `runtime: out of memory` && `^\s*runtime\.sysMapOS`
2023-11-21 16:29 openbsd-386-72 go@78d037b0 runtime/trace (log)
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0x8201b63, 0x16})
	/tmp/workdir/go/src/runtime/panic.go:1023 +0x4d fp=0x3dd75914 sp=0x3dd75900 pc=0x8082dfd
runtime.sysMapOS(0x9f800000, 0x400000)
	/tmp/workdir/go/src/runtime/mem_bsd.go:81 +0x142 fp=0x3dd75940 sp=0x3dd75914 pc=0x805ef12
runtime.sysMap(0x9f800000, 0x400000, 0x834f118)
	/tmp/workdir/go/src/runtime/mem.go:155 +0x3f fp=0x3dd75950 sp=0x3dd75940 pc=0x805ecef
runtime.(*mheap).grow(0x8341de0, 0x1)
...

goroutine 116 gp=0x60982488 m=nil [GC worker (idle)]:
runtime.gopark(0x820c1dc, 0x6098e060, 0x1a, 0x14, 0x0)
	/tmp/workdir/go/src/runtime/proc.go:402 +0xfa fp=0x60a03794 sp=0x60a03780 pc=0x8085dba
runtime.gcBgMarkWorker()
	/tmp/workdir/go/src/runtime/mgc.go:1310 +0xe5 fp=0x60a037f0 sp=0x60a03794 pc=0x8064575
runtime.goexit({})
	/tmp/workdir/go/src/runtime/asm_386.s:1363 +0x1 fp=0x60a037f4 sp=0x60a037f0 pc=0x80b77b1
created by runtime.gcBgMarkStartWorkers in goroutine 35
	/tmp/workdir/go/src/runtime/mgc.go:1234 +0x1f

watchflakes

@gopherbot
Copy link

Found new dashboard test flakes for:

#!watchflakes
post <- `runtime: out of memory` && `^\s*runtime\.sysMapOS`
2023-11-21 17:59 openbsd-386-72 go@070139a1 runtime/trace (log)
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0x8201b6f, 0x16})
	/tmp/workdir/go/src/runtime/panic.go:1023 +0x4d fp=0x212e0044 sp=0x212e0030 pc=0x8082dfd
runtime.sysMapOS(0x82c00000, 0x400000)
	/tmp/workdir/go/src/runtime/mem_bsd.go:81 +0x142 fp=0x212e0070 sp=0x212e0044 pc=0x805ef12
runtime.sysMap(0x82c00000, 0x400000, 0x834f138)
	/tmp/workdir/go/src/runtime/mem.go:155 +0x3f fp=0x212e0080 sp=0x212e0070 pc=0x805ecef
runtime.(*mheap).grow(0x8341e00, 0x12)
...
runtime.gopark(0x0, 0x0, 0xa, 0x10, 0x1)
	/tmp/workdir/go/src/runtime/proc.go:402 +0xfa fp=0x4fd067d4 sp=0x4fd067c0 pc=0x8085dba
runtime.block()
	/tmp/workdir/go/src/runtime/select.go:103 +0x32 fp=0x4fd067e8 sp=0x4fd067d4 pc=0x80968b2
runtime/trace_test.TestTraceStressStartStop.func1.10()
	/tmp/workdir/go/src/runtime/trace/trace_test.go:496 +0x23 fp=0x4fd067f0 sp=0x4fd067e8 pc=0x81b6b73
runtime.goexit({})
	/tmp/workdir/go/src/runtime/asm_386.s:1363 +0x1 fp=0x4fd067f4 sp=0x4fd067f0 pc=0x80b77b1
created by runtime/trace_test.TestTraceStressStartStop.func1 in goroutine 35
	/tmp/workdir/go/src/runtime/trace/trace_test.go:494 +0x6c8

watchflakes

@gopherbot
Copy link

Found new dashboard test flakes for:

#!watchflakes
post <- `runtime: out of memory` && `^\s*runtime\.sysMapOS`
2023-11-21 20:34 openbsd-386-72 go@00715d08 runtime/trace (log)
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0x8201b6f, 0x16})
	/tmp/workdir/go/src/runtime/panic.go:1023 +0x4d fp=0x46bb8494 sp=0x46bb8480 pc=0x8082dfd
runtime.sysMapOS(0xa9c00000, 0x1000000)
	/tmp/workdir/go/src/runtime/mem_bsd.go:81 +0x142 fp=0x46bb84c0 sp=0x46bb8494 pc=0x805ef12
runtime.sysMap(0xa9c00000, 0x1000000, 0x834f138)
	/tmp/workdir/go/src/runtime/mem.go:155 +0x3f fp=0x46bb84d0 sp=0x46bb84c0 pc=0x805ecef
runtime.(*mheap).grow(0x8341e00, 0x6c4)
...

goroutine 87 gp=0x6a9027e8 m=nil [GC worker (idle)]:
runtime.gopark(0x820c1e8, 0x6a92a078, 0x1a, 0x14, 0x0)
	/tmp/workdir/go/src/runtime/proc.go:402 +0xfa fp=0x6a8c0794 sp=0x6a8c0780 pc=0x8085dba
runtime.gcBgMarkWorker()
	/tmp/workdir/go/src/runtime/mgc.go:1310 +0xe5 fp=0x6a8c07f0 sp=0x6a8c0794 pc=0x8064575
runtime.goexit({})
	/tmp/workdir/go/src/runtime/asm_386.s:1363 +0x1 fp=0x6a8c07f4 sp=0x6a8c07f0 pc=0x80b77b1
created by runtime.gcBgMarkStartWorkers in goroutine 35
	/tmp/workdir/go/src/runtime/mgc.go:1234 +0x1f

watchflakes

@gopherbot
Copy link

Found new dashboard test flakes for:

#!watchflakes
post <- `runtime: out of memory` && `^\s*runtime\.sysMapOS`
2023-11-21 21:27 openbsd-386-72 go@351d8520 runtime/trace (log)
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0x8202d22, 0x16})
	/tmp/workdir/go/src/runtime/panic.go:1023 +0x4d fp=0x27d50c24 sp=0x27d50c10 pc=0x808372d
runtime.sysMapOS(0xa0400000, 0x400000)
	/tmp/workdir/go/src/runtime/mem_bsd.go:81 +0x142 fp=0x27d50c50 sp=0x27d50c24 pc=0x805f032
runtime.sysMap(0xa0400000, 0x400000, 0x8350218)
	/tmp/workdir/go/src/runtime/mem.go:155 +0x3f fp=0x27d50c60 sp=0x27d50c50 pc=0x805ee0f
runtime.(*mheap).grow(0x8342ee0, 0x1)
...

goroutine 131 gp=0x61500368 m=nil [GC worker (idle)]:
runtime.gopark(0x820d3b4, 0x61510018, 0x1a, 0x14, 0x0)
	/tmp/workdir/go/src/runtime/proc.go:402 +0xfa fp=0x61482f94 sp=0x61482f80 pc=0x80866ea
runtime.gcBgMarkWorker()
	/tmp/workdir/go/src/runtime/mgc.go:1310 +0xe5 fp=0x61482ff0 sp=0x61482f94 pc=0x8064695
runtime.goexit({})
	/tmp/workdir/go/src/runtime/asm_386.s:1363 +0x1 fp=0x61482ff4 sp=0x61482ff0 pc=0x80b8121
created by runtime.gcBgMarkStartWorkers in goroutine 35
	/tmp/workdir/go/src/runtime/mgc.go:1234 +0x1f
2023-11-21 21:27 openbsd-386-72 go@48a6362d runtime/trace (log)
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0x8202d22, 0x16})
	/tmp/workdir/go/src/runtime/panic.go:1023 +0x4d fp=0x217318c4 sp=0x217318b0 pc=0x808372d
runtime.sysMapOS(0xa3800000, 0x400000)
	/tmp/workdir/go/src/runtime/mem_bsd.go:81 +0x142 fp=0x217318f0 sp=0x217318c4 pc=0x805f032
runtime.sysMap(0xa3800000, 0x400000, 0x8350218)
	/tmp/workdir/go/src/runtime/mem.go:155 +0x3f fp=0x21731900 sp=0x217318f0 pc=0x805ee0f
runtime.(*mheap).grow(0x8342ee0, 0x1)
...
runtime.gopark(0x0, 0x0, 0xa, 0x10, 0x1)
	/tmp/workdir/go/src/runtime/proc.go:402 +0xfa fp=0x649037d4 sp=0x649037c0 pc=0x80866ea
runtime.block()
	/tmp/workdir/go/src/runtime/select.go:103 +0x32 fp=0x649037e8 sp=0x649037d4 pc=0x8097232
runtime/trace_test.TestTraceStressStartStop.func1.10()
	/tmp/workdir/go/src/runtime/trace/trace_test.go:496 +0x23 fp=0x649037f0 sp=0x649037e8 pc=0x81b7523
runtime.goexit({})
	/tmp/workdir/go/src/runtime/asm_386.s:1363 +0x1 fp=0x649037f4 sp=0x649037f0 pc=0x80b8121
created by runtime/trace_test.TestTraceStressStartStop.func1 in goroutine 35
	/tmp/workdir/go/src/runtime/trace/trace_test.go:494 +0x6c8
2023-11-21 21:29 openbsd-386-72 go@90ba4452 runtime/trace (log)
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0x8202d22, 0x16})
	/tmp/workdir/go/src/runtime/panic.go:1023 +0x4d fp=0x2ec54984 sp=0x2ec54970 pc=0x808372d
runtime.sysMapOS(0x95c00000, 0x400000)
	/tmp/workdir/go/src/runtime/mem_bsd.go:81 +0x142 fp=0x2ec549b0 sp=0x2ec54984 pc=0x805f032
runtime.sysMap(0x95c00000, 0x400000, 0x8350218)
	/tmp/workdir/go/src/runtime/mem.go:155 +0x3f fp=0x2ec549c0 sp=0x2ec549b0 pc=0x805ee0f
runtime.(*mheap).grow(0x8342ee0, 0x12)
...
runtime.gopark(0x0, 0x0, 0xa, 0x10, 0x1)
	/tmp/workdir/go/src/runtime/proc.go:402 +0xfa fp=0x5683afd4 sp=0x5683afc0 pc=0x80866ea
runtime.block()
	/tmp/workdir/go/src/runtime/select.go:103 +0x32 fp=0x5683afe8 sp=0x5683afd4 pc=0x8097232
runtime/trace_test.TestTraceStressStartStop.func1.10()
	/tmp/workdir/go/src/runtime/trace/trace_test.go:496 +0x23 fp=0x5683aff0 sp=0x5683afe8 pc=0x81b7523
runtime.goexit({})
	/tmp/workdir/go/src/runtime/asm_386.s:1363 +0x1 fp=0x5683aff4 sp=0x5683aff0 pc=0x80b8121
created by runtime/trace_test.TestTraceStressStartStop.func1 in goroutine 35
	/tmp/workdir/go/src/runtime/trace/trace_test.go:494 +0x6c8

watchflakes

@gopherbot
Copy link

Found new dashboard test flakes for:

#!watchflakes
post <- `runtime: out of memory` && `^\s*runtime\.sysMapOS`
2024-02-02 16:26 openbsd-386-72 go@2fdad8af runtime/trace.TestTraceCPUProfile (log)
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0x81fbb69, 0x16})
	/tmp/workdir/go/src/runtime/panic.go:1077 +0x4d fp=0x493334cc sp=0x493334b8 pc=0x80826ed
runtime.sysMapOS(0x97c00000, 0x400000)
	/tmp/workdir/go/src/runtime/mem_bsd.go:81 +0x144 fp=0x493334f8 sp=0x493334cc pc=0x805e894
runtime.sysMap(0x97c00000, 0x400000, 0x8340958)
	/tmp/workdir/go/src/runtime/mem.go:155 +0x3f fp=0x49333508 sp=0x493334f8 pc=0x805e66f
runtime.(*mheap).grow(0x8333640, 0x42)
...
	/tmp/workdir/go/src/internal/trace/parser.go:269 +0x156f fp=0x5a841b90 sp=0x5a841a5c pc=0x816434f
internal/trace.parse({0x82348e0, 0x5a886588}, {0x0, 0x0})
	/tmp/workdir/go/src/internal/trace/parser.go:104 +0x27 fp=0x5a841bdc sp=0x5a841b90 pc=0x8162b27
internal/trace.Parse({0x82348e0, 0x5a886588}, {0x0, 0x0})
	/tmp/workdir/go/src/internal/trace/parser.go:91 +0x37 fp=0x5a841c0c sp=0x5a841bdc pc=0x8162a07
runtime/trace_test.parseTrace(0x5a8b03c0, {0x82348e0, 0x5a886588})
	/tmp/workdir/go/src/runtime/trace/trace_test.go:146 +0x47 fp=0x5a841d48 sp=0x5a841c0c pc=0x81ade97
runtime/trace_test.TestTraceCPUProfile(0x5a8b03c0)
	/tmp/workdir/go/src/runtime/trace/trace_test.go:676 +0x473 fp=0x5a841f98 sp=0x5a841d48 pc=0x81b10a3
testing.tRunner(0x5a8b03c0, 0x82060b8)

watchflakes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Status: Triage Backlog
Status: No status
Development

No branches or pull requests

4 participants